question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] DoS Possibility if Client ID is known (Security)

See original GitHub issue

System Information

  • Aedes: git pulled from master
  • NodeJS: 14.15.5
  • OS: Arch Linux
  • Arch: x86_64

Describe the bug Given that the $SYS topics are not read-only, an attacker can perform a Denial-of-Service attack on a client connected to aedes.

To Reproduce

  1. Run the AEDES MQTT broker with default configs.
  2. Listen to the $SYS/aedes-cli/new/clients topic to check for announcements of new clients. Let’s consider the attacker “captures” the ID X of a client connecting to the broker
  3. (as per the above step) Subscribe to a /test topic using an mqtt client so that we can see the ID being announced as a new client
  4. Publish a message to $SYS/aedes-cli-but-nope/new/clients with a payload of the captured client ID X.

Expected behavior The message published in $SYS is ignored since the topic is read-only for clients.

Actual Behaviour The client with ID X is disconnected by the aedes broker. Relevant code: https://github.com/moscajs/aedes/blob/c390099c27820cf81c97f4e9df9123cf9d558615/aedes.js#L150

Since the serverId will be different from the broker’s own ID, the broker will close the connection.

In my tests using mqtt node library to subscribe to topics and publish messages, the client that was under attack would repeatedly try to reconnect. However, if we repeatedly publish the DoS messages with a small delay, the client is stuck always attempting to reconnect and will not receive messages to their subscribed topics. Example script:

while true; do sleep 0.5; mqtt_pub -h localhost -t '$SYS/aedes-cli-but-nope/new/clients' 'mqttjs_4b829ced'; done

In which mqttjs_4b829ced is the ID X we have “stolen” above.

Additional context Screenshot that shows this happening:

image

A cleaned up snippet of an iteration of this attack:

------CLIENT INIT, client connected------
Client mqttjs_d8d76c44 CONNECTED, broker aedes-cli
Client BROKER_aedes-cli PUBLISH mqttjs_d8d76c44 on $SYS/aedes-cli/new/clients, broker aedes-cli
CONNACK sent to mqttjs_d8d76c44, broker aedes-cli
Client mqttjs_d8d76c44 READY, broker aedes-cli
Client mqttjs_e431dff2 DISCONNECTED, broker aedes-cli
Client BROKER_aedes-cli PUBLISH mqttjs_e431dff2 on $SYS/aedes-cli/disconnect/clients, broker aedes-cli
Client mqttjs_d8d76c44 PUBLISH mqttjs_e431dff2 on $SYS/aedes-cli-but-nope/new/clients, broker aedes-cli
Client mqttjs_e431dff2 UNSUBSCRIBED to: , broker aedes-cli
Client BROKER_aedes-cli PUBLISH {"clientId":"mqttjs_e431dff2","subs":["/test"]} on $SYS/aedes-cli/new/unsubscribes, broker aedes-cli
Client mqttjs_d8d76c44 DISCONNECTED, broker aedes-cli
Client BROKER_aedes-cli PUBLISH mqttjs_d8d76c44 on $SYS/aedes-cli/disconnect/clients, broker aedes-cli
------CLIENT INIT, client connected------
Client mqttjs_e431dff2 CONNECTED, broker aedes-cli
Client BROKER_aedes-cli PUBLISH mqttjs_e431dff2 on $SYS/aedes-cli/new/clients, broker aedes-cli
CONNACK sent to mqttjs_e431dff2, broker aedes-cli
Client mqttjs_e431dff2 READY, broker aedes-cli
Client mqttjs_e431dff2 SUBSCRIBED to: /test, broker aedes-cli
Client BROKER_aedes-cli PUBLISH {"clientId":"mqttjs_e431dff2","subs":[{"topic":"/test","qos":0}]} on $SYS/aedes-cli/new/subscribes, broker aedes-cli

For this run, mqttjs_e431dff2 was the ID of the attacked client, and mqttjs_d8d76c44 is the ID of the attacker.

We can see that the attacker connects and receives a CONNACK. It is considered READY, and meanwhile the attacked client is DISCONNECTED (probably out of order logging here) due to the PUBLISH done by the attacker (that appears in the following lines). The client later on reconnects just fine, but if this publishing is repeated (as mentioned above) the attacked client will be unable to receive the subscribed messages due to being almost constantly offline.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mcollinacommented, Mar 20, 2021

@mcollina I’m sorry, the issue can be deleted if you prefer this to be discussed privately. I believe admins can do this. Otherwise I can edit the issue description and delete the previous revision.

No worries. Despite your claims, this is not a security vulnerability.

0reactions
robertsLandocommented, Apr 21, 2021

Just submitted a fix for this #622

Read more comments on GitHub >

github_iconTop Results From Across the Web

Securing Against Denial of Service Attacks - W3C
Denial of Service (DoS) is an attack designed to render a computer or network incapable of providing normal services. The most common DoS...
Read more >
Denial-of-service attack - Wikipedia
A DoS or DDoS attack is analogous to a group of people crowding the entry door of a shop, making it hard for...
Read more >
A Client Bootstrapping Protocol for DoS Attack Mitigation on ...
Hiding the addresses of proxy servers aims to lower the likelihood that a proxy server becomes the victim of a denial-of-service (DoS) attack....
Read more >
Understanding Denial-of-Service Attacks | CISA - US-CERT
A denial-of-service (DoS) attack occurs when legitimate users are unable to access information systems, devices, or other network resources ...
Read more >
Bug Pattern: PREDICTABLE_RANDOM - Find Security Bugs
a CSRF token: a predictable token can lead to a CSRF attack as an attacker will know the value of the token; a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found