Threat Intelligence

phpAfterShell: PHP Session Flaw Can Leave Attacker Data Behind and Lead to Code Execution

The Hacker News · 20 Nov 2026
Key Takeaway Update PHP to the latest release now, even if you patched on October 21, and confirm with your hosting provider or distribution whether the fix is included.

PHP has released fixes for a critical flaw called phpAfterShell, tracked as CVE-2026-126714 and rated 9.2 out of 10 on the CVSS 4.0 scale by PHP's maintainers. Security company Depthfirst says it found the issue and reported it. Neither the maintainers nor the company reports any attacks using it. PHP 8.6.0 also includes the fix.

The problem sits in PHP's default file-based session handler. A session file stores values with length fields, and nothing marks a write as finished. If a worker process dies partway through a write, the file can keep the start of the new data and the end of the old data. By setting lengths in the new data, an attacker can make harmless-looking old text read as a separate record, including a serialized object. The next request that calls session_start() loads it and creates the object. Code execution then needs a suitable gadget chain in the app, although the researchers say their own chain used a separate memory corruption bug in a built-in PHP class instead. Sessions stored in Redis or a database fall outside this defect.

On the path Depthfirst tested, the attacker abuses upload progress, a feature that writes to the session before the app's own code runs. The app does not need an upload page, only any page that opens the session later. The October 21 releases, which fixed the PHP2Shell flaws, do not contain this fix, because they limited which classes could load but did not change the file write.

The new releases empty the session file before each write and stop if that step fails. They also switch upload progress off by default, though the release notes do not mention this, and a php.ini file, package or hosting panel that enables it will keep it on. Linux distribution packages may carry the fix without changing the version number. Setting session.upload_progress.enabled = 0 is only a partial workaround, since apps that put attacker-controlled data into sessions in other ways stay exposed.

Why it matters

Teams that patched PHP2Shell on October 21 may believe they are covered, but that fix restricted which classes load and left the underlying file write untouched, so those servers remain exposed. Version numbers are also unreliable here, since distribution packages can carry the fix without changing them. Turning off upload progress closes only one route, so any app that stores attacker-influenced data in sessions still needs the update.

What to do

  • Install the latest PHP releases, including 8.2.36, 8.3.37, 8.4.28, 8.5.13 or 8.6.0 where applicable.
  • Set session.upload_progress.enabled = 0 in php.ini and restart PHP workers if you cannot update yet and do not use upload progress.
  • Check with your Linux distribution or host whether its package includes the fix, as the version number may not show it.
  • Limit the untrusted data your app stores in sessions, or move sessions to a store that replaces records in one step.
PHP phpAfterShell CVE-2026-126714 Remote Code Execution Patch Management

Summarised by CISO AI from The Hacker News, written with Claude Sonnet 5.5. We link back to every original so you can read it yourself.