Summary
The PHP session extension can retain a pointer to freed memory if a fatal error occurs during session shutdown. It affects PHP 8.3.x before 8.3.37, 8.4.x before 8.4.28 and 8.5.x before 8.5.13.
What happened
The session extension records the filename of the executing script when a session starts. If a fatal error occurs in an application callback while session variables are destroyed at shutdown, for example in stream_close() of a user-defined stream wrapper, the pointer is retained after the request memory is freed. A later request handled by the same worker can free the stale string. The weakness is classified as CWE-416 and CWE-459. The issue requires the filename to be allocated in request memory, for example when the script is not cached by OPcache.
Why it matters
According to the description, an attacker who can trigger such a failing cleanup may crash the worker or corrupt memory; code execution has not been demonstrated. The CVSS 4.0 score is 9.2 (critical severity, assigned by the PHP CNA), with vector CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N. The source does not state any active exploitation, and CISA's KEV catalog does not list it.
Affected products and versions
PHP (PHP Group): 8.3.x before 8.3.37 (>= 8.3.0, < 8.3.37); 8.4.x before 8.4.28 (>= 8.4.0, < 8.4.28); 8.5.x before 8.5.13 (>= 8.5.0, < 8.5.13).
| Product | Versions | Fixed in |
|---|---|---|
| PHP Group PHP | 8.5.x before 8.5.13 | 8.5.13 |
| PHP Group PHP | 8.4.x before 8.4.28 | 8.4.28 |
| PHP Group PHP | 8.3.x before 8.3.37 | 8.3.37 |
| PHP Group PHP | >= 8.3.0, < 8.3.37 | — |
| PHP Group PHP | >= 8.4.0, < 8.4.28 | — |
| PHP Group PHP | >= 8.5.0, < 8.5.13 | — |
Action recommended by the source
The vendor lists PHP 8.3.37, 8.4.28 and 8.5.13 as the fixed versions, with release notes in the php.net changelog. The source does not state any other mitigations.
Fixed in: 8.3.37, 8.4.28, 8.5.13
Sources and references
- https://www.php.net/ChangeLog-8.php#8.5.13 — PHP
- https://www.php.net/ChangeLog-8.php#8.4.28 — PHP
- https://www.php.net/ChangeLog-8.php#8.3.37 — PHP
- https://github.com/php/php-src/security/advisories/GHSA-g3vh-838c-65v7 — CVE Program
Weaknesses (CWE): CWE-416, CWE-459
Relevant change history
Advisory correction
The preliminary version was replaced by the full write-up.
Published
Preliminary advisory published.