Skip to content

fix(dns): reject compression pointers that target the fixed header - #2372

Closed
hakarrr wants to merge 2 commits into
fortra:masterfrom
hakarrr:patch-1
Closed

hakarrr wants to merge 2 commits into
fortra:masterfrom
hakarrr:patch-1

Conversation

@hakarrr

@hakarrr hakarrr commented Nov 13, 2026 •

Copy link
Copy Markdown

Fixes #2371.

DNS.parseCompressedMessage converts RFC 1035 4.1.4 compression pointers to body-relative offsets without validating the result. Pointers into the fixed 12-byte header produced a negative offset that Python negative indexing wrapped to the end of the buffer, silently parsing unrelated tail bytes as a name - no exception. Verified pre-fix on master @ 5648c37:

  • parseCompressedMessage(b"\xc0\x00" + tail) returns (2, '') (empty name)
  • parseCompressedMessage(b"\xc0\x07" + tail) returns (2, b'ab') (wrong name)
  • a full packet with a qname pointer to absolute offset 0 parses as an empty question name

The fix rejects negative body-relative pointer offsets with a clear Invalid DNS compression pointer exception. Pointers past the end of the buffer were already rejected by the existing bounds check; cyclic pointers are already rejected by d96cef1. This closes only the header-bounds gap.

Tests:

  • 2 new regression tests in tests/misc/test_dns.py (3 pointer subtests with the exact pre-fix outputs above + 1 packet-level test through get_questions()). On master they fail with no exception raised (silent wrong names); with the fix they pass.
  • Local suites with the fix: tests/misc/test_dns.py 4 passed + 3 subtests; tests/ImpactPacket + tests/dot11 + tests/misc 666 passed, 1 skipped.
  • tests/dcerpc + tests/SMB_RPC could not be validated in this environment (they need a target AD and dcetests.cfg); their failing test IDs were identical before and after this change (1461 both runs, diff empty).

hakarrr and others added 2 commits November 13, 2026 14:20
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Author

Could a maintainer review this DNS compression-pointer validation fix? Please let me know if the fixed-header boundary handling needs changing or if additional malformed-packet cases are needed. Thanks.

@hakarrr

hakarrr commented Nov 16, 2026

Copy link
Copy Markdown
Author

Gentle follow-up: could a maintainer share whether this is still of interest and what the path to review looks like? Happy to make changes as needed.

@hakarrr hakarrr closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DNS parser silently misparses compression pointers that point into the message header

1 participant