← Back to the blog

// blog · Vulnerability analysis / PHP and web

PHP2Shell: critical RCE in the PHP core that shipped as an emergency fix

On 21 October the PHP team shipped emergency releases that fix two critical holes in the language engine itself. The flaws were named PHP2Shell together, and their numbers are CVE-2026-109618 and CVE-2026-109619. Both lead to remote code execution and both scored 9.2 on CVSS 4.0. This is not a single plugin or framework problem. The vulnerable code has been in PHP since version 5.4.0 from 2012, so a huge share of the world's web servers is in scope.

The name sounds alarming and the press took it literally. It is worth cooling the panic right away. The public exploits do not work against a default PHP install. To run them, an attacker usually needs an extra weakness on the application side or knowledge of a specific server state. That is no reason to delay the patch. CISA added both flaws to its actively exploited list, and Cloudflare saw the first attempts before the fix even reached the network.

Context and legality. This is educational material based on the PHP team's advisories and analysis by Sansec, Securelist and Patchstack. We do not publish a working exploit or instructions for using one. We describe the mechanism only as far as needed to understand the risk and patch correctly. Testing systems you do not own is legal only with the owner's written authorisation.

What was actually fixed

Both flaws are use-after-free bugs, where the engine reaches for memory that has already been freed. CVE-2026-109618 sits in the code that tracks file upload progress. It lets an attacker read a slice of process memory remotely and, with the right data layout, reach code execution. CVE-2026-109619 combines a use-after-free in the fatal-error backtrace handling with a type confusion in OPcache. The result is the same, control over execution.

It helps to understand why a use-after-free is so dangerous. A program frees a block of memory but still holds a pointer to it and uses it later. In the meantime other data lands in the same place, so a reference to the supposedly old structure actually reads or overwrites something new. With the right layout the attacker controls what ends up there, and that is what turns a memory bug into code execution.

Importantly, this affects both the mod_php module in Apache and the separate PHP-FPM process. The problem is in the engine, not in how it is run. A researcher using the handle Calif reported the first flaw on 11 August. The details leaked publicly on 20 October, and a day later, on the afternoon of 21 October, the PHP team released the fixed versions. Attackers used the window between the leak and the patch.

Diagram: use-after-free in two PHP code paths, a trigger that needs server-side conditions, memory disclosure and code execution, a web shell as the web server user, and in effect frequent chaining with the Fragnesia flaw to reach root
//The attack at a high level. The RCE alone gives the PHP worker's rights, root needs a separate step

How dangerous it really is

Here it pays to be honest, because a lot of panic grew around PHP2Shell. Sansec analysts tested the public tool and found that on a clean, default PHP install it simply does not work. A successful attack usually needs an existing file inclusion bug in the application or a known, specific server state. In other words, PHP2Shell is rarely the first step. More often it is an amplifier that turns a medium application bug into a full server takeover.

That distinction matters for rating the risk, not for the decision to patch. Since the flaw is in the engine and has been there since 2012, every internet-facing PHP server should be treated as a target. Panic is unnecessary, and so is delay.

It is also worth looking at the timeline. The PHP team received the report in August and worked on a fix at its own pace, but the public leak of details on 20 October changed the situation overnight. Cloudflare recorded the first attempts the very next morning, before the patch even appeared. This is a typical pattern with flaws like this. The real danger window opens when the details become public, not when the fix ships, which is why reaction speed here weighs as much as the patch itself.

From a tester's point of view this flaw is interesting precisely because of its conditional nature. In practice it is rarely the first step. Far more often it is what turns a medium application bug, such as a local file inclusion, into a full server takeover. So when we rate the risk, we look not at a single flaw but at what else is on the server and how the pieces can be combined.

The chain to root: PHP2Shell plus Fragnesia

An RCE in PHP by itself gives an attacker the web server process rights, usually the www-data user. That is already a lot, but it is not root. The catch is that CISA described the two PHP flaws being chained with CVE-2026-46300, a Linux kernel privilege escalation bug known as Fragnesia. A web shell running as www-data plus Fragnesia yields full root on the machine. That is why patching PHP alone is half the job. The kernel has to be current too. We break down the second step in a separate Fragnesia analysis.

How to detect attempts and traces

Since the exploit is conditional, checking whether anyone has already tried matters as much as the patch. Start with the web server logs. Unusual requests to the scripts that handle file uploads, a sudden rise in PHP errors or a run of requests ending in a fatal error are signals worth correlating in time. On the system side, look for fresh files in web-served directories, PHP processes launching a shell and unusual outbound traffic, especially to unknown addresses. WAF rules will block some attempts, but with a flaw in the engine itself treat them as a delaying layer, not a solution.

If you use OPcache, remember that the second flaw touches exactly that area. After the update, clear and warm the cache again so you do not leave an old, potentially altered state in memory. While you are at it, review the places where the application accepts paths from users, because those are what most often supply the missing piece of the puzzle.

Which versions are affected and what to install

The fixed releases are 8.2.35, 8.3.36, 8.4.27 and 8.5.12. The PHP team did not ship a ready release for the 8.1 branch or older, because they are out of official support. It did publish source patches for 7.4, 8.0 and 8.1, and many distributions backported the fix into their packages. In practice this means one thing. Do not look only at the PHP branch number, check the version of the specific package in your system, because a patched distribution package can keep its old version number.

In practice it looks like this. On Debian and Ubuntu you check the version through the package manager and compare it with the distribution's patch list, not with the branch number from php.net. On RHEL and its relatives the package release from the vendor repository is what counts. In containers, remember that an image built before 21 October carries the old version even if the tag looks familiar. After the update, restart PHP-FPM or the server so the new code actually loads.

How to defend

Diagram: patch the PHP engine, cover mod_php and PHP-FPM, close the real vector which is file inclusion, update the kernel for Fragnesia, and hunt for web shells and unusual PHP processes
//Five defence priorities. The PHP patch is the first step, not the last
  1. Patch the PHP engine now. Versions 8.2.35, 8.3.36, 8.4.27 and 8.5.12. If you sit on 8.1 or an older branch, use a distribution backport or plan a move to a supported version.
  2. Cover mod_php and PHP-FPM. The flaw is in the engine, so it reaches every PHP entry point on the machine, including the ones you do not treat as the main path.
  3. Close the real vector, file inclusion. Most public exploitation needs an existing LFI or a known state. Review the include and require spots in your applications and any handling of user-supplied paths.
  4. Update the kernel as well. A web shell as www-data combined with CVE-2026-46300 reaches root. A kernel patch closes the second step of the chain.
  5. Hunt for web shells. New files in web-served directories, unexpected outbound traffic and PHP processes launching a shell are signals worth catching as they happen.

What this means

PHP2Shell is a clear example of why vulnerability handling is a process, not a one-off task. A flaw in an engine that has run since 2012 changes the risk profile of a whole server fleet in a single day. NIS2 names this directly: vulnerability and patch management is one of the baseline measures in Article 21. We wrote about a similar pattern, where one internet-facing component topples the rest, in our review of recent RCE flaws. We broke down the mechanics of a single, mass-exploited flaw in our anatomy of Log4Shell too.

We cover the requirements on the NIS2 / KSC page. If you want to know which of your PHP servers are visible from the internet and whether such a chain can be built on them before someone else tries, that is the scope of our penetration testing and attack-surface review. Book a consultation.


Sources: Sansec · Securelist · Patchstack · CISA KEV

← Back to the blog