Skip to content

fix: bound compression-pointer hops in DNS name parsing (#3490) - #3499

Merged
pjfanning merged 1 commit into
apache:1.7.xfrom
pjfanning:dns-1.7
Aug 31, 2026
Merged

fix: bound compression-pointer hops in DNS name parsing (#3490)#3499
pjfanning merged 1 commit into
apache:1.7.xfrom
pjfanning:dns-1.7

Conversation

@pjfanning

Copy link
Copy Markdown
Member

cherry pick 8391a22 #3490

Motivation:
DomainName.parse followed RFC 1035 compression pointers by recursing with
no hop limit and no check that the pointer moves backwards. A response whose
pointers form a cycle recursed until StackOverflowError, which is fatal and
escapes actor supervision. Message.parse runs on every datagram before the
transaction-id check, so any packet delivered to the resolver socket could
trigger it.

Modification:
Parse iteratively over a swappable iterator, cap the number of pointers
followed at 16 (a 255-octet name cannot legitimately need more), reject the
reserved 0x40/0x80 label types instead of reading them as negative lengths,
and reject names over 255 characters. Add DomainNameSpec.

Result:
Malformed or cyclic names fail with IllegalArgumentException, which actor
supervision handles, instead of overflowing the stack.

Tests:
- sbt "actor-tests/testOnly org.apache.pekko.io.dns.internal.DomainNameSpec org.apache.pekko.io.dns.internal.MessageSpec org.apache.pekko.io.dns.internal.DnsClientSpec" - 14 passed
- sbt actor/scalafmt actor-tests/Test/scalafmt, actor-tests/Test/headerCreate

References:
None - found while reviewing the draft threat model in apache#3478
@pjfanning pjfanning added this to the 1.7.1 milestone Aug 31, 2026
@pjfanning
pjfanning merged commit 5855c78 into apache:1.7.x Aug 31, 2026
10 checks passed
@pjfanning
pjfanning deleted the dns-1.7 branch August 31, 2026 11:33
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.

2 participants