December 3, 2026
PHP2Shell: Two Bugs Beneath the Framework That Hand Over Any PHP Server
A pre-auth remote code execution chain that lives in the PHP runtime itself β below your framework, below your login, and present in everyβ¦

By Mr. Spider
8 min read
A pre-auth remote code execution chain that lives in the PHP runtime itself β below your framework, below your login, and present in every release since 2012.
The runtime is the vulnerability, not your app
On 21 October 2026, the PHP project disclosed two vulnerabilities that, between them, let an unauthenticated attacker run commands on almost any PHP server using nothing but ordinary HTTP requests. Emergency fixes went out the same day across every supported branch.
There was no login to defeat, no file upload the application had to accept, and no bug in the application's own code. The flaw lived in the PHP runtime, beneath whatever framework or CMS happened to be installed.
The disclosure was named PHP2Shell. Because the vulnerable code had been present since PHP 5.4.0 in 2012, it reached fourteen years of releases in one shot.
At a glance:
- Tracked as CVE-2026β109618 and CVE-2026β109619, both scored 9.2 Critical on CVSS v4.0.
- Found by researchers at Wiz, OpenAI and Calif, and reported privately to the PHP security team.
- Patched in PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35.
- Details leaked a day before the fix, and network sensors recorded exploitation attempts within hours β some before the patched releases were even out.
This is a live threat, not a theoretical one.
An attack that happens while your app is asleep
When someone visits a PHP site, PHP hands the request to your application and runs its code. But PHP also does work before your code runs and that pre-execution window is where the whole of PHP2Shell takes place, driven entirely by what the attacker puts in an ordinary multipart upload.
Reaching that code needs no session_start() in the target page, no valid login, and in fact no application logic at all. Any URL on the server that accepts a POST request is enough even one whose script does nothing but print a single line.
That is the uncomfortable part. If the attack works against a page that only prints OK, it works against the runtime, and a real WordPress or Laravel site is no better protected just because its own code is sound.
Phase 1: The pre-auth window: session.upload_progress
PHP has an internal feature called session.upload_progress that tracks how much of a file upload has been received. Imagine uploading a 100 MB file: the server needs a way to report that it has 10%, then 50%, then 100% of the bytes. PHP handles this by writing the upload's name, total size, bytes received and status into the user's session ($_SESSION) as the file streams in, so a second request can read the progress back.
The feature is enabled by default in most configurations. To activate tracking for a specific upload, the form just needs a special hidden field:
<input type="hidden" name="PHP_SESSION_UPLOAD_PROGRESS" value="my_upload"><input type="hidden" name="PHP_SESSION_UPLOAD_PROGRESS" value="my_upload">That field tells PHP: track this upload and store its progress in the session. The attacker's request is the same shape a multipart POST carrying PHP_SESSION_UPLOAD_PROGRESS and one file part:
POST /index.php HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----123
------123
Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"
test
------123
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
Hello World
------123--POST /index.php HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----123
------123
Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"
test
------123
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
Hello World
------123--The timing is the whole point. Parsing the request body is one of the first things PHP does long before it initialises the request environment (RINIT) and long before it compiles and runs the script the URL points at. The progress updates are written from inside the body-parsing callbacks, so they happen before any application code executes. The attacker reaches this stage pre-auth.
Phase 2: When PHP runs out of memory
The upload-progress feature is not itself the vulnerability. The vulnerability is what happens when PHP runs out of memory while that feature is in the middle of its work and to see it, you need to know how PHP handles a fatal memory error.
PHP caps how much memory a single request may use with the memory_limit setting (say memory_limit = 8M). When a request tries to exceed it, PHP cannot simply carry on. Instead it performs what the engine calls a bailout: a longjmp() straight back to a safe recovery point, abandoning whatever it was doing. This is the mechanism behind the familiar "Allowed memory size exhausted" fatal error.
The critical detail is that a bailout is an emergency exit. It stops execution immediately, without properly freeing memory or cleaning up the resources that were in flight.
Phase 3 & 4: A dangling pointer, and a worker that lives on
Here is the bad timing that creates the bug:
- PHP frees a block of memory with
free(). - Before it can clear the pointer that referred to that memory, the out-of-memory error fires.
- PHP bails out, skipping the cleanup.
- The pointer survives and still pointing at memory that has already been freed.
That stale pointer is a dangling pointer, classified as CWE-824 (access of uninitialised pointer). Think of it as keeping the address of a house after the house has been demolished.
A dangling pointer on its own would be harmless if the process restarted. It does not. Under Apache's prefork model, each worker handles one request at a time and stays alive to handle the next one instead of restarting. So the same worker that bailed out picks up a fresh request with the broken pointer still in place.
Now the attacker has an opening. They can influence what new data lands in the freed memory, and when PHP follows the old pointer, it may read or act on attacker-controlled data sitting where the original object used to be.
From this single defect the researchers built two different attacks, which is why PHP2Shell carries two CVE numbers.
One defect, two CVEs
CVE-2026β109618:
- Memory disclosure.
- The attacker influences the length of data PHP reads through the dangling pointer, so PHP reads more memory than it should, and that extra memory is returned inside an HTTP response header.
- The result: the attacker can see parts of the worker's memory that should never be exposed.
CVE-2026β109619:
- Remote code execution.
- Instead of just reading the corrupted memory, the attacker reoccupies it to hijack the program's execution flow, and ultimately runs commands on the server.
Both depend on the same prefork behaviour. Workers are separate server processes that handle incoming requests, like clerks at a reception desk: Apache keeps several of them running, each takes one request at a time, and after finishing, the same worker handles the next request rather than restarting. That reuse is exactly what keeps the dangling pointer reachable across two requests the attacker's first request plants the condition, and a second request springs it.
Reconnaissance: confirming the target
- The lab target runs as a container.
- Listing it and reading its PHP version shows PHP 8.4.26 β one release short of the 8.4.27 fix, so it is vulnerable.
- The application itself is a single line that prints
OK. - No login form, no file upload, no database, and certainly no bug in this code to exploit.
- That is the point worth pausing on.
- If the attack works against this page, it works against the runtime, not the application and a real WordPress or Laravel site is no safer simply because its own code is sound.
The server runs the ordinary prefork mod_php setup with session.upload_progress enabled by default. For the lab it is cut down to a single worker with a low memory_limit, so the dangling pointer is reliably reused and the out-of-memory condition is easy to provoke. A production host would run many workers with a higher limit, which makes the timing harder to hit but not impossible.
Phase 5 & 6: Leaking memory and defeating ASLR (CVE-2026β109618)
Modern systems load code and data at randomised addresses, a defence called Address Space Layout Randomisation (ASLR). An attacker who wants to redirect execution has to know where things actually are in memory, and ASLR is meant to deny that knowledge. CVE-2026β109618 removes it by turning the dangling pointer into a leak of the worker's own memory.
The sequence runs like this:
- PHP crashes while handling the session ID. An out-of-memory error fires mid-processing, PHP bails out, and a pointer to the old session ID is left behind pointing at freed memory.
- The same worker reuses that memory. A later request puts new data there, but the stale pointer still points to the location.
- PHP misreads the length. The stale pointer refers to a string whose recorded length is far larger than its real data say an actual session ID of 32 bytes that PHP now believes is 67 KB so PHP reads far beyond the real value.
- The overread leaks through the response. PHP sends the session cookie back with
Set-Cookie: PHPSESSID=..., and the extra bytes come from adjacent worker memory: potentially passwords, session cookies, API keys, cryptographic material, and memory addresses.
Two leaks matter most:
- The PHP heap base: where the large region PHP uses for dynamic data (strings, objects) begins.
- The
libphpbase: where PHP's own engine code lives. The exploit finds a pointer into the library whose offset from the start is already known, then back-calculates:
library base = leaked address - known offsetlibrary base = leaked address - known offsetWith both the heap and the library located, the exploit can work out where every other relevant object and function sits. The addresses differ on every run that is ASLR doing its job but the attack simply reads them straight out of a Set-Cookie header each time rather than guessing them.
Phase 7: From a leak to a shell (CVE-2026-109619)
The leak told the attacker where everything is. The second CVE turns that knowledge into a command running on the server. It works by reoccupying the freed memory not with data to read, but with a carefully forged object that hijacks PHP's own clean-up machinery.
Two ideas make it work. A destructor is a cleanup function PHP calls when it is finished with a value. A function pointer is a variable that stores the memory address of a function rather than ordinary data:
void (*function_pointer)();void (*function_pointer)();The exploit uses the dangling reference to make PHP interpret attacker-controlled memory as a legitimate internal structure called a HashTable. Inside that forged structure is a field named pDestructor, which normally points at a cleanup function. The exploit makes it point at system() instead the C function that executes operating-system commands.
This is where defeating ASLR pays off. Because the exploit leaked the libphp base, it can compute the exact address of system():
system address = libphp base + system offsetsystem address = libphp base + system offsetWhen PHP finishes the request and performs cleanup, it encounters the forged structure and tries to call its destructor. Instead of the legitimate cleanup routine, it calls system() with attacker-controlled data and the command runs under the privileges of the web-server user.
Run with no command argument, the exploit performs the whole chain and proves execution by running id on the target.
How to fix it
The only complete fix is to patch the PHP runtime itself. Update the PHP package your distribution ships, or the base image your container is built from, to 8.5.12, 8.4.27, 8.3.36 or 8.2.35 then restart every worker, so no process keeps running the old code.
Until you can patch, several interim measures reduce exposure. The PHP team is clear that none is a complete substitute for patching:
- Disable the trigger: set
session.upload_progress.enabled = 0and restart all workers. This removes the entry point for most of the reported techniques. - Disable the opcode cache:
opcache.enable = 0frustrates the code-execution path. - On PHP 8.5:
fatal_error_backtraces = 0addresses CVE-2026-109619 specifically. - Block delivery at the edge: reject
multipart/form-datarequests at your proxy or WAF at the cost of breaking legitimate file uploads. - Least privilege: run the PHP process with minimal rights so that a successful chain gains as little as possible.
Thanks for reading. If this was useful, follow for more deep dives into real-world vulnerabilities and let me know in the comments which chain you want broken down next.