Skip to content

Reject embedded NUL in SimpleXMLElement path/URL constructor - #23069

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/sxe-ctor-nul-path
Open

Reject embedded NUL in SimpleXMLElement path/URL constructor#23069
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/sxe-ctor-nul-path

Conversation

@iliaal

Copy link
Copy Markdown
Contributor

With dataIsURL set, SimpleXMLElement::__construct hands its first argument to xmlReadFile as a C string, so new SimpleXMLElement("/tmp/ok.xml\0anything", 0, true) quietly loads /tmp/ok.xml. simplexml_load_file already rejects this because its filename parameter is declared as a path; the constructor takes a plain string and never runs the check. The constructor now throws the same ValueError before reaching xmlReadFile.

When dataIsURL is true, __construct parsed the path as a plain string
and passed it to xmlReadFile, so an embedded NUL truncated the path.
simplexml_load_file already rejects NULs via the path parameter type.
Match that check before xmlReadFile.
ClosesphpGH-23069
@devnexen

Copy link
Copy Markdown
Member

should target master (thus no more CHECK_NULL_PATH)

Sign up for freeto 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.

2 participants

@iliaal@devnexen