phpAfterShell Flaw Can Enable Code Execution Through Interrupted Session Writes

Summary
PHP's CVE-2026-126714 can leave old serialized data in file-based sessions after an interrupted write, allowing attacker-chosen objects to load later and potentially enable code execution with a suitable gadget chain. PHP releases fix the flaw; no attacks are reported.
Key points
- An interrupted write to PHP's default file-based session handler can leave a mix of new and old serialized data; crafted length fields can make old data load as a separate object.
- On the path researchers tested, PHP's upload-progress feature writes to the session before the application code runs. The attack requires stopping that write at the right moment.
- A later request calling session_start() can load the planted object. Code execution still requires a suitable gadget chain; the researchers' own chain used a separate PHP class memory-corruption bug whose fix status is unknown.
- In Linux tests, researchers used an out-of-memory kill to stop the worker mid-write. The object appeared on the 11th attempt in one fresh run; that count did not measure code-execution success.
- The PHP fix empties the session file before each write and stops if that step fails. The releases also disable upload progress by default.
- Disabling upload progress can close the tested path but is not a complete fix if an application stores attacker-controlled data in sessions through other means. Updating is recommended.
- The maintainers and researchers reported no attacks using phpAfterShell.
Article Details
- Attack Vectors
- In the researchers' tested path, an attacker submits a multipart upload carrying the upload-progress field, causing PHP to write to the user's session before the application code runs.
- If a session-file write is interrupted at the right moment, new and old session data can be left mixed together. The next request that calls session_start() may load an attacker-chosen serialized object.
- The described code-execution path additionally requires a suitable gadget chain in the application. The researchers say their own proof used a separate PHP built-in-class memory-corruption bug instead; they withheld its details.
- The researchers describe an out-of-memory kill as a way they stopped a worker mid-write in their Linux tests. They report that the planted object appeared on the 11th attempt in a fresh run, a result limited to getting the file into the required state on their test servers.
- Defensive Notes
- Install a fixed PHP release; the article says the October 21 releases did not include the fix and that today's releases do.
- If an update is not possible and the application does not use upload progress, set session.upload_progress.enabled = 0 in php.ini or the server's PHP settings, then restart PHP workers. This closes the upload path but is not a full fix if attacker-controlled data can reach sessions another way.
- Limit untrusted data stored in sessions. Moving sessions to a store that replaces records in one step also avoids this defect, according to the article.
- Check whether distribution packages include the fix, since the version number alone may not show whether a server is fixed.
- After updating, check whether php.ini, a distribution package, or a hosting panel re-enables upload progress. Where nothing else sets it, applications that rely on the feature may need to turn it back on.
MITRE ATT&CK
T1190 · Exploit Public-Facing ApplicationThe researchers describe a hypothetical attack against an application using PHP's vulnerable file-based session handler, where an attacker exploits the flaw to create a serialized object that may enable server-side code execution.T1565.001 · Stored Data ManipulationThe described exploit leaves PHP session-file data in a mixed state, allowing an attacker to make old session content read as a separate record or replace ordinary session values such as permissions or a CSRF token.
CVE
Products
PHPPHP's default file-based session storage can be made to return objects an attacker chose, by cutting off a session write at the right moment. When combined with a second weakness, such as a suitable gadget chain in theRedisThe flaw is in the files session handler, which PHP uses by default. Sessions kept in Redis, a database, or another store are outside this defect, though each store's handling of a cut-off update needs its own check.
