fix: ACL bypass and # wildcard zero-children in MatchTopic - #170
Merged
Merged
Conversation
MatchTopic returned true unconditionally after exhausting filter parts, without checking whether topic parts remained. A literal filter 'allowed' matched publish to 'allowed/secret'. Fix: return elements, len(topicParts) == len(filterParts). The '#' multi-level wildcard path returns early, unaffected. Reported by Team Atlanta.
Per MQTT 4.7 spec, the '#' multi-level wildcard must match zero or more sublevels.
The bounds check returned false before checking if the filter part was '#'.
Fix: matched = filterParts[i] == '#', only allow zero-children on '#'.
Regular filters and '+' wildcard still require exact level count.
Test: MatchTopic('a/#', 'a') -> true, MatchTopic('a/+', 'a') -> false.
Updated TestCanACL expectation: topic 'updates' is now correctly denied
for read because global rule 'updates/#' (WriteOnly) matches 'updates'
with the zero-children fix.
wind-c
force-pushed
the
fix/acl-prefix-topic-bypass
branch
from
July 12, 2026 07:12
3744ca3 to
58e7e95
Compare
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.
#170 - MatchTopic fixes
Fix 1: ACL bypass via prefix topic matching (CVSS 4.3)
Reported by Team Atlanta. MatchTopic returned true unconditionally after exhausting filter parts, without checking whether topic parts remain. A literal filter "allowed" matched publish to "allowed/secret".
Fix: return len(topicParts) == len(filterParts)
Fix 2: # wildcard zero-children matching
Per MQTT 4.7 spec, # must match zero or more child levels. The bounds check returned false before checking if filter part was #, so a/# failed to match a.
Fix: matched = filterParts[i] == "#"
Changes
mqtt/hooks/auth/ledger.go 2+
mqtt/hooks/auth/ledger_test.go 16+
Reported by Team Atlanta.