
Proof-of-concept and lab for CVE-2026-104199: a malformed aMQTT '+' wildcard filter triggers catastrophic regex backtracking, freezing the broker. Includes differential 0.11.3 vs 0.11.4 testing.
| CVE | CVE-2026-104199 |
| Component | aMQTT — amqtt/broker.py (add_subscription validation, _matches) |
| Affected | 0.11.0 through 0.11.3 |
| Fixed in | 0.11.4 — commit e48a8a6 (GHSA-2hjf-7455-w946) |
| CWE | CWE-1333 (Inefficient Regular Expression Complexity), CWE-400 (Uncontrolled Resource Consumption), CWE-20 (Improper Input Validation) |
| Impact | A single anonymous client sends one crafted SUBSCRIBE and one PUBLISH; catastrophic backtracking in the topic matcher holds the GIL inside the broker's broadcast loop and freezes the entire process — no CONNACK, no delivery, no keepalive — until restart |
| Vector | Network — MQTT SUBSCRIBE + PUBLISH, anonymous under the default configuration |
| Trigger | SUBSCRIBE "+/" + "+"*60, then PUBLISH "/" + "a"*18 + "/" |
The vulnerable matcher built a regular expression from the subscription
filter, turning every + into a greedy [^/]* fragment:
# v0.11.3, broker.py _matches()
self._topic_filter_matchers[a_filter] = re.compile(
re.escape(a_filter).replace("\\#", "?.*").replace("\\+", "[^/]*").lstrip("?"))
return bool(match_pattern.fullmatch(topic))
The fix validates each level and matches deterministically in O(n):
# v0.11.4 (commit e48a8a6) — per-level validation rejects malformed '+'/'#'
# and _matches() walks '/'-delimited levels instead of using a regex.
Two defects chain into a single-packet broker freeze:
add_subscription() checked the
single-level wildcard + with substring tests ("/+" in filter,
"+/" in filter) instead of requiring every /-delimited level that
contains + to be exactly +. The malformed filter "+/" + "+"*60
contains both substrings, so it was accepted (SUBACK 0x00) rather than
rejected with 0x80 as MQTT-4.7.1-3 requires._matches() replaced each + with the greedy
fragment [^/]*. Sixty adjacent + characters become sixty adjacent
[^/]* groups with no separator between them. Matching a topic that
partially matches but ultimately fails (e.g. "/" + "a"*18 + "/") forces
the engine to explore exponentially many ways to partition the characters
among the groups. re.fullmatch() runs in C while holding the GIL, so the
catastrophic backtracking blocks the asyncio event loop — and every other
thread — freezing the whole broker until the process is restarted.The fix validates filters one level at a time (any level containing + must
be exactly +; # must be a whole, final level) and replaces the regex with
a deterministic level-by-level walk.
| service | image | role |
|---|---|---|
amqtt2-vuln | cve-2026-104199:vuln | real amqtt 0.11.3 broker (PyPI) |
amqtt2-fixed | cve-2026-104199:fixed | real amqtt 0.11.4 broker (vendor fix) |
poc | cve-2026-104199-poc:local | stdlib-only Python driver |
Both run the real amqtt.broker.Broker with the default configuration
(TCP 0.0.0.0:1883, anonymous allowed). A thin supervisor exposes /info and
/stats on :8080. Both sides differ only in the amqtt version. Because the
vulnerable broker stays frozen after the attack, the driver restarts the
target container before each mode.
./run-lab.sh build # installs amqtt 0.11.3 / 0.11.4 from PyPI
./run-lab.sh up # cve104199lab network: amqtt2-vuln / amqtt2-fixed
./run-lab.sh sweep # restarts each target before every mode
./run-lab.sh down
poc/poc.py (stdlib only, raw MQTT 3.1.1 packets). One connection sends the
crafted SUBSCRIBE and PUBLISH; responsiveness is then probed with a fresh
CONNECT (a frozen broker completes the TCP handshake from the kernel backlog
but never sends CONNACK):
0x00) and the
broker freezes, 0 when rejected (0x80) and responsive; 3 no worker,
2 unreachable/indeterminate.+/+++..., valid sport/+, valid
# (valid wildcards must still be granted on the fixed build).e48a8a6, plus the interim
topic-filtering plugin workaround.A standalone full-chain exploit ships at exploit/exploit.py:
python3 exploit/exploit.py --host=amqtt2-vuln
# exit 1 on confirmed broker freeze, 0 on a safe target
| observation | amqtt2-vuln (0.11.3) | amqtt2-fixed (0.11.4) |
|---|---|---|
| SUBSCRIBE malformed filter | SUBACK 0x00 (accepted) | SUBACK 0x80 (rejected) |
| broker after one PUBLISH | frozen — no CONNACK | responsive |
valid sport/+ / # | granted | granted (0x00), responsive |
Captured runs: evidence/check-*-run.txt, evidence/exploit-*-run.txt,
evidence/probe-*-run.txt, evidence/mitigation-*-run.txt,
evidence/exploit-standalone-run.txt, evidence/exploit-standalone-fixed-run.txt,
evidence/versions.txt, evidence/0day-sweep.txt.
cve104199lab
network.The fixed line rejects the malformed + filter at subscription time
(0x80) and matches topics with a deterministic O(n) level walk, so no
backtracking regex remains. Valid wildcard filters (sport/+, #) are
still granted and match normally — no functional regression and no ReDoS
path.
README.md this write-up
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/lab.Dockerfile installs both upstream PyPI releases
lab/service.py real Broker + /info, /stats supervisor
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)