phpAfterShell Flaw Can Enable Code Execution Through Interrupted Session Writes

· Original article ↗

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

CVE

Products

Related Articles