Skip to main content
IoT Networking Protocols: MQTT, CoAP & BLE Security
Lesson 3 of 9

IoT Networking Protocols: MQTT, CoAP & BLE Security

Analyse MQTT, CoAP, and Bluetooth Low Energy traffic in lab captures, detect unauthenticated brokers and weak topic ACLs, and configure transport and pairing protections.

Intermediate 26 min IoT & embedded
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Compare MQTT, CoAP, and Bluetooth Low Energy (BLE) by transport, ports, and security model
  • Subscribe to and inspect MQTT topics in an authorised lab using mosquitto_sub and Wireshark
  • Identify common misconfigurations such as anonymous brokers, wildcard ACL gaps, and BLE Just Works pairing
  • Configure TLS/DTLS, per-client topic ACLs, and authenticated BLE pairing to secure IoT traffic

Recommended first: IoT Architecture, Embedded Linux & Microcontroller BasicsHardware Interfaces & Logic Captures: UART, SPI, I2C & JTAG

#Why this matters

Embedded devices often lack the memory, CPU headroom, and battery budget for full HTTP/2 APIs. Instead, IoT ecosystems rely on lightweight protocols: MQTT for message brokering, CoAP for UDP-based telemetry, and Bluetooth Low Energy (BLE) for local setup and control.

When engineers skip transport encryption or access control on these protocols, anyone on the local network or within radio range can passively sniff sensor readings or inject unauthorized actuator commands.

#Protocol comparison: MQTT, CoAP, and BLE

Protocol Transport / Medium Communication model Default ports Standard security
MQTT TCP Publish / Subscribe via broker 1883 (plain), 8883 (TLS) TLS + client auth + topic ACLs
CoAP UDP Request / Response (GET, POST, PUT, DELETE) 5683 (plain), 5684 (DTLS) DTLS (or OSCORE)
BLE 2.4 GHz radio GAP advertising + GATT services Link-layer channels LE Secure Connections + GATT permissions

#MQTT publish-subscribe and broker flaws

In MQTT, clients do not talk directly to one another. Every device opens a TCP connection (CONNECT) to a central broker, subscribes (SUBSCRIBE) to hierarchical topics such as building/floor2/temp, and sends messages (PUBLISH).

MQTT supports two subscription wildcards:

  • + matches a single topic level (for example, devices/+/temp).
  • # matches all remaining topic levels (for example, # subscribes to every normal topic on the broker, and $SYS/# exposes broker health metrics if permitted).
Unauthenticated MQTT wildcard subscription in a labUnauthenticated MQTT wildcard subscription in a labTesterBrokerSensorCONNECT (no username/password)CONNACK (return code 0: Accepted)SUBSCRIBE topic="#"PUBLISH building/door/pin "4821"PUBLISH building/door/pin "4821"Missing auth and TLS expose all plaintext payloads

You can test an authorised lab broker using mosquitto_sub or inspect captured traffic in Wireshark with the mqtt display filter:

Subscribing to all topics on an unauthenticated lab broker
$ mosquitto_sub -h lab.local -p 1883 -t '#' -v
lab/sensor/temp {"c":21.8,"node":"sensor-04"}
lab/door/command unlock
$ tshark -r iot_capture.pcap -Y "mqtt.msgtype == 3" -T fields -e mqtt.topic -e mqtt.msg
lab/sensor/temp {"c":21.8,"node":"sensor-04"}
lab/door/command unlock

In tshark, mqtt.msgtype == 3 filters specifically for PUBLISH packets. When port 1883 is used without TLS, both topic names and payloads appear in plaintext across the wire. Even when authentication is enabled, weak topic ACLs often allow any authenticated sensor to subscribe to # or publish forged commands to another device's control topic.

#CoAP and BLE security essentials

#CoAP over UDP

CoAP (RFC 7252) brings REST verbs (GET, POST, PUT, DELETE) to UDP ports 5683 (plaintext) and 5684 (DTLS). Devices often advertise available endpoints at /.well-known/core and may answer multicast discovery requests on a local subnet.

Because UDP has no connection handshake, an internet-exposed CoAP server on port 5683 can leak internal resources and be abused for UDP reflection/amplification attacks if large responses follow tiny spoofed requests. Production deployments should restrict CoAP to internal segments or wrap it in DTLS (coaps://).

#Bluetooth Low Energy (BLE)

A BLE peripheral broadcasts its presence using GAP (Generic Access Profile) and structures data into GATT (Generic Attribute Profile) services and characteristics (read, write, notify). Three security flaws appear repeatedly in BLE assessments:

  • Unprotected GATT characteristics: Sensitive write characteristics (such as unlock or firmware update triggers) left writable without pairing or link encryption.
  • BLE Legacy Pairing: Older pairing modes exchange keys without Elliptic Curve Diffie-Hellman (ECDH), allowing passive eavesdroppers to recover the Short Term Key.
  • Just Works pairing: Even under LE Secure Connections, the Just Works association model provides zero Man-in-the-Middle (MITM) authentication because no passkey or numeric comparison occurs.

#Defending IoT protocols and common mistakes

Common configuration mistakes:

  • Enabling TLS without certificate verification: Firmware that skips CA or hostname checks on port 8883 or 5684 still falls to active interception.
  • Sharing one credential across all devices: If one node's flash is dumped (as covered in earlier lessons), an attacker can impersonate the entire fleet.
  • Permitting wildcard subscriptions for regular clients: Only dedicated backend services should subscribe across multiple devices; individual sensors should never read # or $SYS/#.
  • Relying on BLE Just Works for physical locks: Without Passkey Entry or Numeric Comparison, an attacker within radio range can intercept pairing.

Hardening checklist:

  • Require TLS 1.2/1.3 (8883) for MQTT and DTLS (5684) for CoAP, validating server certificates against a pinned or trusted CA.
  • Disable anonymous logins (allow_anonymous false in Mosquitto) and enforce least-privilege topic ACLs per client identity.
  • On BLE devices, mandate LE Secure Connections with MITM-protected pairing and set GATT permissions to require an encrypted, authenticated link before reading or writing sensitive characteristics.

#Summary

MQTT, CoAP, and BLE keep IoT communication lightweight, but their default unencrypted modes expose telemetry and control paths when misconfigured. Inspecting traffic with Wireshark, tshark, and mosquitto_sub quickly reveals anonymous brokers, wildcard topic leaks, and unencrypted CoAP endpoints. Securing production IoT networks requires TLS or DTLS with proper certificate checks, per-device credentials with strict topic ACLs, and MITM-protected BLE pairing.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge