Repository navigation
fix: enforce MQTT 5 Receive Maximum for inbound QoS 2 messages (GHSA-h8jm-hm87-fqw3) - #2065
Merged
Merged
Conversation
robertsLando
force-pushed
the
fix/ghsa-h8jm-receive-max
branch
from
September 16, 2026 09:03
46faf82 to
c8f2bc2
Compare
robertsLando
force-pushed
the
fix/ghsa-h8jm-receive-max
branch
from
September 16, 2026 09:05
c8f2bc2 to
b016f23
Compare
robertsLando
force-pushed
the
fix/ghsa-h8jm-receive-max
branch
from
September 16, 2026 09:08
b016f23 to
966b766
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2065 +/- ##
==========================================
+ Coverage 85.18% 85.54% +0.35%
==========================================
Files 26 26
Lines 1715 1757 +42
Branches 395 407 +12
==========================================
+ Hits 1461 1503 +42
Misses 220 220
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
robertsLando
force-pushed
the
fix/ghsa-h8jm-receive-max
branch
from
September 16, 2026 09:09
966b766 to
e64ae57
Compare
…h8jm-hm87-fqw3) The client advertised a Receive Maximum and then ignored it on the way in: a broker could send unlimited QoS 2 PUBLISH packets with distinct message ids, never send PUBREL, and grow the incoming store without bound. Reconnecting did not help, because a resumed session keeps its store. Inbound QoS 2 message ids are now tracked against the advertised quota, and a broker that exceeds it is disconnected with 0x93. A redelivery of a message already held takes no second slot, so DUP still works, and the PUBREL handler answers a re-sent PUBREL whether or not the store still has the entry. The quota is also advertised as the value actually enforced: they differ when the option failed validation, and a rejected receiveMaximum: 0 on the wire is itself a protocol error (3.2.2.3.3) the broker would blame us for. Slots are kept across a reconnect on purpose. They are the bound on the incoming store, which is session state: releasing them per connection would let a broker reset the quota by dropping the TCP connection and grow the store across reconnects, which is the vulnerability itself.
robertsLando
force-pushed
the
fix/ghsa-h8jm-receive-max
branch
from
September 16, 2026 09:10
e64ae57 to
225f420
Compare
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes GHSA-h8jm-hm87-fqw3 (low). The client advertised a Receive Maximum and then ignored it on inbound QoS 2: a broker could grow the client's incoming store without bound. Reconnecting did not clear it, because a resumed session keeps its store.
The trigger and the full analysis are in the advisory and stay there until it publishes.
Last of six; stacked on #2064 (and #2063, #2062, #2061, #2060 beneath it).
Fix
src/lib/client.ts,src/lib/handlers/publish.ts,src/lib/handlers/pubrel.ts.0x93(Receive Maximum exceeded), which §3.3.4 [MQTT-3.3.4-9] is exactly the code for.receiveMaximum: 0on the wire is itself a protocol error (§3.2.2.3.3) the broker would blame us for.receiveMaximumoption is validated and latched at construction, so a caller mutatingoptionsmid-session cannot disable the check, and a non-number cannot silently defeat it (every comparison againstNaNis false).On slot lifetime
Slots are deliberately kept across a reconnect. §4.9 describes the flow-control quota as re-initialized per network connection, and read literally that would mean releasing them. They are not released here, because these slots are the bound on the incoming store, which is session state: releasing them per connection lets a broker reset the quota by dropping the TCP connection and grow the store across reconnects — the vulnerability itself.
The trade-off is that a broker which resumes a session, leaves earlier QoS 2 exchanges unfinished, and then fills the connection to
receiveMaximumcan be disconnected. That requires the broker to leave exchanges unresolved, and the store bound is the property worth keeping. Splitting the two limits — per-connection flow control for the0x93decision, a separate store cap refusing the excess withPUBREC0x97— is a possible follow-up, deliberately not done in a security fix.Consumer-visible changes
receiveMaximumon inbound QoS 2 now gets disconnected instead of being allowed to grow the store. Reconnect behaviour is unchanged.properties.receiveMaximumoutside 1..65535, or not an integer, is ignored with a log line and 65535 is enforced and advertised instead.Verification
Full node suite on this branch: 1030 tests, 1025 pass, 0 fail, 5 skipped. Typecheck, lint and build clean.
With all six merged, the tree is byte-identical to the integration branch the whole set was tested on.