Skip to content

Fix GH-25815: UAF when a userspace stream_stat() closes the stream - #25822

Open
lazerg wants to merge 1 commit into
php:PHP-8.5from
lazerg:fix/gh-25815
Open

lazerg wants to merge 1 commit into
php:PHP-8.5from
lazerg:fix/gh-25815

Conversation

@lazerg

@lazerg lazerg commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes GH-25815

GH-14506 and GH-25586 set PHP_STREAM_FLAG_NO_FCLOSE around the read/write/seek/flush/cast handlers, but php_userstreamop_stat() was still missing it. A stream_stat() that calls fclose() on its own stream frees it, and callers that stat the stream internally keep using it afterwards, e.g. stream_get_contents() reads from the freed stream in _php_stream_copy_to_mem(). This sets the flag around the call the same way, so the fclose() only warns.

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