GHSA-g3vh-838c-65v7 / CVE-2026-129481: Use-after-free after interrupted session shutdown
- Published:
- Fetched:
- Updated:
- Affects:
- php ext-session
- KEV due:
- 2026-10-29
https://github.com/php/php-src/security/advisories/GHSA-g3vh-838c-65v7 ↗
Use-after-free after interrupted session shutdown ### Summary PHP can retain a pointer to a script filename after session shutdown is interrupted and the request memory has been released. A later request handled by the same worker can then release the stale string, causing a heap use-after-free. This is an incomplete fix for CVE-2026-109619 (GHSA-6wmf-4rv5-p3rp). It affects PHP 8.3 and later. PHP 8.2 does not contain the affected session filename field. ### Details When a session starts, PHP records the executing script's filename in an internal global variable. Session shutdown normally releases this string, but it destroys the session variables first. That destruction can invoke application callbacks, including a user-defined stream wrapper's `stream_close()` method. A fatal error in such a callback can abort session shutdown before the filename is released or cleared. PHP catches the bailout and continues shutting down the request. The request heap is then freed while the worker still retains the filename pointer. The next request's session initialization does not reset this field. Starting another session can release the stale string, and ordinary session-module shutdown can also reach it even when the next script does not call any session functions. The requests must reach the same worker, but they do not need to belong to the same user or session. The reported reproducer uses PHP-FPM with OPcache disabled and a stream resource held in the session. Its close callback raises a fatal error during cleanup. A subsequent request then reaches the freed filename. The report confirms the use-after-free on PHP 8.4.27 and 8.5.12. PHP 8.3.36 contains the same vulnerable code. Unlike the early-error and upload-progress cases in the original advisory, this path does not require a diagnostic-producing FastCGI parameter or session upload progress. ### Impact An attacker who can cause an application's session cleanup to fail in this way may corrupt memory or crash a reused PHP worker. The use-after-free could potentially lead to remote code execution, but code execution through this specific field has not been demonstrated. Authentication requirements depend on the application path that reaches the failing cleanup. The demonstrated configuration has OPcache disabled, so the recorded filename belongs to the request heap. A filename retained in persistent OPcache memory does not produce the same dangling pointer. Exploitability depends on how the affected script was loaded and whether its filename is request-owned. ### Affected versions The affected field was introduced in PHP 8.3.0, when `session_start()` began recording the file and line where a session was started in order to report them in the notice about an already active session. PHP 8.2 and earlier do not contain the field and are not affected. ### Mitigation Upgrade to the fixed release for your PHP branch when it becomes available. The fix clears the recorded session filename and line number during sessi Affected packages: php:ext-session Patched: ext-session 8.3.37, ext-session 8.4.28, ext-session 8.5.13