Skip to main content
All incident reports
Incident report

PHP patches critical phpAfterShell session flaw enabling remote code execution

PHP has released fixes for a critical session-file flaw, CVE-2026-126714, that can let an attacker corrupt stored session data and reach remote code execution. The bug, named phpAfterShell by the firm that reported it, has no reported exploitation in the wild.

· First published

The short version

  • The flaw. PHP fixed CVE-2026-126714, rated 9.2 on the CVSS severity scale, on 19 November alongside six other critical issues. The security firm Depthfirst calls it phpAfterShell.
  • How it works. An attacker who can control data written to a session file and interrupt the write can leave new session data sitting alongside remnants of the old. A later request that starts a session on that file can treat the mixed content as valid state and trigger object deserialisation, leading to remote code execution.
  • Conditions. Exploitation requires default file-backed session storage, a way to influence session data (upload-progress tracking is the easiest), a PHP process that stops mid-write, a later session_start() call on the corrupted file, and a deserialisation path to code execution.
  • Exploitation status. There appear to be no reports of phpAfterShell being exploited in the wild. Depthfirst links it to PHP2Shell, an earlier flaw whose fix restricted which objects could be created in memory but did not change how the session file is written.

How the corruption happens

Depthfirst says an attacker who can control data written to a session file and interrupt the write can leave the file holding new session data followed by remnants of the old. A later request that starts a session on that file can treat the mixed content as valid server-side state, letting the attacker set session values and trigger object deserialisation, in which stored data is rebuilt as live objects. That can lead to remote code execution.

The underlying cause, per Depthfirst, is that PHP overwrites the session file from the start without emptying it first. If the write is interrupted before the trailing old data is truncated, ordinary strings can end up positioned where serialised object data is expected. PHP's own advisory notes the same problem can arise when an application stores large user-controlled strings in a session, and that on threaded builds a memory-limit failure in another thread can stop the process mid-write.

Who is exposed and what fixes it

Exploitation needs several things at once: default file-backed session storage, a route to influence session data, a PHP process that stops mid-write, a later request calling session_start() on the corrupted file, and a path from deserialisation to code execution. Depthfirst says it found reliable ways to interrupt the write during session upload-progress updates, which it describes as the easiest route.

PHP fixed the bug on 19 November in version 8.4.28 and in the corresponding releases for its other supported branches, alongside six other critical issues. Administrators should check PHP's advisory for the release that matches the branch they run.

Link to PHP2Shell

Depthfirst describes phpAfterShell as related to PHP2Shell, a flaw in the handling of unauthenticated multipart requests where an upload-progress callback could open and decode a file-backed session before the target script ran. PHP restricted which objects could be created in memory during that callback but, according to Depthfirst, left the file update behaviour unchanged: the callback still reads the session, adds upload-progress state, serialises the whole thing and writes it back to the same file.

What is not known yet

  • Whether any attacker has attempted to exploit phpAfterShell, and who might.
  • How many production applications meet all of the conditions the flaw requires.
  • Whether shared hosting providers and managed platforms running PHP have applied the 19 November fixes.
  • Whether PHP2Shell itself was ever exploited in the wild.

What to do

If you run PHP

  1. Upgrade to PHP 8.4.28, or the patched release for your branch listed in PHP's advisory.
  2. Check whether your applications rely on PHP's default file-backed session storage, which the flaw depends on.
  3. Note that upload-progress tracking is described as the easiest way for a remote client to influence stored session data.

If you develop PHP applications

  1. Avoid storing large user-controlled strings in session data, which PHP's advisory says can produce the same corruption.
  2. Review code that calls session_start() on session files that may have been written by an interrupted operation.

For everyone else

  1. Treat session state written in place as fragile: a write that is cut short can leave data that a later request accepts as genuine, so keep runtimes current and watch for advisories on session handling.

Update log

  • First published.

Sources

New incident reports by email

One email a week with the reports published since the last one.

We email you about this topic only; unsubscribe any time. See our Privacy Policy.

Want us to look at your domain?

Give us one apex domain and we'll send back a written snapshot of what is already visible from outside. No call required.