Repository navigation
fix(gateway): eliminate ReDoS ambiguity in _WHO4_QUERY_RE (CodeQL #8) - #891
Merged
GreenGrassBlueOcean merged 1 commit intoNov 10, 2026
Merged
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
What is the problem
GitHub Advanced Security / CodeQL posted Review
#5847970625(Code Scanning Alert#8, rulepy/redos/ CWE-1333) oncustom_components/myhome/gateway_sessions.py:529(introduced in #887 for Issue #886):In$2^{k-1}$ ways, causing exponential backtracking.
(?P<where>[^#*]+(?:#[^*]+)*), the repeated inner group(?:#[^*]+)*uses[^*]+, which matches#as well as non-#characters. On malformed strings starting with*#4*<zone>#followed by repeated#...segments without a trailing##, the regex engine can partition the#-delimited segments between a single[^*]+run and multiple(?:#[^*]+)repetitions inWhat is the solution
#-separated segments disjoint in_WHO4_QUERY_RE(custom_components/myhome/gateway_sessions.py):(?:#[^*]+)*to(?:#[^#*]+)*:[^#*]+cannot consume#or*, every#inside<where>deterministically starts a new(?:#[^#*]+)segment and can never consume the trailing##terminator, eliminating all backtracking ambiguity while matching the exact same set of valid OpenWebNetWHO=4WHEREtokens (1..99,Z#N,Z#4#II).tests/test_issue_886_myhomeserver1_41_zones.py):_mismatched_who4_reply_zonesmatches multi-segmentWHEREqueries (*#4*60#4#01*60##) and rejects pathological multi-#strings ("*#4*1" + "#a" * 40 + "!") in linear time.State Diagram
N/A (deterministic regex character-class tightening; no state machine changes)
Hardware Verification
N/A (verified against the existing 41-zone
MyHomeServer13.87.13trace suite intests/test_issue_886_myhomeserver1_41_zones.py)How is it tested
tests/test_issue_886_myhomeserver1_41_zones.py,tests/test_gateway_sessions.py:88 passed in 7.82sruff check custom_components tests scripts:All checks passed!python scripts/verify_ha_standards.py:SUCCESS: All Home Assistant architectural standards passed!python scripts/sync_documentation.py --check:SUCCESS: All documentation is calibrated and in sync with the codebase!Where are the traces
tests/fixtures/traces/issue_886/myhome_trace_MyHomeServer1_41_zones_2026-11-09.json(2,428frames)What does the Firmware Oracle / Encyclopedia say
Queried via
openwebnet-mcp(lookup_frame_syntax(who=4, frame_type="STATUS_REQUEST")):STATUS_REQUEST/DIMENSION_REQUESTWHEREparameters are#-separated non-empty tokens ((?P<where>#?\d+)(?P<where_param>(?:#\d+)*)), and##is reserved exclusively as the frame delimiter. Excluding#inside each segment ((?:#[^#*]+)*) is 100% aligned with the OpenWebNet frame grammar.Checklist
What is the problem,What is the solution,State Diagram,How is it tested,Where are the traces,What does the Firmware Oracle / Encyclopedia say).handle_event()and do not manually subscribe viaasync_dispatcher_connect.pytest,ruff, andscripts/verify_ha_standards.pypass.