phpAfterShell Vulnerability Allows PHP Session Manipulation Leading to Remote Code Execution

PHP's default file-based session handler is vulnerable to a flaw tracked as CVE-2026-126714 and rated 9.2 on CVSS 4.0. An attacker can truncate a session write at a precise moment to inject chosen serialized objects that later deserialize into active instances. When combined with a gadget chain or secondary memory corruption bug, this leads to arbitrary code execution on the server. The issue affects PHP 8.2 through 8.6.0 before the listed fixed releases and was discovered by Depthfirst. Today's patches empty the session file before writing and disable upload progress by default, while older branches remain end-of-life. The same releases also address additional security issues and correct an incomplete fix from the October PHP2Shell updates.

The Hacker NewsTranslated from English

Read at source

PHP's default file-based session storage can be abused to return attacker-chosen objects by cutting off a session write at the right moment. When combined with a second weakness such as a suitable gadget chain in the application, those objects allow an attacker to run arbitrary code on the server.

The flaw, called phpAfterShell and tracked as CVE-2026-126714, received a CVSS 4.0 score of 9.2 from PHP maintainers. Security company Depthfirst discovered and reported the issue. The October 21 releases that fixed the two critical PHP2Shell flaws did not contain this fix, leaving servers updated at that time still vulnerable until today's patches are applied. No attacks using phpAfterShell have been observed so far.

Affected Releases and Remediation

The following branches require updates according to the official advisory:

  • PHP 8.2 before 8.2.36 → fixed in 8.2.36
  • PHP 8.3 before 8.3.37 → fixed in 8.3.37
  • PHP 8.4 before 8.4.28 → fixed in 8.4.28
  • PHP 8.5 before 8.5.13 → fixed in 8.5.13

PHP 8.6.0 also includes the fix. PHP 8.1 and older branches are end-of-life; official mitigation branches for 7.4, 8.0 and 8.1 are not affected, although older unpatched builds remain vulnerable.

Administrators should install the fixed releases, rebuild container images, redeploy, and verify the running PHP version. If an immediate update is impossible and the application does not use upload progress, set session.upload_progress.enabled = 0 and restart PHP workers. Moving sessions to an atomic store such as Redis also avoids the defect.

How the Attack Works

The attack begins with the session write performed by the upload progress feature before application code executes. A PHP session file stores values as name followed by serialized data; length fields determine string boundaries and no marker indicates a completed write. If the worker process terminates mid-write, the file can contain a mix of new and old data. By carefully setting lengths in the injected data, an attacker can make previously harmless text parse as a separate serialized object such as stdClass.

The next session_start() call deserializes the object. Depthfirst researchers demonstrated the technique using an out-of-memory kill to interrupt the write; the planted object appeared on the 11th attempt in their tests. Code execution still requires a gadget chain or an additional memory corruption bug in a built-in class, details of which are withheld for coordinated disclosure.

The October PHP2Shell fixes limited classes that could be loaded during upload progress but left the underlying file-write issue untouched. Today's releases empty the session file before each write and stop writing if the step fails, preventing mixed data from being left behind. They also switch upload progress off by default, although applications relying on the feature must re-enable it explicitly after the update.

Meridian digestThe week's most consequential security stories, distilled into one briefing.See the digest

More in Vulns & Exploits

Microsoft Entra Connect Health Flaw Exploited to Access Tenant Metadata and Admin Emails
GnuPG Warns of Critical Double-Free Flaw in GPGME Exposing App Data to Malicious OpenPGP Keys
CISA Adds Four Critical Flaws in Apache Roller, Cisco Expressway, SAP NetWeaver, and VMware vCenter to Known Exploited Vulnerabilities Catalog