#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).
You can test an authorised lab broker using mosquitto_sub or inspect captured traffic in Wireshark with the mqtt display filter:
$ 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 unlockIn 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
unlockor 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
8883or5684still 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 falsein 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.