Skip to content

[Standard] Bound-check RR parsing in dns_get_mx() answer loop - #295

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/dns-getmx-checkcp-84
Open

[Standard] Bound-check RR parsing in dns_get_mx() answer loop#295
iliaal wants to merge 1 commit into
PHP-8.4from
fix/dns-getmx-checkcp-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

dns_get_mx()'s answer loop read type/class/ttl/rdlength and weight via raw GETSHORT() after unvalidated dn_skipname() advances, so a reply whose last record name ends at the buffer end overran the 64K querybuf stack union by up to about 12 bytes. Checks mirroring php_parserr()'s CHECKCP(10)/CHECKCP(2) now guard those reads; rdata skips stay bounded by cp < end and dn_skipname()'s eom check. A sibling audit found every remaining GETSHORT()/dn_expand() walk inside guarded php_parserr(). No phpt ships since a red test would need an LD_PRELOAD resolver mock serving a truncated hostile reply.

The dns_get_mx() answer loop parsed records with raw GETSHORT() after
unvalidated dn_skipname() advances, so a reply whose last record name ends
exactly at end of buffer made the type/class/ttl/rdlength and weight reads
run up to ~12 bytes past the 64K querybuf stack union. Guard the fixed-size
header fields the same way php_parserr() does with CHECKCP(10)/CHECKCP(2);
rdata skips remain bounded by the cp < end loop condition and dn_skipname()'s
own eom check. Sibling audit: every other GETSHORT()/dn_expand() walk lives
inside php_parserr(), which is already CHECKCP-guarded on all paths.
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.

1 participant