Are you Mythos ready?

Read our latest report on validating and fixing vulnerabilities at machine speed.

Read the report
Read the report
Book a demo
Book a demo
For more information about how ZEST processes personal data, check out our Privacy Policy.
No items found.

PHP2Shell, the third one: how ZEST found CVE-2026-115560

Dvir Sasson
Dvir Sasson
VP, Al & Security Research

Last updated November 19, 2026, 14:33 UTC

TL;DR

  • What: PHP's session upload progress feature lets an unauthenticated request write attacker bytes into the session store. When one part of a deployment writes sessions in the php_binary or php_serialize format and another part reads them in the default php format, a single | in a form field becomes an unserialize() of attacker data. With a stock gadget from Guzzle, that is remote code execution as the PHP worker.
  • Severity: PHP rates it Critical, CVSS 4.0 9.2 (AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H), CWE-20 and CWE-502.
  • Fixed in: PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13 (released 19 November 2026). PHP 8.6.0, released the same day, ships with the fix. PHP 8.1 and older get no fix.
  • The fix: upload progress is now off by default, and PHP rejects runtime changes to session settings, including session.serialize_handler, while upload progress is enabled.
  • Do now: upgrade, then grep every php.ini, FPM pool and vhost for an explicit session.upload_progress.enabled = On. An explicit setting overrides the new default, and the fix does not stop two separately configured apps from disagreeing about the format.
  • Exploitation: no public reports of in-the-wild use as of publication. We are not publishing exploit code.

Three questions on the day PHP2Shell dropped

On 21 October PHP shipped emergency fixes for PHP2Shell (CVE-2026-109618 and CVE-2026-109619), two critical bugs in the same session upload progress code. Exploit code was already public. My team set ourselves three research questions that day, and wrote down the answers as we got them.

QUESTION 01
Can PHP2Shell become one generic, self-calibrating exploit?
Across versions and stacks, with no hand tuning per target.
Yes
About two hours. Used, with consent, to validate and protect customers.
QUESTION 02
Did the October patch close every path into this code?
Or only the two paths that were reported?
No
This post is the path it missed.
QUESTION 03
How fast does a local open-weight model get us to a new bug?
GLM 5.3 on our own hardware, no cloud API in the loop.
~5 hours
From our first look at PHP2Shell to a reportable vulnerability.

We put the first answer to work straight away. The self-calibrating payload let us validate, with our customers' consent, which of their environments were actually exploitable, and protect those proactively, before any vendor fix existed. The rest of this post answers the second question. We opened the advisory on GitHub at 16:53 UTC that day, and it is now CVE-2026-115560.

The model was fast, and it was sometimes wrong with total confidence. One of its write-ups put the php_binary key limit at 255 bytes; the source says 127. So every claim in this post comes from a lab run or from PHP's source at a pinned commit. That habit mattered more than the speed.

The bug in one byte

PHP stores sessions with a pluggable serializer, chosen by session.serialize_handler. Three ship in core:

  • php (default) · how a key is stored: the name, a pipe, then the serialized value · a key that contains a pipe: Refused. The whole write fails.
  • php_binary · how a key is stored: one length byte, raw key, value · a key that contains a pipe: Stored verbatim. Only keys over 127 bytes are skipped.
  • php_serialize · how a key is stored: a:N:{s:LEN:"key";value} · a key that contains a pipe: Stored verbatim, no length cap.

The php writer knows the pipe is its delimiter and guards against it. Here is that guard in PHP 8.5.12 (session.c#L1090-L1113):

c
PS_SERIALIZER_ENCODE_FUNC(php)
{
	...
	PS_ENCODE_LOOP(
		smart_str_append(&buf, key);
		if (memchr(ZSTR_VAL(key), PS_DELIMITER, ZSTR_LEN(key))) {
			PHP_VAR_SERIALIZE_DESTROY(var_hash);
			smart_str_free(&buf);
			fail = true;
			php_error_docref(NULL, E_WARNING, "Failed to write session data. Data contains invalid key \"%s\"", ZSTR_VAL(key));
			break;
		}
		smart_str_appendc(&buf, PS_DELIMITER);
		php_var_serialize(&buf, struc, &var_hash);
	);

The php_binary writer has no content check at all, only a length check (session.c#L1023-L1044):

c
#define PS_BIN_NR_OF_BITS 8
#define PS_BIN_UNDEF (1<<(PS_BIN_NR_OF_BITS-1))
#define PS_BIN_MAX (PS_BIN_UNDEF-1)            /* 127 */

PS_SERIALIZER_ENCODE_FUNC(php_binary)
{
	...
	PS_ENCODE_LOOP(
			if (ZSTR_LEN(key) > PS_BIN_MAX) continue;
			smart_str_appendc(&buf, (unsigned char)ZSTR_LEN(key));
			smart_str_append(&buf, key);      /* raw bytes, '|' included */
			php_var_serialize(&buf, struc, &var_hash);
	);

Neither of those is a bug by itself. A format is allowed to have its own rules. The bug appears when a file written under one set of rules is read under the other. The php reader scans for the first |, calls everything before it the name, and hands everything after it to php_var_unserialize() (session.c#L1122-L1158).

So who gets to choose the key?

The attacker picks the key

Session upload progress, on by default since PHP 5.4 in 2012, tracks a file upload by putting an array into $_SESSION. The array's key is the configured prefix plus whatever the client sent in a form field called PHP_SESSION_UPLOAD_PROGRESS (session.c#L3262-L3268):

c
} else if (zend_string_equals_cstr(PS(rfc1867_name), data->name, name_len)) {
	smart_str_free(&progress->key);
	smart_str_append(&progress->key, PS(rfc1867_prefix));          /* "upload_progress_" */
	smart_str_appendl(&progress->key, *data->value, value_len);    /* attacker bytes, unfiltered */
	smart_str_0(&progress->key);

This runs while PHP parses the multipart body, before a single line of application code. The page does not need to handle uploads or even call session_start(). Any .php URL that accepts a POST will do, as long as the request carries a session ID.

Put the pieces together:

  1. The attacker POSTs a multipart body to a URL served with php_binary or php_serialize. The progress field holds x|O:... followed by a serialized object.
  2. PHP writes that key, pipe and all, into the session file and flushes it to disk mid-request.
  3. Anything that later opens the same session with the php handler splits at the attacker's pipe and unserializes the object.
  4. The rest of the record fails to parse, so session_start() warns and fails. The objects it already built stay alive, and their destructors run at shutdown. No application unserialize() call is needed. A destructor gadget is enough.

Here is the same record as each side sees it.

One session record, read two ways: the writer stores one key, the reader splits at the pipe and unserializes the rest.

Why the PHP2Shell fix did not stop it

The October fix for CVE-2026-109619 added a sensible guard. While the upload progress handler decodes and re-encodes the session inside the upload request, objects come back as __PHP_Incomplete_Class, with no autoloading and no magic methods (session.c#L958-L977, from commit 3584a98):

c
static void php_session_unserialize_init(php_unserialize_data_t *var_hash)
{
	PHP_VAR_UNSERIALIZE_INIT(*var_hash);
	if (PS(in_rfc1867_update)) {
		php_var_unserialize_set_incomplete_classes_only(*var_hash, true);
	}
}

That locks the door inside the writing request. It does nothing for the poisoned bytes already sitting on disk, and it does nothing for the next request, a different pool or a different vhost that opens the file with full class loading. We reproduced code execution on all four October releases (8.2.35, 8.3.36, 8.4.27, 8.5.12), the builds that carry the PHP2Shell fix.

From "unlikely" to a working exploit

PHP's first response to our report was fair. A hand-written class with system() in its destructor proves the mechanism, and PHP said so: crafted code in callbacks is not a security issue. So we removed every line we wrote from the target.

A stock gadget. The reading app got one common dependency, guzzlehttp/guzzle, and nothing we wrote. One of its classes writes a file when it is destroyed, and that was enough to plant a PHP file the worker could then run. PHP's advisory names a second chain we reported, Monolog 2.11.1. Neither library is at fault. They are simply on the reader's class path.

The 127-byte cap is not a limit. php_binary silently drops keys longer than 127 bytes, and a real gadget is longer than that. The php reader, though, does not respect php_binary record boundaries, so one object can be spread across several upload fields and reassembled by the reader. PHP's advisory now says it plainly: the 127-byte limit does not prevent payloads that span records.

It calibrates itself. The exact layout shifts with the PHP version and the server's temp path. Our tool works it out per target without a crash or a hint from the server, and confirms success only with a per-run marker, so a catch-all page cannot fake a result.

Cleanup is on by default, and it does not help. session.upload_progress.cleanup=1 removes the progress key when the upload finishes, not while it is still running. A concurrent read during a slow upload is enough. PHP's advisory makes the same point: "Do not rely on upload-progress cleanup to prevent a concurrent read." We hit this on the first attempt in three of three runs under Apache mod_php.

We demonstrated code execution on PHP 5.4.45, 5.6.40, 7.4.33, 8.0.30, 8.1.34 and the 8.2 through 8.5 lines, on nginx with two PHP-FPM pools, on Apache mod_php with per-directory settings, and on the PHP built-in server.

We are not publishing the exploit, the gadget layout or the calibration logic.

Where the mismatch hides in real deployments

PHP's first public note, on 23 October, described one narrow setup: an app that configures php_binary or php_serialize and then switches to php with ini_set() before session_start(). It called that setup unlikely and scheduled the fix for the regular release cycle.

The pattern is less rare than that. It sits in widely deployed open source code today:

None of these apps is vulnerable on its own. They are the reader half. They become exploitable when the server's own configuration writes in a different format, and that is a decision an operator makes in php.ini, a pool file or a panel template, usually years apart from whoever installed the app.

The runtime switch is not even required. These shapes all worked in our lab with no ini_set() anywhere:

  • nginx + two FPM pools · writer: pool A: php_binary · reader: pool B: php · what they share: one session.save_path
  • Apache mod_php · writer: <Directory a> override · reader: <Directory b> default · what they share: the server-wide save_path
  • Shared hosting · writer: an old app on the account · reader: a WordPress-style app on the same account · what they share: uid and save_path

Separate FPM pools do not get separate session directories unless someone configures them, a point PHP's advisory makes too. The advisory also lists command-line processes with their own INI settings as a possible writer.

The shared-hosting row is the one that worried us most. A legacy app's configuration choice let us drop a webshell into a neighbouring application, and overwrite its wp-config.php, through a session file neither app's code ever touched. The app that got owned did nothing wrong.

PHP's final advisory covers all of this: "An application that never changes its serializer at runtime can still be affected if another application or process writes incompatible data into the same session store."

The bug PHP was told about in 2015

Credit where it is due. The injection idea is not new. In December 2015 Taoguang Chen filed PHP bug #71101, "PHP Session Data Injection Vulnerability," with a working test case: an upload progress key carrying a serialized object, read back through a different handler. The reply was that this "requires specific (and erroneous) user action to trigger." The report was downgraded to a regular bug in 2016 and to a documentation problem in 2021. CTF players have used the trick ever since.

What changed in 2026 is the evidence. We used a stock gadget from a widely used library instead of a class we wrote. We showed setups that need no runtime switch and no code change, a way past the length cap, and a race that works with cleanup on. We took over a neighbouring app on a shared-hosting layout. And we did it on the releases that had just been patched for the same feature.

In under four weeks the classification moved from an informational note handled "in the regular release cycle" to Critical, 9.2, with a default changed in a security release. PHP does not flip defaults lightly, and the 2015 thread shows why: the structural fix proposed then, making the handler a per-directory setting, was rejected as a big backward-compatibility break. Turning upload progress off by default sidesteps that. The feature exists to draw upload progress bars from $_SESSION, and the sites that need it can switch it back on.

The fix, and what it does not cover

From PHP's advisory, GHSA-658j-r8rw-q6mx, the fixed releases:

  1. Disable session.upload_progress.enabled by default.
  2. Reject runtime changes to session settings, session.serialize_handler included, while upload progress is enabled.

Fix commits, one per branch: 8.2 (3f70f66), 8.3 (6aa0395), 8.4 (178d4c8) and 8.5 (522afb6). Each flips the session.upload_progress.enabled default from "1" to "0" and adds a runtime guard that throws "Session ini settings cannot be changed at runtime when session.upload_progress.enabled is On".

The advisory went public at 14:08 UTC on 19 November. It is the one we opened on 21 October, and PHP credits eight reporters on it in all. The same releases also fix CVE-2026-126714, a separate Critical bug in which partially overwritten session files lead to code execution. One upgrade covers both.

Two caveats PHP states itself, and we want every operator to read twice:

  • An explicit setting wins. If any php.ini, FPM pool or vhost says session.upload_progress.enabled = On, the new default does nothing for that context.
  • Separate configurations are not checked against each other. "The fix does not enforce matching serializers across separate configurations." Two pools that disagree, with upload progress on in either, are still exposed after the upgrade.

The hardening we proposed upstream closes both writer variants for every handler pairing: reject | in the PHP_SESSION_UPLOAD_PROGRESS value when the key is built, the same way the php writer already rejects it. That question is still open with the PHP team.

How many servers are in scope

Shodan, 19 November 2026, hosts advertising a PHP version in the X-Powered-By header:

  • 8.5 · hosts: 121,806 · fix: 8.5.13
  • 8.4 · hosts: 103,423 · fix: 8.4.28
  • 8.3 · hosts: 288,800 · fix: 8.3.37
  • 8.2 · hosts: 230,818 · fix: 8.2.36
  • 8.1 and 8.0 · hosts: 136,501 · fix: none, end of life
  • 7.x · hosts: 277,214 · fix: none, end of life
  • 5.4 to 5.6 · hosts: 241,375 · fix: none, end of life

That is about 1.4 million hosts on a version that shipped the feature, and about 655,000 of them on branches that will never get the fix. About 444,000 hosts report exactly the October build (8.5.12, 8.4.27, 8.3.36 or 8.2.35). Those operators patched PHP2Shell on time, and their version is still in scope today.

Read those numbers carefully. A version banner says nothing about configuration. Shodan cannot see whether upload progress is on, which handler each pool uses, or whether two contexts share a session directory, and many well-run servers hide X-Powered-By entirely. This is the population that has to check, not the population that is exploitable.

Shodan, 19 November 2026: about 94,000 hosts advertise PHP/8.5.12, the build that fixed PHP2Shell and is still in scope.

What to do on Monday morning

Step 1. Upgrade to 8.2.36, 8.3.37, 8.4.28, 8.5.13 or 8.6.0, or your distribution's backport, and restart every PHP worker. Rebuild container images on the fixed base.

Step 2. Find explicit enables. They override the new default.

find explicit upload progress enables
grep -rniE 'upload_progress\.enabled' /etc/php* /usr/local/etc/php* /etc/apache2 /etc/httpd /etc/nginx 2>/dev/null

Step 3. Find handler mismatches. Every context that can reach one session store must use the same handler.

find serializer settings and runtime switches
grep -rniE 'serialize_handler' /etc/php* /usr/local/etc/php* /etc/apache2 /etc/httpd 2>/dev/null
grep -rnE "ini_set\(\s*['\"]session\.serialize_handler" /var/www 2>/dev/null

Step 4. On PHP 8.1 and older, set session.upload_progress.enabled = 0 in php.ini or the pool config, not with ini_set(). The write happens before your code runs.

Step 5. Give each app its own session.save_path, owned by its own user. Separate FPM pools do not get separate session directories automatically.

Step 6. Do not trust cleanup. session.upload_progress.cleanup=1 does not stop a concurrent read.

How ZEST handles a bug like this

A bug like this is a configuration problem wearing a version number. The fix is easy to name: upgrade PHP, switch upload progress off, keep one serializer per session store. Shipping that across every pool, vhost and container image without breaking a checkout page is the hard part, and it is the part ZEST is built for.

Find the exposure, and the person who owns it. ZEST builds one inventory of every PHP runtime from the scanners, SBOMs and cloud sources you already run, and flags the affected branches as a zero-day before the scanner feeds catch up. Each vulnerability goes to its AI-suggested owner, so the team that runs the pool hears about it, not a shared security queue.

Rehearse the fix on a Digital Twin. Turning upload progress off breaks any page that draws a progress bar from $_SESSION, and an upgrade can surprise an old app. The Digital Twin simulates the fix against a model of your environment before it ships, so the change that reaches production has already passed.

Ship it with Autonomous Remediation. The plan that passes goes to its owner the way your team already works: Autonomous Remediation can kick off your deployment workflow, send the plan to the owner to review and run, or open a Jira ticket already assigned to them. The vulnerability closes when the scanner sees the fixed build, not when someone marks a ticket done.

Credit the mitigating controls that actually hold. Until every worker is upgraded, the control that matters is upload progress switched off in the pool or php.ini, not in code. ZEST records it as a mitigating control on the vulnerability, so a mitigated server is visibly mitigated and an unmitigated one stays at the top of the queue. We hold every control to the same bar we set for WAF rules: it counts only when it covers this vulnerability, enforces rather than logs, and sits on the only path in.

Timeline

  • 2015-12-12 · event: PHP bug #71101 reports upload progress session injection; ruled not a security issue
  • 2026-10-21 · event: PHP2Shell fixes ship (8.2.35, 8.3.36, 8.4.27, 8.5.12)
  • 2026-10-21 16:53 · event: ZEST opens GHSA-658j-r8rw-q6mx with the serializer mismatch and RCE on current releases
  • 2026-10-22 · event: Stock Guzzle gadget RCE on 8.4.27 using the record-spanning technique
  • 2026-10-23 · event: CVE-2026-115560 assigned; PHP publishes an informational note, fix in the regular cycle
  • 2026-10-24 to 25 · event: Self-calibrating exploit on all four October releases; FPM, Apache and shared-hosting shapes; cleanup-on race
  • 2026-11-16 · event: Advisory updated: Critical, CVSS 4.0 9.2
  • 2026-11-18 · event: PHP pre-announces a critical security release
  • 2026-11-19 · event: PHP 8.2.36, 8.3.37, 8.4.28 and 8.5.13 released, 8.6.0 ships fixed; advisory public at 14:08

Thank you to the PHP security team: Arnaud Le Blanc for the fix, Jakub Zelenka for reviewing and publishing it, Ilija Tovilo for the analysis, and Nils Adermann for working the advisory with us.

Sources

About The Author

Dvir Sasson

Dvir Shimon Sasson is the VP of AI & Security Research at ZEST Security, where he drives innovation at the nexus of AI, autonomous agents, and cybersecurity. With over a decade of hands-on expertise across offensive and defensive security, his specializations include red team operations on AI systems and agents, incident response, threat intelligence, cloud security, and pioneering research into agentic security automation and emerging risks like Shadow AI. Certified CISSP and OSCP, Dvir is passionate about problem-solving, developing intelligent automation scripts in Python and PowerShell, and dissecting the mechanics of breaking things to build more resilient, AI-native defenses.

More Resources

View more
View more
BOOK a demo

Ready to see
ZEST in action?

"With ZEST, we can proactively resolve attack paths and quickly address cloud vulnerabilities"
Alexander Scheer Head of Cybersecurity @ Odyssey Therapeutics
Alexander Scheer
Head of Cybersecurity
@ Odyssey Therapeutics