Skip to content
Memory corruption Write-up Advanced

PHP2Shell: How a Core Runtime Zero-Day Broke the Web (CVE-2026–109618 & CVE-2026–109619)

A pair of memory-corruption bugs in the PHP core engine could be triggered by crafted multipart HTTP requests, leaving stale pointers in long-lived worker processes. An unauthenticated attacker could then reuse that corrupted state to hijack execution and run commands as the web server user.

Suraj Prajapati Follow

Published on medium.com

Php Developers

Suraj Prajapati, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

PHP2Shell is the name researchers gave to a pair of vulnerabilities tracked as CVE-2026-109618 and CVE-2026-109619. Unlike the PHP bugs that usually make the news, these do not live in application code, a framework or a plugin. They sit in the PHP core C engine itself, in the way the Zend Engine manages memory and process lifecycles around request parsing.

The practical consequence, as described in the write-up, is unauthenticated remote code execution. The author states that the flaw affects nearly every standard process execution architecture: PHP-FPM, Apache mod_php, php-cgi, LiteSpeed and FrankenPHP. Because PHP still powers roughly 70%+ of all internet websites, the affected population includes WordPress, Drupal, Magento, Laravel, Symfony and bespoke in-house applications alike. The only precondition given is that the web server invokes an unpatched PHP worker process.

php From the original on medium.com

The write-up was published on 21 October 2026 and describes the situation in the first 24 hours after the vulnerabilities became public, when government portals, e-commerce platforms and enterprise infrastructures were reportedly scrambling to deploy emergency patches or take public-facing forms offline.

Setup

There are no accounts, roles or special tooling in this write-up. The attack path it describes is unauthenticated: no account, no active session and no administrative dashboard are needed. The only precondition is a reachable server running an unpatched PHP version where PHP accepts incoming HTTP traffic, whether public or internally accessible.

The author lists the emergency out-of-cycle releases published by the PHP Group across all actively supported branches:

Branch Patched release
PHP 8.5 8.5.12
PHP 8.4 8.4.27
PHP 8.3 8.3.36
PHP 8.2 8.2.35

Branches such as PHP 8.1, 8.0 and earlier are officially End-of-Life, and the PHP Foundation has not released upstream patches for them. Organisations on those versions depend entirely on operating system vendor backports, such as Ubuntu ESM or RHEL Extended Life Cycle Support, or on manual enterprise mitigations.

Finding it

The write-up does not describe a discovery process, a testing session or a specific target. It presents the flaw analytically, contrasting it with the PHP vulnerabilities usually seen in the wild: SQL injection, unsafe deserialisation and directory traversal, which stem from poorly written custom code, insecure framework configurations or vulnerable third-party plugins. PHP2Shell is different because application code does not matter. A codebase can be bug-free, heavily audited and free of user-input vulnerabilities and still be exposed, because the defect is in the runtime that executes it.

Exploitation

Step 1: Trigger an abort during multipart parsing

When a web server processes an incoming HTTP POST request, specifically complex multipart/form-data payloads with large headers or file boundaries, PHP tracks resource consumption against its configured memory ceilings. If a payload triggers an unexpected out-of-memory condition or an uncaught fatal parse error, the Zend Engine does not gracefully walk back up the standard C call stack. Instead it relies on low-level non-local jumps via longjmp() to abort the execution thread and reset the request environment.

The write-up does not include a concrete payload for this step.

Step 2: Exploit the incomplete reset

When longjmp() fires during certain phases of multipart parsing and session upload tracking, the cleanup is incomplete:

  1. Dangling pointers. Destruction routines for allocated hashtables, OPcache structures and upload metadata are bypassed or only partially completed.
  2. Persistent worker pollution. Worker processes such as PHP-FPM pool workers do not terminate after a single request. They remain resident in memory to service subsequent incoming requests.
  3. Use-after-free. The aborted cleanup leaves stale memory references and corrupted heaps in the persistent worker process.

Step 3: Re-enter the tainted worker and take control

When the subsequent HTTP request reaches that same tainted worker process, the Zend Engine attempts to reference what it expects to be clean global runtime state. Instead it reads the remnants of the attacker's previous payload. By carefully manipulating the allocation layout, aligning forged Zend internal structs with executable memory pages, the attacker gains control of the instruction pointer ($RIP), pivots into shellcode and spawns an arbitrary reverse shell under the privileges of the web process (www-data, nginx or apache).

The write-up does not include the second request, the forged structures or the shellcode.

Root cause

The mistake is in the runtime's error handling, not in any application. The Zend Engine aborts a request with longjmp() rather than unwinding the C call stack, and during certain phases of multipart parsing and session upload tracking the destruction routines for hashtables, OPcache structures and upload metadata are skipped or only partly run. Because workers are long-lived and reused across requests, the stale references and corrupted heap survive into the next request handled by the same worker, producing a use-after-free that the attacker can shape into control of $RIP.

What it does make clear is why ordinary application-level defences do not help: input validation, framework hardening and code review all operate above the layer where the corruption happens.

Impact

The write-up says the paired vulnerabilities allow unauthenticated attackers to achieve complete remote code execution, whatever application runs on the server. The shell runs with the privileges of the web process, named in the write-up as www-data, nginx or apache. The author describes the reach as millions of production servers, including government portals, major e-commerce platforms and enterprise infrastructures, and notes that the affected architectures cover PHP-FPM, Apache mod_php, php-cgi, LiteSpeed and FrankenPHP.

Fix

The real fix is to upgrade PHP to one of the patched releases listed above. The write-up gives these commands for checking the installed version and upgrading.

Check the current version:

Bash
php -v

Ubuntu / Debian:

Bash
sudo apt update && sudo apt --only-upgrade install php*-fpm php*-cli
sudo systemctl restart php*-fpm
sudo systemctl restart nginx

RHEL / AlmaLinux / Rocky Linux:

Bash
sudo dnf upgrade php php-fpm
sudo systemctl restart php-fpm

If patching today is not possible, for example on mission-critical legacy applications, change-frozen production systems or complex deployment pipelines, the write-up offers three stop-gap mitigations.

1. Disable upload progress. One of the primary vectors relies on global session tracking during multipart uploads, so disable upload progress monitoring in every php.ini configuration:

INI
; In /etc/php/*/fpm/php.ini and /etc/php/*/cli/php.ini
session.upload_progress.enabled = 0

Reload or restart the PHP-FPM daemon for the change to take effect.

2. Restrict multipart payloads at the reverse proxy. If public endpoints do not require file uploads, reject or heavily constrain multipart/form-data traffic at the Nginx or Cloudflare edge. Example Nginx snippet:

NGINX
if ($http_content_type ~* "multipart/form-data") {
    return 403;
}

3. Adjust memory limits on FPM pools. Because the bug is triggered by forced OOM abort routines during request parsing, temporarily lifting hard-stop memory ceilings or adjusting process recycling intervals helps force workers to cycle down before an exploit chain can stabilise in persistent memory. The write-up gives pm.max_requests = 100 or lower as the setting.

Beyond patching, the author recommends keeping runtimes minimal and jailed through Docker, systemd sandboxing or read-only filesystems, and running web workers with the lowest possible OS privileges.

Variants to test

  1. Inventory PHP versions across every host that accepts HTTP traffic. Run php -v on each server and compare against 8.5.12, 8.4.27, 8.3.36 and 8.2.35. A positive result is any host below the patched release for its branch, or on an EOL branch without vendor backports.
  2. Enumerate the execution architecture. Check whether the host runs PHP-FPM, Apache mod_php, php-cgi, LiteSpeed or FrankenPHP. A positive result is any of these serving requests with an unpatched PHP binary.
  3. Check session.upload_progress.enabled in every php.ini.
  4. Test whether the edge rejects multipart/form-data. Send a multipart POST to an endpoint that does not need uploads.
  5. Review FPM pool recycling. Check pm.max_requests on each pool.
  6. Confirm worker privileges. Check the OS user behind each worker.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

In October 2026, two serious bugs in PHP, the software that runs a very large share of the websites on the internet, became public. The bugs were given the official tracking numbers CVE-2026-109618 and CVE-2026-109619, and the researchers nicknamed the pair PHP2Shell. A CVE number is simply a public catalogue entry: a way for everyone to refer to the same flaw without confusion.

What makes these bugs unusual is where they live. Most PHP security stories are about mistakes in the code a developer wrote: a badly built login form, an out-of-date plugin, a query that lets a stranger read the database. PHP2Shell is not that. The mistake is inside PHP itself, in the engine that every PHP website relies on. That means a website can be written perfectly and still be exposed, because the flaw is in the machinery underneath it, not in the pages it serves.

The practical result is that an attacker who has never logged in, has no account and has no special access can make the server run commands of their choosing. Security people call that remote code execution, or RCE: remote because it happens over the network, code execution because the attacker's instructions actually run on the machine. The author of the write-up describes the reach as millions of production servers, including government portals, major e-commerce platforms and enterprise systems, and says they were scrambling to deploy emergency patches or take public forms offline in the first 24 hours after the news broke.

php From the original on medium.com

The image is the article's header illustration, captioned simply php.

Why this one is different

To see why PHP2Shell matters, it helps to know what PHP is. PHP is a programming language used mostly on web servers. When you load a page, the server runs a PHP program, which builds the page and sends it back to your browser. WordPress, Drupal, Magento, Laravel and Symfony, all popular tools for building sites and shops, are written in PHP, and so are countless custom in-house applications. The write-up puts PHP's share at roughly 70% or more of all internet websites.

The author contrasts PHP2Shell with the PHP bugs usually seen in the wild: SQL injection, unsafe deserialisation and directory traversal. These come from poorly written custom code, insecure framework configurations or vulnerable third-party plugins. In plain terms:

  • SQL injection is when a site pastes what you typed into a database query without cleaning it, so clever input can make the database do something else.
  • Unsafe deserialisation is when a site turns stored data back into live objects without checking it, so a tampered file can turn into unexpected behaviour.
  • Directory traversal is when a site lets a request reach files outside the folder it should, for example by using ../ in a path.

All three are mistakes in the application. PHP2Shell is different in three ways the author spells out:

  1. Application code does not matter. Your code can be free of bugs, heavily reviewed and safe against user input, and you are still exposed.
  2. No authentication is required. The attacker needs no account, no active session and no admin dashboard. A session is the server's short-term memory of who you are after you log in, usually held in a cookie, a small piece of data your browser stores and sends back with each request. None of that is needed here.
  3. The impact is widespread. Any site whose web server hands a request to an unpatched PHP worker is in scope, whatever application it runs.

A worker is the part of the server that actually executes PHP for a request. The write-up says the flaw affects nearly every standard way of running PHP: PHP-FPM, Apache mod_php, php-cgi, LiteSpeed and FrankenPHP. These are different products that all do the same basic job, running PHP code when a request arrives. The only precondition the author gives is that the web server invokes an unpatched PHP worker process.

How the flaw works, step by step

To follow the attack you need two ideas from the world of C, the low-level language PHP is written in.

Memory is the server's working space. Programs ask the operating system for chunks of it, use them, and are supposed to give them back. A pointer is a note that says where a particular chunk lives. If a program keeps using a note after the chunk has been freed, that is a use-after-free: it is reading or writing memory that no longer belongs to it, and an attacker who can control what lands in that space can steer the program.

The call stack is how a program keeps track of which function called which. Normally, when something goes wrong deep inside, the program walks back up that stack, cleaning up as it goes. PHP's engine, called the Zend Engine, sometimes does not do that. Instead it uses a shortcut called longjmp(), which jumps straight out of the deep function back to a safe point, skipping the cleanup in between. Think of it as leaving a building through the fire escape while leaving the lights on, the taps running and the doors unlocked.

Step 1: Trigger an abort during multipart parsing

When a browser sends a form that includes a file, it uses a format called multipart/form-data. The request is split into parts, each with headers and a body, separated by a boundary string. While handling such a request, PHP keeps an eye on how much memory it is using against a configured ceiling. If a payload pushes it into an unexpected out-of-memory condition, or causes an uncaught fatal parse error, the Zend Engine aborts the request with longjmp() rather than unwinding the stack properly.

The write-up does not include a concrete payload for this step. What it does say is that the trigger involves complex multipart/form-data payloads with large headers or file boundaries.

Step 2: Exploit the incomplete reset

When longjmp() fires during certain phases of multipart parsing and session upload tracking, the cleanup is incomplete. The author lists three consequences:

  1. Dangling pointers. The routines that should destroy allocated hashtables, OPcache structures and upload metadata are skipped or only partly run. A hashtable is a lookup structure that maps keys to values. OPcache is PHP's built-in cache of compiled code, kept in memory to save work. Upload metadata is the bookkeeping about files being uploaded. All of these are left half-destroyed.
  2. Persistent worker pollution. Worker processes such as PHP-FPM pool workers do not shut down after one request. They stay in memory and serve the next request, and the next. So the mess left behind does not disappear with the request.
  3. Use-after-free. The aborted cleanup leaves stale memory references and a corrupted heap in that long-lived worker. The heap is the general-purpose pool of memory a program allocates from at runtime.

Step 3: Re-enter the tainted worker and take control

When the next HTTP request reaches that same tainted worker, the Zend Engine tries to read what it believes is clean global runtime state. Instead it reads the leftovers of the attacker's previous payload. By carefully arranging how memory is allocated, and lining up forged Zend internal structures with memory pages that can be executed, the attacker gains control of the instruction pointer, written $RIP. The instruction pointer is the CPU's bookmark: it says which instruction to run next. Control it, and you decide what the machine does.

From there the attacker pivots into shellcode, a small piece of machine code written to do one job, and spawns an arbitrary reverse shell. A reverse shell is a connection from the victim server back to the attacker, giving the attacker a command prompt on the machine. It runs with the privileges of the web process, named in the write-up as www-data, nginx or apache. Those are the low-privilege operating system accounts web servers typically use.

The write-up does not include the second request, the forged structures or the shellcode.

Am I vulnerable?

You are vulnerable if you run any unpatched PHP version on a public or internally accessible server where PHP accepts incoming HTTP traffic. The author lists the emergency out-of-cycle releases published by the PHP Group across all actively supported branches:

Branch Patched release
PHP 8.5 8.5.12
PHP 8.4 8.4.27
PHP 8.3 8.3.36
PHP 8.2 8.2.35

Branches such as PHP 8.1, 8.0 and earlier are officially End-of-Life, meaning the PHP project no longer supports them. The PHP Foundation has not released upstream patches for those versions. Organisations still on them depend entirely on backports from their operating system vendor, such as Ubuntu ESM or RHEL Extended Life Cycle Support, or on manual enterprise mitigations. A backport is when a vendor takes a fix written for a newer version and adapts it to an older one it still supports.

How to fix it

Step 1: Upgrade PHP (the real fix)

First, check which version is installed. The command below asks PHP to print its version:

Bash
php -v
  • php is the program.
  • -v is a flag meaning version.
  • The output tells you the exact release, which you compare against the table above.

On Ubuntu or Debian, update the package lists, upgrade only the PHP packages, then restart the PHP service and the web server:

Bash
sudo apt update && sudo apt --only-upgrade install php*-fpm php*-cli
sudo systemctl restart php*-fpm
sudo systemctl restart nginx
  • sudo runs the command with administrator rights.
  • apt update refreshes the list of available packages.
  • && means run the next command only if this one succeeds.
  • apt --only-upgrade install installs newer versions of packages already present, without adding new ones.
  • php*-fpm and php*-cli are patterns matching the PHP packages for the web server and the command line.
  • systemctl restart stops and starts a service so the new code is loaded.
  • php*-fpm is the PHP service, and nginx is the web server in front of it.

On RHEL, AlmaLinux or Rocky Linux, the equivalent is:

Bash
sudo dnf upgrade php php-fpm
sudo systemctl restart php-fpm
  • dnf upgrade installs newer versions of the named packages.
  • php is the language package and php-fpm is the worker service.
  • The restart makes the running service pick up the new binaries.

Step 2: Temporary mitigations if you cannot patch today

The author offers three stop-gap defences for mission-critical legacy applications, change-frozen production systems or complex deployment pipelines that cannot be updated in the next hour.

1. Disable upload progress. One of the primary vectors relies on global session tracking during multipart uploads, so turn off upload progress monitoring in every php.ini configuration. php.ini is PHP's main settings file.

INI
; In /etc/php/*/fpm/php.ini and /etc/php/*/cli/php.ini
session.upload_progress.enabled = 0
  • The line starting with ; is a comment, a note for humans that PHP ignores. It tells you which files to edit.
  • session.upload_progress.enabled is the setting that tracks upload progress through the session.
  • = 0 turns it off.

Reload or restart the PHP-FPM daemon for the change to take effect.

2. Restrict multipart payloads at the reverse proxy. A reverse proxy is the server that sits in front of your application and forwards requests to it, such as Nginx or Cloudflare. If your public endpoints do not need file uploads, reject or heavily constrain multipart/form-data traffic there. The example Nginx snippet is:

NGINX
if ($http_content_type ~* "multipart/form-data") {
    return 403;
}
  • if (...) starts a condition.
  • $http_content_type is the request's Content-Type header, which says what kind of data is being sent.
  • ~* means match the following pattern case-insensitively.
  • "multipart/form-data" is the pattern being looked for.
  • return 403 sends back the HTTP status code for forbidden, refusing the request before it reaches PHP.

3. Adjust memory limits on FPM pools. Because the bug is triggered by forced out-of-memory abort routines during request parsing, temporarily lifting hard-stop memory ceilings or adjusting how often workers are recycled helps force workers to cycle down before an exploit chain can stabilise in persistent memory. The write-up gives pm.max_requests = 100 or lower as the setting. pm.max_requests is the number of requests a worker handles before it is replaced with a fresh one.

Beyond patching, the author recommends keeping runtimes minimal and jailed through Docker, systemd sandboxing or read-only filesystems, and running web workers with the lowest possible OS privileges.

Checks to run on your own servers

  1. Inventory PHP versions across every host that accepts HTTP traffic. Run php -v on each server and compare against 8.5.12, 8.4.27, 8.3.36 and 8.2.35. A positive result is any host below the patched release for its branch, or on an End-of-Life branch without vendor backports.
  2. Enumerate the execution architecture. Check whether the host runs PHP-FPM, Apache mod_php, php-cgi, LiteSpeed or FrankenPHP. A positive result is any of these serving requests with an unpatched PHP binary.
  3. Check session.upload_progress.enabled in every php.ini.
  4. Test whether the edge rejects multipart/form-data. Send a multipart POST to an endpoint that does not need uploads.
  5. Review FPM pool recycling. Check pm.max_requests on each pool.
  6. Confirm worker privileges. Check the OS user behind each worker.

Final thoughts

The author closes by calling PHP2Shell a reminder of the hidden fragility in the foundational plumbing of the web. When a bug bypasses application logic entirely and targets the underlying process lifecycle, defence in depth is the only real safety net: keep runtimes minimal and jailed, run web workers with the lowest possible OS privileges, and apply vendor patches immediately when runtime engine zero-days drop. A zero-day is a flaw that is exploited before the vendor has a fix available.

Glossary

  • Backport: a fix written for a newer version of software, adapted by a vendor to an older version it still supports.
  • Boundary: the separator string that marks where one part of a multipart request ends and the next begins.
  • Call stack: the program's record of which function called which, used to return and clean up in order.
  • Cookie: a small piece of data a browser stores for a site and sends back with later requests.
  • CVE: a public catalogue number for a known security flaw.
  • Dangling pointer: a note pointing at memory that has already been freed.
  • Defence in depth: layering several independent protections so one failure does not expose everything.
  • Directory traversal: a flaw that lets a request reach files outside the intended folder, often using ../.
  • End-of-Life (EOL): a version the project no longer supports or patches.
  • FrankenPHP: one of the products that runs PHP for web requests.
  • Hashtable: a lookup structure mapping keys to values.
  • Heap: the general-purpose pool of memory a program allocates from at runtime.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Instruction pointer ($RIP): the CPU's bookmark for the next instruction to run.
  • longjmp(): a C shortcut that jumps out of a deep function without unwinding the stack.
  • Memory: the server's working space, handed out to programs in chunks.
  • multipart/form-data: the request format used when a form includes a file.
  • Nginx: a web server and reverse proxy.
  • OPcache: PHP's in-memory cache of compiled code.
  • php.ini: PHP's main settings file.
  • PHP: a programming language used mostly on web servers.
  • PHP-FPM: a common way of running PHP workers for a web server.
  • php-cgi: another way of running PHP for web requests.
  • pm.max_requests: how many requests a worker handles before being replaced.
  • Pointer: a note saying where a chunk of memory lives.
  • Remote code execution (RCE): making a remote machine run instructions of your choosing.
  • Reverse proxy: a server in front of an application that forwards requests to it.
  • Reverse shell: a connection from the victim server back to the attacker, giving a command prompt.
  • Session: the server's short-term memory of who you are after you log in.
  • Shellcode: a small piece of machine code written to do one job.
  • SQL injection: a flaw where untrusted input changes a database query.
  • Unsafe deserialisation: a flaw where stored data is turned back into live objects without checking.
  • Use-after-free: using memory after it has been freed.
  • Worker: the part of the server that executes PHP for a request.
  • Zend Engine: the core engine that runs PHP code.
  • Zero-day: a flaw that is public before a fix is widely available.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.