Skip to content

ext/standard: Bound-check RR parsing in the dns_get_mx() answer loop - #23798

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

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

Conversation

@iliaal

@iliaal iliaal commented Sep 20, 2026

Copy link
Copy Markdown
Member

dns_get_mx() reads type, class, ttl, rdlength and weight with raw GETSHORT() after an unvalidated dn_skipname() advance. A reply whose last record name ends at the end of the received data walks up to about 12 bytes past the 64K querybuf stack union, and the weight is handed to userland through the $weights array. php_parserr() already guards the equivalent reads with CHECKCP(10)/CHECKCP(2) and this mirrors it; rdata skips stay bounded by the cp < end loop condition. No test ships because a red one needs an LD_PRELOAD resolver mock serving a truncated reply.

The answer loop read type, class, ttl, rdlength and weight with raw
GETSHORT() after an unvalidated dn_skipname() advance, so a reply whose
last record name ends at the end of the received data read up to about 12
bytes past the 64K querybuf stack union, with the weight reaching userland
through the $weights array. Guard the fixed-size header fields the way
php_parserr() already does; rdata skips stay bounded by the cp < end loop
condition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant