News 4 min read

phpAfterShell: critical PHP session flaw, update to 8.2.36 or later


PHP has fixed phpAfterShell (CVE-2026-126714), a critical flaw in its default file-based session handler that can let an attacker plant serialized objects in a session and, with the right conditions, run code on the server. The PHP security advisory, published on November 19, 2026, rates it 9.2 out of 10 (CVSS 4.0) and lists fixes in PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13. The same releases fix 16 other security bugs, so every PHP site should update this week.

What’s new

The bug. PHP’s default files session handler overwrites a session file in place without clearing it first. The advisory says that if a write is interrupted, the file can end up holding “parts of two different serialized sessions”: the start of the new data followed by the end of the old data. When the application next calls session_start(), PHP deserializes that mix, and crafted data can turn into objects of the attacker’s choice. The file lock does not help, because it does not make the write atomic. PHP says the code has been there since PHP 4.1.0.

How an attacker gets in. depthfirst, which found the bug and named it, shows the attack through session upload progress: a multipart/form-data upload makes PHP write progress data into the session, with no login and no session_start() needed on the endpoint. The researchers then kill the worker mid-write, through memory pressure or CPU-heavy parsing. The advisory also names a hard memory-limit failure in another thread of a threaded PHP build as a way to interrupt the write.

Code execution needs one more piece. The advisory says reaching code execution needs a gadget chain in the application. depthfirst says it got there without one by chaining a second, memory-corruption bug in a PHP-native class, which it has not disclosed yet. Cloudflare notes the sources do not confirm whether that second bug is fixed in the November 19 releases.

Which versions. Per the advisory, everything below 8.2.36, 8.3.0 to 8.3.36, 8.4.0 to 8.4.27 and 8.5.0 to 8.5.12 is affected. Cloudflare lists PHP 8.6.0 as fixed and its release candidates as vulnerable. depthfirst says the 7.4, 8.0 and 8.1 end-of-life mitigation branches are not affected by phpAfterShell, because their upload-progress code returns without opening the session. That does not put them in the clear: PHP says the PHP-FPM bug, CVE-2026-129289, goes back to PHP 5.6.0, and that releases older than 8.2 may also be affected by CVE-2026-115560.

16 other fixes. Cloudflare counts 16 other vulnerabilities in the same releases. Among the critical ones is CVE-2026-129289 in PHP-FPM: request smuggling that can run PHP code as the worker when the front end reuses FastCGI connections (nginx fastcgi_keep_conn on, Apache mod_proxy_fcgi with enablereuse=on, or HAProxy). Others are use-after-free bugs in the timezone cache, session shutdown and PHP 8.5’s fatal error backtraces. As of November 19, none was in CISA’s Known Exploited Vulnerabilities catalog, and the sources Cloudflare reviewed reported no exploitation in the wild.

What it means for developers

Upgrade and restart. Move to 8.2.36, 8.3.37, 8.4.28, 8.5.13 or 8.6.0, rebuild container images, and restart PHP-FPM or Apache so every worker loads the new binary. Check the version your web server actually serves (a phpinfo() page or your framework’s health check), not just the CLI. Linux distributions often backport fixes without changing the version number, so compare the full package version with your distribution’s advisory.

Check your php.ini. After upgrading, Cloudflare says to check that no php.ini, FPM pool or virtual host still sets session.upload_progress.enabled=1: an explicit setting overrides the new default, so the risky feature stays on.

If you can’t upgrade today, the advisory and Cloudflare suggest:

  • Set session.upload_progress.enabled=0 if you don’t use upload progress bars.
  • Store less untrusted data in sessions.
  • Use a session backend that replaces records atomically instead of the default file handler.
  • Turn off FastCGI connection reuse, and keep PHP-FPM listeners off untrusted networks.
  • On PHP 8.5, set fatal_error_backtraces=0.
  • Fix configuration errors that produce PHP startup warnings, or send PHP errors to syslog instead of a file (this covers the timezone-cache use-after-free).

None of these replaces the upgrade.

If you are behind Cloudflare. Cloudflare extended its existing rule “PHP Remote Code Execution Attack (CVE-2026-109618, CVE-2026-109619, CVE-2026-115560, CVE-2026-126714) #6” to cover phpAfterShell, set to Block in both the Free Managed Ruleset and the paid Managed Ruleset. New rules for the PHP-FPM bug and two PHP SOAP bugs are on Pro, Business and Enterprise plans and default to Log, so review their matches and switch them to Block. Cloudflare says its WAF cannot see the deserialization itself, session data that arrives from databases or queues, or traffic that bypasses Cloudflare.

How it compares

phpAfterShell builds on php2shell (CVE-2026-109618 and CVE-2026-109619), which Cloudflare first wrote rules for on October 21. depthfirst says the php2shell patch only restricted how objects are handled and left the file-update behaviour unchanged, which is what made this second attack possible. It is the latest of several flaws below the application code this week, after Java4Shell in OpenJDK and the nginx HTTP/2 and HTTP/3 bugs: in each case the fix is an upgraded server component plus a restart, not a change to application code.

Sources