[php-src] PR #22126: Fix GH-22122: UAF in SQLite3/Pdo\Sqlite authorizer when callback releases it
| From: | iliaal | Date: | Fri, 22 May 2026 12:38:02 +0000 |
| Subject: | [php-src] PR #22126: Fix GH-22122: UAF in SQLite3/Pdo\Sqlite authorizer when callback releases it | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36197@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22126
Author: iliaal
zend_call_known_fcc does not addref
fcc->object/fcc->closure. When the authorizer callback invokes
$db->setAuthorizer(null), zend_fcc_dtor releases the bound
$this and the object is freed mid-call; the method body then dereferences freed memory.
Snapshot object and closure before the call, addref via
zend_fcc_addref, release the snapshots after. Saved pointers are required because the
callback can replace db_obj->authorizer_fcc.
Same fix applied to Pdo\Sqlite, which has the identical reachable bug via its own
setAuthorizer(null). SQLite3's Z_ISUNDEF(retval) branch now matches
Pdo\Sqlite's ZEND_ASSERT(EG(exception)) shape, so a throwing callback
no longer triggers the misleading "An error occurred while invoking the authorizer
callback" warning.
zend_fcc_dup is not safe here: shallow-copy of function_handler would
leave a trampoline owned by two FCCs, and dtor of the second would double-free.
Fixes #22122