Skip to content

dns: reject compression pointers into the DNS header - #2396

Open
sudonishant wants to merge 1 commit into
fortra:masterfrom
sudonishant:fix-2371-dns-header-pointer
Open

sudonishant wants to merge 1 commit into
fortra:masterfrom
sudonishant:fix-2371-dns-header-pointer

Conversation

@sudonishant

@sudonishant sudonishant commented Nov 28, 2026 •

Copy link
Copy Markdown

Summary

DNS.parseCompressedMessage() (impacket/dns.py) converts RFC 1035 section 4.1.4 compression pointers (absolute message offsets) to body-relative offsets by subtracting self.__HEADER_BASE_SIZE (12). Previously, pointers with an offset < 12 produced a negative index that silently wrapped around via Python negative slicing and parsed trailing bytes as a domain name.

This change:

  • Rejects negative compression pointer targets (pointer < 0) with a clear Exception.
  • Guards offset < 0 or offset >= len(buf) at entry to parseCompressedMessage().

Closes #2371.

Validation

  • Added test_parse_compressed_message_rejects_header_pointers in tests/misc/test_dns.py.
  • Ran python3 -m pytest tests/misc/test_dns.py -v (3 passed, 4 subtests passed).
  • git diff --check passed.

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in review This issue or pull request is being analyzed

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

3 participants