Skip to content

Fix GH-25817: UAF when a userspace stream_truncate() closes the stream - #25823

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

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

Conversation

@lazerg

@lazerg lazerg commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Fixes GH-25817

Same gap as GH-25586: stream_truncate() was still called without PHP_STREAM_FLAG_NO_FCLOSE set, so an fclose() from inside it freed the stream while ftruncate() was still using it. When stream_truncate() then returns a non-bool, the warning reads the freed userspace stream data (ASAN reports a heap-use-after-free in user_stream_set_truncation()). This sets the flag around the truncate call, so the fclose() there only warns, like it does for the other handlers.

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