Skip to content

Fix GH-22878: Use-after-free of callable via autoloader#192

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-22878-callable-uaf
Closed

Fix GH-22878: Use-after-free of callable via autoloader#192
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-22878-callable-uaf

Conversation

@iliaal

@iliaal iliaal commented Jul 24, 2026

Copy link
Copy Markdown
Owner

A ['Class','method'] or 'Class::method' callable is validated by borrowing the method name and object out of the callable, then resolving the class. Resolving a string class can run an autoloader, and a compound name emits a deprecation that reaches a user error handler; either can free or mutate the callable mid-validation, so the borrowed method string and $this dangle when the method is resolved and the call frame is built. This copies the borrowed string before the reentrant lookup and holds the array across INIT_USER_CALL so the object survives, covering call_user_func(), call_user_func_array(), $cb(), and referenced/reference-wrapped array callables.

Validating an array or string callable runs user code before its borrowed
method name and object are used: a string class name can trigger an
autoloader, and a compound "Class::method" name emits an E_DEPRECATED that
reaches a user error handler. Either can free or mutate the callable,
leaving the method string and $this dangling. Copy the method string
before the reentrant lookup, and hold the callable array across
INIT_USER_CALL's validation and frame build so the object survives to the
call. This also covers call_user_func_array(), $cb(), and referenced or
reference-wrapped array members.

Fixes phpGH-22878
@iliaal

iliaal commented Jul 24, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#22881

@iliaal iliaal closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant