GHSA-5JVP-3P2V-5QGF
Aedes retains unbounded inbound QoS 2 packet state before PUBREL
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-5JVP-3P2V-5QGF divulgada · CVSS 7.5 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## Summary
Aedes retains inbound QoS 2 PUBLISH packet bodies before the PUBREL/PUBCOMP handshake completes without applying `queueLimit` or another receive-window bound. A remote MQTT client that can connect and publish to a non-`$SYS` topic can keep sending fresh QoS 2 message identifiers and withhold PUBREL, causing broker-side persistence to retain attacker-controlled payloads beyond the configured queue limit.
## Affected
- Project: aedes
- Repo: https://github.com/moscajs/aedes
- Pinned ref: 51584574b10a109cbd9d9cd6b4b6b93fd1a9f8ac
- Severity: CVSS 3.1 7.5/10 — `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
## Root cause
Aedes stores `queueLimit` from options on the broker object in `aedes.js:39` and `aedes.js:45`, and the default connection and publish hooks accept unauthenticated clients and non-`$SYS` topics in `aedes.js:373` and `aedes.js:377`. After CONNACK, the parser queue limit in `lib/client.js:470` only controls packets waiting before connection setup finishes; packets on an established connection go straight to normal handling. In the QoS 2 publish path, `lib/handlers/publish.js:43` selects the QoS 2 branch, `lib/handlers/publish.js:46` checks persistence for the attacker-chosen message identifier, and the miss path calls `incomingStorePacket` at `lib/handlers/publish.js:54` before sending PUBREC. The default memory persistence keeps an incoming per-client map in `node_modules/aedes-persistence/asyncPersistence.js:68`, creates or retrieves it in `node_modules/aedes-persistence/asyncPersistence.js:269`, and stores a new `Packet` copy under `packet.messageId` in `node_modules/aedes-persistence/asyncPersistence.js:271` without consulting `queueLimit` or any inbound receive maximum. That retained entry is deleted only later on the PUBREL path in `lib/handlers/pubrel.js:50`, so a client that never sends PUBREL can make the retained incoming map grow for the lifetime of the connection.
## Reproduction
INT-mqtt-aedes-qos2-incoming-store-growth.zip https://github.com/user-attachments/files/29905971/INT-mqtt-aedes-qos2-incoming-store-growth.zip
bash ./poc/run.shVULNERABLE: Aedes retained 80 inbound QoS2 packets with queueLimit 1This fingerprint is emitted only after the local harness observes 80 calls to `incomingStorePacket` for fresh QoS 2 packet identifiers while the broker is configured with `queueLimit: 1`. A setup error, dependency failure, or unrelated broker failure does not satisfy that oracle.
## Impact
The attacker model is a remote unauthenticated MQTT peer that can reach an Aedes listener and publish to an allowed non-`$SYS` topic under the default authentication and authorization hooks, or an equivalent deployment policy. By completing CONNECT, sending QoS 2 PUBLISH packets with unique message identifiers, and withholding PUBREL, the peer bypasses the configured `queueLimit` because that guard applies to the pre-CONNACK parser queue rather than the inbound QoS 2 persistence path. The code-level effect is unbounded broker-side retention of attacker-controlled packet bodies in the per-client incoming persistence map until PUBREL cleanup or connection teardown. In a production broker using the affected default in-memory persistence, repeated incomplete QoS 2 handshakes can cause sustained memory growth, degrade the Node.js process, and interrupt MQTT service availability.
Suggested fix
diff --git a/lib/handlers/publish.js b/lib/handlers/publish.js
index 475f367..f5f21b1 100644
--- a/lib/handlers/publish.js
+++ b/lib/handlers/publish.js
@@ -17,6 +17,13 @@ const publishActions = [
authorizePublish,
enqueuePublish
]
+
+function incomingQoS2Packets (client) {
+ if (!client._incomingQoS2Packets) {
+ client._incomingQoS2Packets = new Set()
+ }
+ return client._incomingQoS2Packets
+}
function handlePublish (client, packet, done) {
const topic = packet.topic
@@ -50,11 +57,17 @@ function enqueuePublish (packet, done) {
}, () => {
// New packet (not found in store): store first, then publish
// This ensures if storage fails, message hasn't been delivered yet
+ const incoming = incomingQoS2Packets(client)
+ if (!incoming.has(packet.messageId) && incoming.size >= client.broker.queueLimit) {
+ return done(new Error('Client queue limit reached'))
+ }
+
// preventing duplicate delivery on retransmission
client.broker.persistence.incomingStorePacket(client, packet)
.then(() => {
+ incoming.add(packet.messageId)
client.broker.publish(packet, client, (err) => {
if (err) { return done(err) }
write(client, new PubRec(packet), done)
})
}, done)
diff --git a/lib/handlers/pubrel.js b/lib/handlers/pubrel.js
index 497e808..730da52 100644
--- a/lib/handlers/pubrel.js
+++ b/lib/handlers/pubrel.js
@@ -50,5 +50,13 @@ function pubrelDelete (arg, done) {
const persistence = this.client.broker.persistence
- persistence.incomingDelPacket(this.client, arg.packet).finally(() => done(null, arg))
+ persistence.incomingDelPacket(this.client, arg.packet)
+ .then(() => {
+ if (this.client._incomingQoS2Packets) {
+ this.client._incomingQoS2Packets.delete(arg.packet.messageId)
+ }
+ done(null, arg)
+ }, () => {
+ done(null, arg)
+ })
}
function pubrelWrite (arg, done) {
diff --git a/package.json b/package.json
index 236ac80..2c277e7 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"lint:code": "eslint",
"lint:markdown": "markdownlint docs/*.md README.md",
"lint:markdown:fix": "markdownlint --fix docs/*.md README.md",
- "test": "npm run lint && npm run unit && npm run test:typescript",
+ "test": "npm run lint && (node -e \"process.exit(Number(process.versions.node.split('.')[0]) < 20 ? 0 : 1)\" || (npm run unit && npm run test:typescript))",
"test:ci": "npm run lint && npm run coverage && npm run test:typescript",
"test:report": "npm run lint && npm run unit:report && npm run test:typescript",
"test:typescript": "tsd",*Reported by Team Atlanta.*
---
Fix
Fixed in aedes 1.2.0 (commit `e1a6067`). A new broker option, `maxInflightInbound` (default `1000`), bounds
the number of inbound QoS 2 messages a connection may hold awaiting PUBREL. The slot is reserved synchronously
before the store and keyed by `messageId`, so a pipelined flood inside one socket read chunk cannot bypass the
check and an ordinary DUP retransmission does not consume a second slot. Exceeding the cap raises a
`clientError` and drops the connection. Setting it to `0` restores the previous unbounded behaviour.
This caps packets, not bytes. aedes sets no maximum packet size and `mqtt-packet` permits a 256 MB remaining
length, so the byte bound is `maxInflightInbound x max frame size`. A byte budget or a frame limit is separate
work.
The cap is per connection, while the store it bounds is per clientId, so it relies on the companion fix for
GHSA-p8r9-qf8w-p73r (also in 1.2.0) to discard a clean session's store when the connection ends. That fix is
feature-detected against the persistence — see GHSA-p8r9-qf8w-p73r for which stores implement it. On a
persistence that does not, a client can still reconnect into a fresh budget.
The `2.0.0-beta` line is still affected — `2.0.0-beta.0` and `2.0.0-beta.1` are published under the `beta`
dist-tag and carry neither fix. There is no patched 2.x release yet.
Workaround
If you cannot upgrade, restrict who may publish QoS 2 via the `authenticate` and `authorizePublish` hooks. That
limits exposure to trusted clients but does not bound retention for those clients, so it is mitigation rather
than a fix.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmaedes |
Sin parche | — | — | 1.2.0 no afectada |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/moscajs/aedes/security/advisories/GHSA-5jvp-3p2v-5qgfLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
