Picture an office building with a strict front desk. Every visitor shows ID, signs in, and gets escorted. That front desk is your application: its logins, its permissions, its input checks.
Now picture a parcel built to jam the sorting machine in the basement mailroom — the room that opens every delivery before anything reaches the front desk. Jam it the right way and the machine hands the sender a key to the building. Nobody at the front desk ever sees them.
That's PHP2Shell: two flaws in PHP itself, the language that runs a large share of the world's websites. A single crafted web request can let an attacker run commands on the server, with no account and no login, because the flaw sits in the part of PHP that unpacks requests before your website's code runs at all.
Fixes shipped on October 21. Attackers were already probing four days earlier, and the U.S. government added the flaws to its list of actively exploited vulnerabilities on October 26.
Patching closes the door. It doesn't tell you whether someone already walked through it. That second question needs a hunt — and the hunt is the part this post is about.
Everything below is the technical version.
What PHP2Shell is
PHP2Shell is the name for two bugs disclosed together: CVE-2026-109618 and CVE-2026-109619. Both lead to unauthenticated remote code execution (RCE), and the PHP security team scored each at 9.2 on the Common Vulnerability Scoring System (CVSS) v4.0.
- CVE-2026-109618 — out-of-memory (OOM) corruption. PHP builds
$_POSTduring request start-up. If memory runs out partway through adding an entry, the entry is counted but never initialized, and cleanup later treats that half-built data as real. - CVE-2026-109619 — stale state across requests. A use-after-free: after a fatal error, a worker-wide pointer keeps pointing at memory the previous request already freed, and a later request on the same worker can follow it. One confirmed path runs through session upload progress, which is on by default and runs even if the application never calls
session_start().
The detail that matters most for defenders: application code never runs. The exploit is an ordinary unauthenticated HTTP POST, and it's processed before your framework, your authentication, or your input validation gets a turn. Datadog's lab reproduction got command execution as the Apache worker user, www-data, while the worker kept serving traffic afterwards.
Who's affected
| PHP branch | Vulnerable | Fixed in |
|---|---|---|
| 8.5 | before 8.5.12 | 8.5.12 |
| 8.4 | before 8.4.27 | 8.4.27 |
| 8.3 | before 8.3.36 | 8.3.36 |
| 8.2 | before 8.2.35 | 8.2.35 |
| 7.4 – 8.1 | all versions | No official release — minimal source backports only |
| 5.4 – 7.3 | all versions | End-of-life (EOL), no fix from PHP |
PHP says every installation serving web requests is in scope: Apache with mod_php, FastCGI Process Manager (PHP-FPM), php-cgi, FrankenPHP, and LiteSpeed. mod_php carries the highest demonstrated risk. Cortex Xpanse counted over 22.6 million exposed instances that are potentially vulnerable.
Ten days, compressed
| Date (2026) | What happened |
|---|---|
| Oct 17 | Amazon Threat Intelligence sees an exploitation attempt against its MadPot honeypots — four days before disclosure. |
| Oct 20 | CVE identifiers leak ahead of the embargo. PHP issues an advance notice; watchTowr says it has reproduced both bugs. |
| Oct 21 | PHP publishes the advisory and fixed releases, a day earlier than planned. watchTowr's honeypots record in-the-wild exploitation of both CVEs. |
| Oct 24 | Researcher Adel Karimi reports three honeypots on PHP 8.4.26 successfully exploited, consistent with CVE-2026-109618. |
| Oct 26 | The Cybersecurity and Infrastructure Security Agency (CISA) adds both CVEs to its Known Exploited Vulnerabilities (KEV) catalog. Trail of Bits shows working exploits against PHP 8.2 – 8.5, with demo shells on MediaWiki, Symfony, Laravel, and phpBB. |
| Oct 26 – 29 | Dream Research reports PHP2Shell chained with a Linux kernel privilege-escalation bug to gain root on internet-exposed firewall management interfaces. Unit 42 says it independently verified the tooling. |
| Oct 28 | Amazon updates its status: "broad exploitation attempts in the wild." |
Two things in that table should change how you scope the response. First, exploitation started before the patch existed, so "we patched on day one" doesn't mean "we were never exposed." Second, the firewall chain shows where this goes next: PHP isn't only in your websites. It's inside appliances, admin consoles, and vendor products you don't think of as PHP at all.
This one came with an unusual amount of bad intel. The leaked CVE identifiers circulated with a CVSS score of 10.0, which the PHP Foundation says was wrong. Unit 42 published an update on October 23 and retracted it two days later. Public "exploit" code was circulating that nobody had verified against these CVEs. If your threat-intel pipeline ingested the first wave of reports, re-check what it concluded. Date every claim, and prefer the source that reproduced the bug over the one that repeated it.
Patching isn't the finish line
The fix is simple: upgrade to the fixed release for your branch. Getting it to actually take effect is less simple.
- Restart every worker. PHP-FPM pools and Apache children keep running the old code in memory until they're replaced. A patched package on disk with week-old workers is still vulnerable.
- Find the runtimes you didn't install. Container images, bundled interpreters in vendor products, appliances. The
phpcommand-line binary on a host may not be the runtime serving web traffic. - Don't trust version strings alone. Distributions and long-term support vendors often backport fixes without changing the upstream version number. Check the vendor advisory, not just
php -v. - Don't lean on the config workarounds. Setting
memory_limit=-1andsession.upload_progress.enabled=0reduces exposure, but watchTowr and Datadog both say the.inimitigations don't fully protect you. They're a bridge to the patch, not a substitute.
Start with inventory. If your servers run Microsoft Defender for Endpoint (MDE), Defender Vulnerability Management (MDVM) can tell you where it sees vulnerable PHP. All queries in this post run in Microsoft Defender XDR advanced hunting; in Microsoft Sentinel with the Defender XDR connector, replace Timestamp with TimeGenerated.
// Every PHP runtime Defender Vulnerability Management can see, by version.
// Fixed builds: 8.5.12, 8.4.27, 8.3.36, 8.2.35. 8.1 and older: no official fix.
DeviceTvmSoftwareInventory
| where SoftwareName has "php"
| summarize Devices = dcount(DeviceId),
DeviceList = make_set(DeviceName, 50)
by SoftwareVendor, SoftwareName, SoftwareVersion
| order by SoftwareVersion asc
// Then: where MDVM has mapped the CVEs directly.
DeviceTvmSoftwareVulnerabilities
| where CveId in ("CVE-2026-109618", "CVE-2026-109619")
| summarize Devices = dcount(DeviceId) by CveId, SoftwareName, SoftwareVersion
Treat the result as a floor, not a ceiling. MDVM sees packages it can identify on onboarded hosts. It won't see a PHP runtime baked into a container image or locked inside an appliance, and a backported distro build may be flagged as vulnerable when it isn't. Use it to start the patch list, then go find the runtimes it can't see.
Hunt the behavior, not the request
There's real value in detecting the exploit request at the edge. Most public proofs of concept use a multipart upload carrying PHPSESSID and PHP_SESSION_UPLOAD_PROGRESS fields, hundreds of parts, and machine-generated nested field names like files[R00001][a][a][a]. Your web application firewall (WAF) vendor almost certainly has a signature for that by now.
But anyone who read the last post knows where that sits on the Pyramid of Pain: it's a network artifact, and attackers can change it. Datadog already documents a second path — one huge URL-encoded field instead of a multipart upload — and warns against building defenses around any single code path. It also warns that your WAF may not parse the request the way PHP does.
What the attacker can't change is what happens after the exploit lands. However the request is built, success means a PHP worker — a process whose whole job is serving web pages — starts doing things web workers don't do: spawning shells, calling out to the internet, writing files where persistence lives. That's the hunt. It maps to Exploit Public-Facing Application (T1190) at the start and Unix Shell (T1059.004) right after, and it works the same whether the attacker used PHP2Shell or the next PHP bug.
The hunts below start from October 17, the first observed attempt, not from your patch date. They need MDE on the web servers themselves — Linux and Windows.
Hunt 1 — a web worker starts a shell
// Shells, downloaders and recon tools started by a PHP web worker,
// directly or one hop down through "sh -c". Covers mod_php (apache2/httpd),
// PHP-FPM, php-cgi, LiteSpeed, FrankenPHP, and PHP on IIS.
let HuntStart = datetime(2026-10-17);
let WebWorkers = dynamic(["apache2", "httpd", "httpd.exe", "php-cgi", "php-cgi.exe",
"lsphp", "frankenphp", "w3wp.exe"]);
let Interesting = dynamic(["sh", "bash", "dash", "zsh", "curl", "wget", "nc", "ncat",
"socat", "python", "python3", "perl", "base64", "chmod",
"id", "whoami", "uname", "cmd.exe", "powershell.exe",
"pwsh.exe", "certutil.exe"]);
DeviceProcessEvents
| where Timestamp > HuntStart
| extend Parent = tolower(InitiatingProcessFileName),
Grandparent = tolower(InitiatingProcessParentFileName)
| where Parent in (WebWorkers) or Parent startswith "php-fpm"
or Grandparent in (WebWorkers) or Grandparent startswith "php-fpm"
| where FileName in~ (Interesting)
| project Timestamp, DeviceName, AccountName, Grandparent, Parent,
FileName, ProcessCommandLine, InitiatingProcessCommandLine
| order by Timestamp desc
This is the core detection. It checks one hop down because PHP's exec() and friends run commands through /bin/sh -c: the exploit's shell is often a child of sh, not of the worker itself. On Windows with IIS, the chain is w3wp.exe → php-cgi.exe → cmd.exe, and the same logic catches it.
Hunt 2 — stack the children, rarest first
// Every distinct child of a PHP web worker over 30 days, rarest first.
// Legitimate children (sendmail, convert, git) run on many hosts, often.
// A child first seen after Oct 17 on one or two hosts deserves a look.
let WebWorkers = dynamic(["apache2", "httpd", "httpd.exe", "php-cgi", "php-cgi.exe",
"lsphp", "frankenphp", "w3wp.exe"]);
DeviceProcessEvents
| where Timestamp > ago(30d)
| extend Parent = tolower(InitiatingProcessFileName)
| where Parent in (WebWorkers) or Parent startswith "php-fpm"
| summarize Devices = dcount(DeviceId),
Events = count(),
FirstSeen = min(Timestamp),
LastSeen = max(Timestamp),
SampleCommandLine = take_any(ProcessCommandLine)
by Parent, FileName
| order by Devices asc, Events asc
Some PHP applications legitimately shell out — to send mail, resize images, or run Git. Hunt 1 will flag those, and you'll tune them out. This query is how you find what to tune and what to chase: anything that first appeared after October 17, on one or two hosts, is worth opening. For sh itself, re-run the stack grouped on the command line, since sh is the wrapper for everything.
Hunt 3 — worker-spawned processes talking to the internet
// Public-internet connections made by anything a PHP worker spawned,
// up to two hops down (apache2 -> sh -> bash). Joins network events
// back to the process tree, because DeviceNetworkEvents only knows
// the connecting process and its direct parent.
let HuntStart = datetime(2026-10-17);
let WebWorkers = dynamic(["apache2", "httpd", "httpd.exe", "php-cgi", "php-cgi.exe",
"lsphp", "frankenphp", "w3wp.exe"]);
let WorkerSpawned = DeviceProcessEvents
| where Timestamp > HuntStart
| extend Parent = tolower(InitiatingProcessFileName),
Grandparent = tolower(InitiatingProcessParentFileName)
| where Parent in (WebWorkers) or Parent startswith "php-fpm"
or Grandparent in (WebWorkers) or Grandparent startswith "php-fpm"
| project DeviceId, ProcessId, ProcessStart = Timestamp,
Lineage = strcat(Grandparent, " > ", Parent, " > ", tolower(FileName));
DeviceNetworkEvents
| where Timestamp > HuntStart
| where RemoteIPType == "Public"
| join kind=inner WorkerSpawned
on $left.DeviceId == $right.DeviceId, $left.InitiatingProcessId == $right.ProcessId
| where Timestamp between (ProcessStart .. (ProcessStart + 1d))
| summarize Connections = count(),
Ports = make_set(RemotePort, 10),
FirstSeen = min(Timestamp),
LastSeen = max(Timestamp)
by DeviceName, Lineage, RemoteIP, RemoteUrl
| order by FirstSeen desc
A reverse shell is a process descended from the web worker holding a connection to a host your web tier has never talked to. The join matters: DeviceNetworkEvents only records the connecting process and its parent, and the connecting process is often two hops below the worker (apache2 → sh → bash).
Hunt 4 — persistence written by the web tier
// Files written where persistence lives, by a PHP worker or something it
// spawned: scripts in web paths, cron entries, SSH keys, systemd units.
let HuntStart = datetime(2026-10-17);
let WebWorkers = dynamic(["apache2", "httpd", "httpd.exe", "php-cgi", "php-cgi.exe",
"lsphp", "frankenphp", "w3wp.exe"]);
DeviceFileEvents
| where Timestamp > HuntStart
| where ActionType in ("FileCreated", "FileModified", "FileRenamed")
| extend Parent = tolower(InitiatingProcessFileName),
Grandparent = tolower(InitiatingProcessParentFileName)
| where Parent in (WebWorkers) or Parent startswith "php-fpm"
or Grandparent in (WebWorkers) or Grandparent startswith "php-fpm"
| extend Persistence = case(
FileName matches regex @"(?i)\.(php\d?|phtml|phar)$", "script in web path",
FolderPath has_any ("/etc/cron", "/var/spool/cron"), "cron",
FileName == "authorized_keys", "ssh key",
FolderPath has_any ("/etc/systemd/", "/.config/systemd/"), "systemd unit",
"")
| where isnotempty(Persistence)
| project Timestamp, DeviceName, Persistence, FolderPath,
InitiatingProcessAccountName, Grandparent, Parent,
InitiatingProcessCommandLine
| order by Timestamp desc
This covers the usual follow-ups after a web-tier shell: a dropped web shell (T1505.003), a cron job (T1053.003), an SSH authorized key (T1098.004), or a systemd unit. Expect noise from content management systems that update their own plugins — WordPress writing .php files is normal. A .php file written by something the worker spawned, rather than the worker itself, is not.
Hunt 5 — the crash, then the shell (Sentinel)
PHP2Shell is a memory-corruption exploit, and those are noisy before they're quiet. Datadog's research describes the signature: a short burst of two to four memory-exhaustion errors on one worker, logged as failing at Unknown on line 0 — meaning PHP died during start-up, before any script ran — or worker segmentation faults. Legitimate apps run out of memory too, so a burst alone proves nothing. A burst followed by a worker-spawned shell on the same host is a different story.
// Microsoft Sentinel. A burst of PHP start-up memory errors or worker
// segfaults, followed within 15 minutes by a worker-spawned shell on the
// same host. Assumes PHP and Apache error logs are forwarded to Syslog.
let HuntStart = datetime(2026-10-17);
let Window = 15m;
let CrashBursts = Syslog
| where TimeGenerated > HuntStart
| where (SyslogMessage has "Allowed memory size of" and SyslogMessage has "Unknown on line 0")
or (SyslogMessage has "AH00052" and SyslogMessage has "Segmentation fault")
or SyslogMessage has "exited on signal 11"
| extend Host = tolower(tostring(split(Computer, ".")[0]))
| summarize CrashEvents = count(),
BurstStart = min(TimeGenerated),
BurstEnd = max(TimeGenerated)
by Host, bin(TimeGenerated, 5m)
| where CrashEvents >= 2;
let WorkerShells = DeviceProcessEvents
| where TimeGenerated > HuntStart
| where tolower(InitiatingProcessFileName) in ("apache2", "httpd", "php-cgi", "lsphp", "frankenphp")
or InitiatingProcessFileName startswith "php-fpm"
| where FileName in~ ("sh", "bash", "dash", "curl", "wget", "python3", "perl", "nc")
| extend Host = tolower(tostring(split(DeviceName, ".")[0]))
| project Host, ShellTime = TimeGenerated, FileName, ProcessCommandLine;
CrashBursts
| join kind=inner WorkerShells on Host
| where ShellTime between (BurstStart .. (BurstEnd + Window))
| project Host, BurstStart, CrashEvents, ShellTime, FileName, ProcessCommandLine
| order by BurstStart desc
Hunt 5 needs logs you may not collect. Apache and PHP-FPM write their error logs to files by default, not to syslog. You'll need to forward them — Apache's ErrorLog syslog:, or Azure Monitor Agent custom text logs into their own table. If they land somewhere other than Syslog, swap the table and field names.
Hostnames won't match by default. MDE often reports fully qualified names; syslog often sends short names. The query normalizes both to the short name. Check that this holds in your environment.
No sensor, no hunt. Every endpoint query here assumes MDE is on the web server. Containerized PHP on a Kubernetes node without a sensor, managed hosting, and vendor appliances won't show up at all. For appliances, the hunt moves to their management logs and to what the appliance talks to.
Absence isn't clearance. Datadog's lab ran the exploit in about three seconds, and the worker kept serving traffic. An attacker who only wanted to read memory or steal a config file may never spawn a shell. Clean hunt results lower the risk; they don't eliminate it.
What I'd tell a client
1. Patch, restart, then prove it. "We applied the update" isn't the finish. Confirm every worker restarted on the fixed runtime, including in container images and vendor products.
2. Scope from October 17, not from your patch date. Exploitation predates the fix. Every internet-facing PHP host needs a retro-hunt back to the first observed attempt before anyone signs off on "not affected."
3. Don't let the WAF be the answer. Signatures help, and you should have them. But the exploit has more than one request shape, the WAF may parse the request differently from PHP, and this bug beats application-level controls by design. Detection has to live on the host.
4. Get management interfaces off the internet. The firewall chain only worked because admin consoles were reachable from anywhere. That was a bad idea before PHP2Shell, and it's a worse one now.
5. End-of-life PHP is the real exposure. PHP 5.4 through 7.3 will never get a fix, and 7.4 through 8.1 only get source patches you have to build yourself. If those versions are still serving traffic, the remediation plan is a migration, not a patch.
PHP2Shell is a good reminder of why the top of the pyramid matters. The request shape changed within days of disclosure. The CVSS score that circulated first was wrong. One of the first major vendor write-ups was partly retracted. Almost everything at the bottom of the pyramid moved. The one thing that stayed constant was the behavior: a process built to serve web pages started acting like an operator's terminal.
Your app never saw the request. Your endpoint sensor saw everything that happened next.
Hunt the worker, not the request.