Skip to content

Fix UAF when a stream notification callback closes the stream - #25853

Open
bukka wants to merge 1 commit into
php:PHP-8.4from
bukka:stream_notifier_fclose_uaf
Open

bukka wants to merge 1 commit into
php:PHP-8.4from
bukka:stream_notifier_fclose_uaf

Conversation

@bukka

@bukka bukka commented Nov 27, 2026

Copy link
Copy Markdown
Member

Progress and completed notifications are dispatched from the socket and TLS read and write operations and from the stream buffer filling and writing code, all of which keep using the stream after the notifier returns. A notification callback calling fclose() on that stream freed it under them.

Set PHP_STREAM_FLAG_NO_FCLOSE on the stream while the notifier runs, as is already done for user filters, so that fclose() fails with a warning.

Progress and completed notifications are dispatched from the socket and
TLS read and write operations and from the stream buffer filling and
writing code, all of which keep using the stream after the notifier
returns. A notification callback calling fclose() on that stream freed
it under them.

Set PHP_STREAM_FLAG_NO_FCLOSE on the stream while the notifier runs, as
is already done for user filters, so that fclose() fails with a warning.
@bukka
bukka force-pushed the stream_notifier_fclose_uaf branch from ec4599f to 9dc0eb6 Compare November 27, 2026 21:11
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