Skip to content

DNS outbound: Keep hijacked A/AAAA replies within the buffer - #7225

Merged
RPRX merged 3 commits into
XTLS:mainfrom
Shilmoon:fix/dns-reply-cap
Oct 29, 2026
Merged

RPRX merged 3 commits into
XTLS:mainfrom
Shilmoon:fix/dns-reply-cap

Conversation

@Shilmoon

Copy link
Copy Markdown
Contributor

handleIPQuery builds the A/AAAA reply into an 8 KB buffer but doesn't limit the answer count. When a lookup returns more addresses than fit (about 495 A or 282 AAAA), the builder grows into a new slice and b.Resize panics, which stops the process. UDP, TCP and QUIC name servers can't return that much; DoH and localhost can.

Fix: keep at most 256 answers. The worst case (AAAA, longest name) is 7439 bytes.

Test: TestHandleIPQueryManyIPs fails on main with slice bounds out of range [:16271] with capacity 8192.

handleIPQuery builds the reply into an 8 KB buffer. A lookup with more
addresses than fit made the builder grow into a new slice, and the
following Resize panicked, which stops the process. Keep at most 256
answers, which fit even with the longest name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Meo597 Meo597 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although no such panic reports have been received and I am skeptical about whether the trigger path exists in the real world, truncating the slice is fine.

Comment thread proxy/dns/dns_internal_test.go Resolved
Remove limit on the number of AAAA answers and add check for message size.
@therealtunge

Copy link
Copy Markdown

claude..., claude everywhere...

@RPRX
RPRX merged commit 5865e3a into XTLS:main Oct 29, 2026
black-raison-detre added a commit to black-raison-detre/Xray-core that referenced this pull request Nov 7, 2026
Backport upstream XTLS#7225, XTLS#7327, XTLS#7236, and XTLS#7291 onto the
v26.7.11 maintenance branch with focused regression coverage.

Co-authored-by: Codex <[email protected]>
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.

5 participants