amqtt is vulnerable to a remote denial of service caused by improper MQTT topic-filter validation combined with catastrophic regular-expression backtracking.
A single client can freeze the entire broker by sending one specially crafted SUBSCRIBE packet followed by one PUBLISH packet.
The vulnerability is caused by two defects:
add_subscription() validates the placement of the single-level wildcard + using substring checks for /+ and +/, rather than verifying that each /-delimited level containing + is exactly +. This allows malformed filters such as "+/" + "+" * 60 to be accepted instead of rejected with return code 0x80, as required by MQTT-4.7.1-3._matches() converts every + character into the greedy regular-expression fragment [^/]* and evaluates the resulting expression with re.fullmatch(). A filter containing many adjacent + characters can cause catastrophic backtracking when matched against a topic that partially matches but ultimately fails.Topic matching runs synchronously inside the broker’s global broadcast loop. When the malicious match is evaluated, it blocks the asyncio event loop and prevents the broker from processing any other work.
The issue was reproduced using a single raw MQTT 3.1.1 TCP connection with no third-party client dependencies.
Successful exploitation causes:
CONNACKUnder the default configuration, anonymous clients can exploit the vulnerability without credentials. When authentication is enabled, any authenticated client permitted to create arbitrary subscriptions and publish messages may still exploit it. Authentication alone is therefore not a sufficient mitigation.
pipamqtt>= 0.11.0, <= 0.11.3The vulnerable code is...
0.11.4Exploitability
AV:NAC:LAT:NPR:NUI:NVulnerable System
VC:NVI:NVA:HSubsequent System
SC:NSI:NSA:N8.7/CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:XInput Validation
Resource Management