Skip to content

Fix OSS-Fuzz #5674034779193344: Read of uninitialized memory in is_cacheable_stream_path() - #23830

Closed
ndossche wants to merge 1 commit into
php:PHP-8.4from
ndossche:fix-oss-fuzz-5674034779193344
Closed

ndossche wants to merge 1 commit into
php:PHP-8.4from
ndossche:fix-oss-fuzz-5674034779193344

Conversation

@ndossche

Copy link
Copy Markdown
Member

memcmp() will read inside the padding bytes of the zend_string, which are not initialized. This is not exploitable because they're 8 padding bytes and the length of "file://" and "phar://" is 7 so the mismatch happens at the length-of-the-string index; returning non-0 anyway.

…cheable_stream_path()

memcmp() will read inside the padding bytes of the zend_string, which
are not initialized. This is not exploitable because they're 8 padding
bytes and the length of "file://" and "phar://" is 7 so the mismatch
happens at the length-of-the-string index; returning non-0 anyway.
@ndossche
ndossche requested a review from dstogov as a code owner September 21, 2026 19:08
@ndossche
ndossche requested review from iluuu1994 and removed request for dstogov September 21, 2026 19:08

@iluuu1994 iluuu1994 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

return memcmp(filename, "file://", sizeof("file://") - 1) == 0 ||
memcmp(filename, "phar://", sizeof("phar://") - 1) == 0;
return zend_string_starts_with_literal(filename, "file://") ||
zend_string_starts_with_literal(filename, "phar://");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a new issue, but should this be zend_string_starts_with_literal_ci()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nice catch. Dunno which URL standard we follow, but from RFC3986:

Although schemes are case-
insensitive, the canonical form is lowercase and documents that
specify schemes must do so with lowercase letters. An implementation
should accept uppercase letters as equivalent to lowercase in scheme
names (e.g., allow "HTTP" as well as "http") for the sake of
robustness but should only produce lowercase scheme names for
consistency.

So yes, in principle this should be accepted.
Most code in php-src seems to check for this case-insensitively, but e.g. ext/openssl does not.
Should be brought up in a separate issue and uniformized (on consensus).

@ndossche ndossche closed this in c7ffb82 Sep 21, 2026
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.

2 participants