PHP2Shell: Dissecting the Memory Overloads Behind PHP’s Critical 9.2 RCE Vulnerabilities
Two memory-corruption flaws in PHP's error-handling path let an unauthenticated attacker trigger an out-of-memory condition during request parsing, leaving dangling pointers that a second request can overwrite with attacker-controlled data. This could allow remote code execution on servers running default PHP configurations.
Published on medium.com
Cybersecurity
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
PHP2Shell is the collective name given to two critical remote code execution (RCE) vulnerabilities in PHP, tracked as CVE-2026-109618 and CVE-2026-109619, both rated CVSS 9.2. They were publicly disclosed on October 21, 2026, and the write-up states they are actively being exploited in the wild. The flaws sit in PHP's error-handling path rather than in any application feature: they are triggered through PHP's handling of out-of-memory (OOM) conditions during request parsing, and they bypass authentication entirely. The affected range is stated as PHP 5.4 through 8.5 in its default configuration.
The two CVEs form a chain. CVE-2026-109618 is the memory-corruption primitive (a use-after-free / dangling-pointer condition created when PHP aborts a request via longjmp()), and CVE-2026-109619 is the step that turns that corrupt state into arbitrary code execution.

Setup
The write-up does not describe a lab, a target application, accounts, roles or tooling used to reproduce the issue. It is an analysis of the disclosed vulnerabilities and a remediation guide, not a walkthrough of a live test. The only environmental facts given are the affected PHP versions (5.4 through 8.5, default configuration) and the patched releases named in the hunting section (PHP 8.1.31, 8.2.25, 8.3.13, 8.4.1 and later security releases from late October 2026).
Finding it
The author frames the discovery around a design decision in the Zend Engine, the C-based core of PHP. To stop a runaway script from consuming all system resources, PHP enforces a per-request memory_limit (the example given is 128M). When that limit is hit, PHP does not unwind the stack gracefully. Historically it uses the C-level setjmp() and longjmp() functions to perform an abrupt "abnormal termination" back to an earlier checkpoint.
The observation that makes this dangerous is that longjmp() bypasses the standard stack unwinding and memory cleanup code that a normal return would run. If the OOM happens while PHP is in the middle of parsing something, the structures on the stack are only partially initialised, and internal pointers that should reference active request objects are left dangling. The author describes this as the point where a resource-exhaustion condition becomes a memory-corruption condition.

Exploitation
Step 1: Force an out-of-memory condition during parsing
The attacker sends a request designed to exhaust the per-request memory limit while PHP is inside a parsing routine. The write-up names the relevant contexts: raw multipart/form-data upload headers, session variables, heavy serialisation, upload progress tracking, and heavily parsed custom HTTP payloads. When the limit is reached in one of these paths, PHP raises a fatal OOM error and triggers longjmp() to escape without crashing the whole web-server process.

Because the jump skips cleanup, variables, arrays and objects on the stack are left partially initialised, and crucial internal pointers are left dangling. The attacker's goal at this stage is simply to make the allocator (Zend MM) skip cleaning the allocated request memory: the metadata for those objects continues to exist while the system believes the memory has been freed. That is the use-after-free condition of CVE-2026-109618.
Step 2: Reclaim the abandoned memory with a second request
The attacker sends a secondary request back-to-back with the first. If the heap can be groomed, or the second payload can be loaded into the memory slots where the dangling pointers reside, the new data overlays the corrupt state. The write-up describes filling the abandoned memory block with shellcode or function pointers, specifically hijacking zend_executor or zval types.
Step 3: Trigger a dereference to obtain code execution
With the PHP environment operating in the compromised state, calling standard built-in functions causes pointer dereferences of the attacker's data. That is the arbitrary execution step of CVE-2026-109619: the attacker commands the server and obtains a shell without ever logging in.
The write-up does not include the raw HTTP requests, payloads or exploit strings used in either step. It describes the mechanism and the classes of input that reach it, but the concrete bytes are not published here.
Root cause
The mistake is architectural rather than application-level. PHP's use of longjmp() for abnormal termination means an OOM during parsing abandons the request mid-flight without running the cleanup that would normally release or reset partially built structures. The allocator is left believing memory has been freed while object metadata still exists, producing dangling pointers. A subsequent request can then occupy that memory and have its contents treated as trusted internal data.
The write-up is explicit that fixing application code will not solve it, since the flaw resides in the language runtime.
Impact
The write-up characterises the impact as follows:
- Zero authentication required. An HTTP POST request with heavy or malformed headers is described as sufficient to overwhelm PHP.
- Arbitrary code execution. The attacker obtains a shell on the server.
- Massive scope. PHP 5.4 through 8.5 are affected, and the author notes PHP powers "nearly 75%+" of active web technologies, with older legacy builds especially exposed.
- Active exploitation. Exploit strings and automated tooling are stated to be in active use, with adversaries mapping open upload endpoints, mass serialisation scripts and OOM targets.
These claims are the author's assessment; the write-up does not provide telemetry or incident data behind them.
Fix
The primary fix is to upgrade PHP. The write-up gives PHP 8.1.31, 8.2.25, 8.3.13 and 8.4.1 as examples of releases with critical security fixes deployed in late October 2026, and treats anything below them as highly suspected of being vulnerable. Updates should come from the distribution package manager or by compiling the latest security release, and php-fpm, mod_php and CLI environments must be restarted afterwards.


Where patching is not immediately possible, the write-up recommends constraining inputs to remove the OOM triggers:
- Lower
max_input_varsand limit multipart POST sizes. Cap the size of unauthenticated POST requests in the reverse proxy (Nginx or Apache) or withinphp.ini.

- Disable session upload progress if the application does not rely on tracking upload progress.

- Tune memory and time limits. Set a more restrictive server-level memory limit, or configure
max_execution_timeso scripts abort on time rather than accumulating bulk payload buffers. - Deploy WAF signatures that filter POST requests carrying hundreds of multipart form structures, repeating headers, or abnormal payloads targeting binary patterns.
Variants to test
The write-up's hunting guidance translates into concrete checks on other targets:
- Version detection. Query PHP configurations and compare against the patched releases (8.1.31, 8.2.25, 8.3.13, 8.4.1 and later). A positive result is any release below those versions, which the author treats as highly suspected of being vulnerable.
- Crash-log analysis. Inspect Apache
error.log, Nginxerror.logandphp-fpm.logfor abrupt crash dumps, segfaults, or recurrent OOM errors in short intervals. Positive indicators areAllowed memory size of X bytes exhaustedfollowed immediately by a server crash or reload, and kernel segfault notices such asphp-fpm[...] general protection fault ... in libc / php. - Behavioural scanning. Look for heavy requests targeting
upload_progressor high-volume multipart uploads, especially with thousands of file inputs or extremely long field names designed to blow out chunk memory parsing. The write-up describes these patterns as the kind of traffic to look for.

What happened, in plain words
On 21 October 2026, two serious security bugs in PHP were made public. PHP is the programming language behind a large share of active web technologies. The two bugs were given the joint nickname PHP2Shell and the official tracking numbers CVE-2026-109618 and CVE-2026-109619. Both were rated CVSS 9.2, which is near the top of the severity scale.
A "remote code execution" bug, usually shortened to RCE, is the worst kind of web bug. It means someone on the internet, with no account and no password, can make the server run commands of their choosing. In this case the write-up says attackers can get a shell: an interactive command line on the server, as if they were sitting at its keyboard.
The bugs are not in any particular website's code. They are in PHP itself, in the part that handles errors. The write-up says they are already being exploited in the wild, that they need no login at all, and that almost any PHP version from 5.4 through 8.5 in its default configuration is likely affected.

The article is laid out in five parts: a plain-language explanation, a technical explanation, a risk assessment, guidance on how to check whether your own systems are exposed, and finally how to patch and defend them. This version follows the same order and explains each idea from scratch as it appears.
Part 1: The restaurant kitchen comparison
Before any technical detail, the write-up asks you to picture your PHP server as a busy restaurant kitchen.
- Customers are web users. They send orders, which are HTTP requests: the messages your browser sends to a website every time you click a link or submit a form.
- Kitchen staff are PHP-FPM worker processes. A worker process is a small program the web server keeps running to handle one request at a time. A busy site has several, so several visitors can be served at once.
- Each worker has a prep station, which in computing terms is memory: the workspace where the program keeps the data it is currently working on.
- The manager's rule is PHP's
memory_limit. This is a cap, set per request, on how much memory one request may use. The write-up gives 128M (128 megabytes) as an example. If a request tries to use more, PHP stops it rather than letting it eat all the server's resources.
The rule works like this: if any single order uses more than $100 worth of ingredients or counter space, hit the emergency stop buzzer, abandon the ticket and move on to the next customer. In normal life this is sensible: one bad request cannot take the whole kitchen down.
Now an attacker arrives. They do not want dinner. They want to take over the kitchen. The write-up walks through four stages:
- The overload. The attacker submits a monstrous, nonsensical order: dice 50,000 onions, whip 400 soufflés, and track the progress of every single chop on a whiteboard. In web terms, they send a request built to be enormously expensive to process.
- The panic bailout. Halfway through, the chef hits the $100 limit. The buzzer sounds, and following the rule, the chef drops everything and jumps back to the counter for the next order. In PHP terms, the request is aborted mid-flight.
- The fatal flaw. Because the chef left in a panic, they skipped the cleanup. Half-chopped ingredients are still on the board, and the kitchen's master clipboard still has a sticky note pointing at the middle of that board saying "Trusted Chef Instructions Here". In computing terms, the memory was never properly wiped, but internal records still point into it and still treat it as trustworthy.
- The hijack. The attacker immediately sends a second, tiny order. The chef puts the new ingredients on the same dirty board, and the attacker's note lands right under the "Trusted Chef Instructions" pointer. The chef reads it, obeys it, and hands over the keys to the restaurant. In computing terms, the attacker's data is now sitting where the program expects its own instructions, so the program runs the attacker's code.
That is the whole bug in one picture: PHP ran out of memory, jumped out of the current job to stay alive, and forgot to wipe the slate clean before the next request. The write-up calls the result arbitrary code execution: the attacker commands the server and gets a shell without ever logging in.

Part 2: Under the bonnet
This part looks inside the Zend Engine, the C-based core of PHP. C is a lower-level programming language, and PHP is written in it. "Core" means this is the machinery underneath every PHP website, not something a website developer writes.
The root cause: running out of memory and longjmp()
As above, PHP enforces a per-request memory_limit (the example is 128M) so that one runaway script cannot consume all system resources.
Historically, PHP uses two standard C functions, setjmp() and longjmp(), to handle "abnormal termination": errors, and out-of-memory events in particular. Think of setjmp() as placing a bookmark in a book, and longjmp() as slamming the book shut and jumping straight back to that bookmark, skipping every page in between. Normally, if PHP hits the memory limit while processing raw multipart/form-data upload headers, session variables or heavy serialisation, it raises a fatal OOM (out of memory) error. To escape without crashing the entire web-server process, it triggers longjmp().

Memory corruption (CVE-2026-109618)
longjmp() is an abrupt teleport of the CPU's execution state back to an earlier checkpoint. The important word is abrupt: it bypasses the standard stack unwinding and memory cleanup code that would normally run during a graceful return. Stack unwinding is the tidy process of closing out a function call, releasing what it allocated and restoring what came before. Skipping it is like leaving a shop without paying and without the till being reconciled.
When an OOM happens during multipart POST parsing or upload progress tracking, the variables, arrays and objects on the stack are only partially initialised. Pointers are the key idea here: a pointer is a small value that says "the real data lives at this address in memory", much like a house number rather than the house itself. If the data a pointer refers to is gone but the pointer still exists, it is called dangling. The write-up says crucial internal pointers, which should point to active request objects, are left dangling.
The attacker forces the OOM, which causes PHP's memory allocator, Zend MM, to skip cleaning the allocated request memory. The allocator is the part of the program that hands out and reclaims memory. The metadata for those objects continues to exist, while the system thinks the memory is freed. That combination is a classic use-after-free (UAF), or memory-corruption condition: the program keeps using memory it has officially given back.
Arbitrary execution (CVE-2026-109619)
If the heap can be groomed, or a subsequent request's payload can be strategically loaded into the memory slots where those dangling pointers reside, the attacker can overlay a new payload onto the corrupt state. Heap grooming means arranging memory allocations deliberately, the way you might shuffle boxes in a storeroom so that the next delivery lands in exactly the spot you want.
By sending a secondary request back-to-back, the attacker fills the now abandoned memory block with shellcode or function pointers, hijacking zend_executor or zval types. Shellcode is a small piece of machine code whose job is to start a shell. A function pointer is a stored address saying "when this action is needed, run the code at this address". zend_executor and zval are internal PHP structures: the executor is the part that runs PHP code, and a zval is the container PHP uses to hold a single value. Because the PHP environment is now operating in a compromised state, calling standard built-in functions triggers pointer dereferences of the attacker's data, handing over remote code execution. A dereference is following a pointer to the data it names; if the attacker controls that address, the program follows it straight into the attacker's code.
Part 3: Risk and impact
The write-up assesses the risk in three points:
- High likelihood and zero authentication. The attacker does not need to be logged in. An HTTP POST request with heavy or malformed headers is all it takes to overwhelm PHP. A POST request is the kind your browser sends when you submit a form; it carries data in the body rather than in the address.
- Massive scope. PHP versions 5.4 through 8.5 are affected. The author notes PHP powers nearly 75%+ of active web technologies, especially older systems running legacy builds, which makes this an expansive attack surface. Attack surface means the total set of places an attacker could try to get in.
- Weaponised exploitations. Exploit strings and automated tooling are already in active use. Adversaries are actively mapping out open upload endpoints, mass serialisation scripts and OOM targets. An endpoint is a specific address on a server that accepts requests, such as an upload form. Serialisation is turning a data structure into a stream of bytes so it can be stored or sent, and it is expensive to process, which is why it is a useful way to trigger the memory overload.
These are the author's assessments; the write-up does not include telemetry or incident data behind them.
Part 4: How to check whether you are exposed
The write-up gives three practical checks for your own systems.
1. Version detection
Find out which PHP version you are running and compare it with the patched releases.

Any release below the newly patched security versions is highly suspected of being vulnerable. The write-up names the fixes deployed in late October 2026, giving PHP 8.1.31, 8.2.25, 8.3.13 and 8.4.1 as examples. The logic is simple: if your number is lower than the fixed number for your branch, the author treats it as highly suspected of being vulnerable.
2. Analysing crash logs
Check your web server logs: Apache error.log, Nginx error.log, or php-fpm.log. A log is a file where a program writes a line every time something notable happens, good or bad. Look for abrupt crash dumps, segfaults, or recurrent out-of-memory errors occurring within short intervals. A segfault (segmentation fault) is the operating system killing a program because it tried to touch memory it is not allowed to touch; it is a strong sign of memory corruption. The write-up lists these indicators:
Allowed memory size of X bytes exhaustedfollowed immediately by a server crash or reload.- Kernel segfault notices related to PHP binaries:
php-fpm[...] general protection fault ... in libc / php.
The first line is PHP's own message that it hit the memory cap. Seeing it followed straight away by a crash or restart is the pattern the author flags. The second is the operating system reporting that a PHP process made an illegal memory access.
3. Behavioural scans
Look for heavy requests targeting upload_progress or using high-volume multipart uploads, especially with thousands of file inputs or extremely long field names designed to blow out chunk memory parsing. upload_progress is a PHP feature that lets a site track how far along an upload is. Multipart is the format a browser uses to send a form that includes files, splitting the data into labelled parts. A request with thousands of parts, or absurdly long field names, is exactly the kind of input that drives memory use up during parsing.
Part 5: Patching and remediation
Because the flaw lives in the language runtime, fixing your application code will not solve it. The primary line of defence is upgrading PHP.
Action 1: Apply PHP security patches (critical)
Update your PHP installation directly from your distribution package manager, or compile the latest security release. A package manager is the tool that installs and updates software on a server, such as apt on Ubuntu or dnf on RHEL. Compiling means building the program from its source code yourself.
Ubuntu / Debian:

RHEL / AlmaLinux:

After updating, make sure php-fpm, mod_php and CLI environments are restarted. php-fpm is the worker process pool described earlier, mod_php is the older way of running PHP inside the Apache web server, and the CLI is the command-line version of PHP. Restarting matters because a running process keeps using the old, vulnerable code until it is replaced.
Action 2: Temporary mitigations if you cannot patch immediately
If legacy infrastructure prevents an immediate upgrade, heavily constrain inputs to mitigate the OOM triggers. Mitigate means reduce the risk without removing the cause.
- Lower
max_input_varsand limit multipart POST sizes.max_input_varsis a PHP setting that caps how many form fields one request may contain. Limit the size of unauthenticated POST requests in your reverse proxy (Nginx or Apache) or withinphp.ini. A reverse proxy is the server sitting in front of your application that receives visitors' requests first;php.iniis PHP's main configuration file.

- Mitigate session upload progress hazards. If your application does not rely on tracking upload progress, turn it off. A session is the server's way of remembering who you are between requests, usually via a cookie, which is a small piece of data your browser stores and sends back.

-
Memory limit alerting and tuning. Set a more restrictive server-level limit, or configure
max_execution_timeso scripts abort based on time rather than accumulating bulk payload buffers.max_execution_timeis the cap on how many seconds a script may run. -
Deploy WAF signatures. A WAF (web application firewall) inspects incoming traffic and blocks patterns that look malicious; a signature is a rule describing such a pattern. Filter POST requests that carry hundreds of multipart form structures, repeating headers, or abnormal payloads targeting binary patterns.
The write-up closes by noting that even decades-old parsing handlers and core cleanup strategies like longjmp are susceptible to the demands of modern web inputs, and invites readers to share edge cases with FPM or older builds. It also offers a possible Part 2: a hands-on lab that spins up a vulnerable setup, traces the raw HTTP payloads in Burp Suite (a tool for intercepting and editing web traffic), and watches the dangling pointers corrupt the Zend heap in real time.
Glossary
- PHP: the programming language that runs a large share of websites; the bugs here are in PHP itself, not in any one site.
- PHP2Shell: the nickname given to the two vulnerabilities together.
- CVE: a public catalogue number for a known security vulnerability; CVE-2026-109618 and CVE-2026-109619 are the two here.
- CVSS: a scoring system for how severe a vulnerability is; 9.2 is near the top.
- RCE (remote code execution): a bug that lets an attacker make a server run their own commands from afar.
- Shell: an interactive command line on a server, as if you were sitting at its keyboard.
- HTTP request: the message a browser sends to a website when you load a page or submit a form.
- POST request: a request that carries data in its body, typically from a form submission.
- PHP-FPM: the pool of worker processes that handle PHP requests on a web server.
- Worker process: a small program that handles one request at a time; several run in parallel.
- Memory: the workspace where a running program keeps the data it is currently using.
memory_limit: PHP's per-request cap on how much memory one request may use.- OOM (out of memory): the condition where a program hits its memory cap.
- Zend Engine: the C-based core of PHP that executes PHP code.
- C: a low-level programming language; PHP is written in it.
setjmp()/longjmp(): C functions that place a checkpoint and later jump back to it abruptly, skipping normal cleanup.- Abnormal termination: ending a request through an error path rather than a normal finish.
- Stack unwinding: the tidy process of closing out a function call and releasing what it allocated.
- Pointer: a value that says where in memory the real data lives, like a house number rather than the house.
- Dangling pointer: a pointer that still exists but refers to data that has been freed.
- Memory allocator (
Zend MM): the part of PHP that hands out and reclaims memory. - Metadata: bookkeeping data about an object, as opposed to the object's contents.
- Use-after-free (UAF): using memory that the program has officially given back.
- Memory corruption: a state where memory contents no longer match what the program expects.
- Heap: the area of memory used for data allocated while a program runs.
- Heap grooming: deliberately arranging memory allocations so a later payload lands in a chosen spot.
- Shellcode: a small piece of machine code whose job is to start a shell.
- Function pointer: a stored address saying which code to run for a given action.
zend_executor: the internal PHP structure that runs PHP code.zval: the internal PHP container that holds a single value.- Dereference: following a pointer to the data it names.
multipart/form-data: the format browsers use to send forms that include files, split into labelled parts.- Serialisation: turning a data structure into a stream of bytes for storage or transport; expensive to process.
- Session: the server's way of remembering who you are between requests.
- Cookie: a small piece of data your browser stores and sends back to a site.
upload_progress: a PHP feature that tracks how far along an upload is.- Endpoint: a specific address on a server that accepts requests, such as an upload form.
- Attack surface: the total set of places an attacker could try to get in.
- Log: a file where a program records notable events.
- Segfault: the operating system killing a program because it touched memory it is not allowed to touch.
max_input_vars: a PHP setting capping how many form fields one request may contain.max_execution_time: a PHP setting capping how many seconds a script may run.php.ini: PHP's main configuration file.- Reverse proxy: the server in front of your application that receives visitors' requests first, such as Nginx or Apache.
- Package manager: the tool that installs and updates software on a server.
php-fpm,mod_php, CLI: the three ways PHP can run: as a worker pool, inside Apache, or from the command line.- Mitigate: reduce risk without removing the underlying cause.
- WAF (web application firewall): a filter that inspects incoming traffic and blocks malicious patterns.
- Signature: a rule describing a malicious pattern for a WAF to match.
- Burp Suite: a tool for intercepting and editing web traffic, mentioned for the proposed hands-on lab.