fix: bound compression-pointer hops in DNS name parsing (#3490) - #3499
Merged
Conversation
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
samueleresca
approved these changes
Aug 31, 2026
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.
cherry pick 8391a22 #3490