Insights / Embedded & Firmware

MQTT Security: Why TLS to the Broker Is Not End-to-End Encryption

TLS protects the link to an MQTT broker, but the broker, a relaying phone and the cloud still read every message. How application-layer encryption closes that gap on small MCUs.

Portrait of Ivan Karbovnyk

Ivan Karbovnyk

Chief Technology Officer

Chief Technology Officer, responsible for Indeema's technology strategy, and a professor of radiophysics and computer technologies at Ivan Franko National University of Lviv.

View leadership profile

A wearable medical sensor and a smartphone on a dark workbench, linked by a glowing green line with padlock marks that runs unbroken toward a server rack

The short answer

MQTT security usually means TLS between each device and the broker, plus authentication and topic permissions. That protects the network path, but TLS ends at the broker: the broker, any phone or gateway that relays data, and the cloud behind them can all read the messages. To keep data private from them, encrypt at the application layer, end to end between the nodes that create and use the data. Frameworks such as the Microchip Connectivity Framework (MCF) do this with standard ECDH, HKDF and ECDSA in 20–30 kB of flash, over MQTT or any other link.

Key takeaways

  • TLS, authentication and topic permissions are the baseline for any MQTT deployment, and they protect the path, not the content.
  • TLS ends at the broker, so the broker, relaying phones and gateways, and the cloud can read every message.
  • Application-layer end-to-end encryption keeps the data unreadable to everything between the two nodes that use it.
  • MCF adds this layer in 20–30 kB of flash on 8- to 32-bit MCUs, over MQTT, Bluetooth, CAN and other links. Indeema implements it on devices and runs its cloud instances.
  • Encryption helps with the CRA and sector standards, but compliance also needs secure boot, updates and vulnerability handling.

MQTT security best practices: the baseline

MQTT
MQTT is a lightweight publish-subscribe messaging protocol. Devices publish messages to topics on a central server called a broker, and the broker delivers each message to every client subscribed to that topic.

The MQTT standard leaves security to the deployment. In practice, a well-run system adds five controls, and every one of them belongs in a production device:

  • TLS between each client and the broker, so nobody on the network path can read or change the traffic. Secure MQTT runs on port 8883, which is registered with IANA for MQTT over TLS. Port 1883 carries unencrypted MQTT and should stay closed to the internet.
  • Client authentication with a certificate per device (mutual TLS), or at least a username and password. MQTT 5 also supports extended authentication, so the client and broker can run a challenge-response exchange.
  • Authorisation rules on the broker that limit which topics each client may publish or subscribe to.
  • Broker hardening: no anonymous access, closed admin ports, rate limits and logging.
  • Monitoring: alerts on failed logins, on clients that subscribe to the # wildcard, and on sudden changes in message rates.

Broker vendors describe much the same baseline in their security guides, and it stops most attacks from outside. It does not change who can read the messages once they arrive.

Where the data is still exposed

TLS protects one link at a time. It ends at the broker, because the broker has to read the topic to route the message. The payload is decrypted there and encrypted again for the next link. The same happens on a phone or gateway that relays data from a device without an IP stack.

Green message envelopes stream into a rack server and turn bright white inside it before leaving green again, showing data exposed at the broker
With TLS on each link, the broker decrypts every message to route it, so the content is readable in the middle
  1. Sensor deviceEncrypts the reading for the Bluetooth link to the phone.
  2. Phone appDecrypts the Bluetooth traffic, then opens a new TLS session to the broker. The app can read and change the data.
  3. MQTT brokerEnds TLS, reads the topic and the payload, and forwards the message.
  4. Cloud applicationStores the message, often in one central database.
  5. Clinician's PCReceives the data over a second TLS session from the cloud.

Every hop is encrypted, but the phone, the broker and the cloud each see the data in plain text.

A typical connected medical device: where the message is readable with TLS on every link
Who can read a device message, by protection model
Point in the pathTLS on each linkApplication-layer end-to-end encryption
Network between hopsCannot readCannot read
Phone or gateway that relays dataCan read and changeForwards encrypted bytes
MQTT brokerCan readRoutes encrypted bytes by topic
Cloud provider or integrator running the brokerCan readCannot read
Receiving application at the far endCan readCan read

For many products this is acceptable. It stops being acceptable when the data is health data, when a customer contract says no third party may see production data, or when a compromised phone app must not be able to send commands to the device.

How application-layer end-to-end encryption closes the gap

End-to-end encryption in IoT
End-to-end encryption means a message is encrypted on the device that creates it and decrypted only on the node it is meant for. Every system in between carries bytes it cannot read.

The usual building blocks are standard elliptic-curve cryptography. Each node holds a certificate and a private key. Two nodes agree on a shared secret with ECDH, derive session keys from it with HKDF, and sign what they send with ECDSA, so the receiver knows who sent a message and that nobody changed it.

Because this layer sits above the transport, MQTT, Bluetooth, CAN or a serial line underneath carry it unchanged. The broker still sees the topic and routes the message. It just cannot open it.

How MCF does it

The Microchip Connectivity Framework (MCF) is one way to build this layer. It is a set of software libraries and tools that add an encrypted messaging layer at the application level. It only needs access to the input and output buffers of whatever driver or stack is already there, so the transport code stays as it is.

MCF at a glance, from the published MCF specification
PropertyMCF
CryptographyECDSA, ECDH, HKDF
Hardware8-, 16- and 32-bit MCUs and MPUs
Links underneathUART, SPI, CAN, 10BASE-T1S, Ethernet, Wi-Fi, 802.15.4, Bluetooth and others
Flash footprintFrom 20 kB to 30 kB
TopologiesPoint to point, star and mesh
Cloud linkA standard MQTT broker plus a small application that extends the network through the cloud
Keys and certificatesHeld in a PKI the customer controls

With MCF, the broker becomes part of the transport. A sensor and a clinician's PC, or a controller and a service laptop, keep one secure session between them while the bytes travel over Bluetooth, through a phone, through the broker and across the internet. For a fuller walk-through of clusters, gateways and node identity, see our MCF overview.

Two embedded boards on a bench; a microcontroller and a small secure element on one board, with a green glow tracing the twisted-pair cable to the second board
Application-layer encryption runs on the microcontroller itself, and private keys can stay in a secure element, over any wired link

What it takes to run MCF in a product

At Indeema we implement MCF on devices and run its cloud instances (see MCF on our ecosystem page). The library is the smaller part of the work. Most of the effort goes into the parts around it:

  • The cloud instance. We run it as a shared instance, a dedicated instance, or on-premise on the customer's own server. Services run in an isolated environment behind a firewall that limits inbound and outbound traffic.
  • Scale. For large fleets the instance runs on Kubernetes, with a load balancer, automatic scale-down when demand drops, and metrics for monitoring.
  • Firmware ports. Porting the library to the target MCU and connecting it to the existing Bluetooth, CAN or Wi-Fi stack.
  • Key storage. Where the threat model asks for it, private keys go into a hardware security module or secure element instead of flash.
  • Updates. Firmware updates delivered through the same secure channel.

Why device makers ask for it

Product teams rarely search for application-layer encryption. They come with a business problem, and encryption turns out to be part of the answer.

Business needs that end-to-end message encryption addresses
NeedTypical buyerWhat end-to-end encryption changes
Keep selling in the EU under new security rulesAny maker of connected devices for the EU marketGives evidence for the confidentiality and integrity requirements on data in transit
Keep data away from the cloud provider or integratorMedical, industrial and public-sector customersThe party running the broker carries data it cannot read
Avoid lock-in to one cloud IoT serviceTeams built on one provider's IoT platformA standard MQTT broker on any cloud or on-premise does the routing
Limit the damage of a breachAnyone holding sensitive data from a fleetA compromised broker or relay app does not expose message content
Add security to a product already in the fieldProducts on small MCUs and non-IP busesA 20–30 kB library above existing drivers can often arrive as a firmware update
One security model for mixed linksGateways, hubs and plants with Bluetooth, CAN and Wi-Fi side by sideOne secure session across all links instead of a separate fix per bus
A wearable sensor, smartphone, industrial gateway, two controller boards and a laptop on a dark bench, joined in a ring by one continuous green line
One secure session can run across Bluetooth, cable, CAN and Wi-Fi links between the devices in a system

Where regulation comes in

European rules now treat protection of data in transit as a basic requirement. The Cyber Resilience Act asks manufacturers to protect the confidentiality and integrity of data and commands. Its vulnerability reporting obligations apply from 11 September 2026, and the main requirements from 11 December 2027. Radio equipment already falls under the cybersecurity requirements of the Radio Equipment Directive, which apply from 1 August 2025.

Sector standards say the same in more detail: ETSI EN 303 645 for consumer IoT, and IEC 62443-4-2 for components of industrial control systems. End-to-end encryption helps meet the parts of these rules that concern communication. It does not make a product compliant on its own, because the same rules also cover secure boot, updates, default settings and how the maker handles vulnerabilities. Our Cyber Resilience Act guide covers the rest.

When TLS is enough and when it is not

TLS to a well-configured broker is enough when you run the broker yourself, trust everyone who operates it, and devices talk to the cloud directly. Consider an application-layer framework such as MCF if one of these is true:

Signs you need end-to-end encryption

  • A third party runs the broker or the cloud, and must not see the data
  • Data passes through a phone, gateway or hub you do not fully control
  • Devices talk over Bluetooth, CAN or serial links, not only IP
  • A customer contract or regulator asks who can access production data
  • You want to change cloud provider later without redesigning device security

Engineering trade-offs

TLS to the broker only

You gain
Simple, supported by every broker and MQTT library.
You pay
The broker operator, relaying apps and the cloud can read all data.
Choose it when
You run the broker and every hop yourself and the data is not sensitive.

Application-layer end-to-end encryption

You gain
Data stays private across brokers, phones, gateways and clouds.
You pay
You own a PKI, certificate provisioning and key rotation, and debugging encrypted traffic takes more tooling.
Choose it when
Third parties carry the data, or links other than IP are involved.

Encrypt payloads ad hoc in application code

You gain
No new dependency.
You pay
Teams tend to reinvent key exchange, replay protection and identity, and get one of them wrong.
Choose it when
Rarely. Prefer a reviewed framework or library.

Common mistakes

  1. Calling TLS to the broker end-to-end encryption

    Security reviews and customers assume the operator cannot read data when it can.

    Instead: Describe exactly where TLS ends, and add application-layer encryption where the data must stay private.

  2. Leaving meaning in topic names

    Encrypted payloads still reveal patient, site or device details through the topic tree.

    Instead: Use opaque topic identifiers and keep the mapping inside the encrypted layer.

  3. Storing device private keys in plain flash

    A device pulled from the field gives up its identity and the ability to impersonate it.

    Instead: Use a secure element or the MCU's protected storage, and plan certificate revocation.

Questions engineers ask

Is MQTT secure?

MQTT has no encryption of its own. It becomes secure when you add TLS, client authentication and topic permissions. Even then, the broker can read every message, so sensitive data also needs application-layer encryption.

What port does secure MQTT use?

Port 8883 is registered with IANA for MQTT over TLS. Port 1883 is for unencrypted MQTT and should not be open to the internet.

Does MQTT over TLS give end-to-end encryption?

No. TLS protects each connection between a client and the broker. The broker decrypts the message to route it, so the content is readable on the broker and on anything that processes it after that.

How much memory does end-to-end encryption need on a microcontroller?

It depends on the library and the crypto hardware. The Microchip Connectivity Framework, for example, needs 20 to 30 kB of flash and runs on 8-, 16- and 32-bit MCUs.

What are the main security weaknesses of MQTT?

The protocol leaves encryption and access control to the deployment, so a broker with anonymous access or an open port 1883 is easy to abuse. Topic names can also leak information. In a well-secured system the remaining gap is that the broker and any relaying app can read every message.

Who implements the Microchip Connectivity Framework?

MCF is a Microchip technology. Indeema implements it on devices, from firmware ports to key storage in a secure element, and runs MCF cloud instances as shared, dedicated or on-premise deployments.

Was this useful?

Where this shows up in our work

ExpertiseEmbedded and firmware engineeringNeed end-to-end encryption on a device that already ships, or on a new design?

Apply this to your product

Review your device security approach

Review your device security approach

Sources