DETECTIONCVE-2026-109618CVE-2026-109619T1190T1505.003

Detecting PHP2Shell exploitation and webshell drops

T+0ReconScanner finds PHP
T+2mProbeWAF rule fires
T+3mCrashes502s, php-fpm segfaults
T+6mShellwww-data runs curl
T+7mWebshellcache.php in uploads
T+8mIncident2 signals, raised High
TL;DRTwo critical PHP flaws let attackers run code on servers with default PHP settings. Attackers moved within days, often planting a PHP webshell to keep access. I built a 6-query detection pack that stacks the signals: WAF probe, backend crashes, shell spawn and webshell drop. Two signals on one server raises an incident.

What happened

PHP shipped emergency fixes for CVE-2026-109618 and CVE-2026-109619 on 21 October 2026. The first is remote code execution through out-of-memory corruption, the second through stale global state (a use-after-free). Both are rated critical at CVSS 9.2, and neither needs the attacker to log in. Public proof-of-concept code appeared quickly and exploitation in the wild followed. The pattern I designed for: get code running as the web server user, then drop a PHP webshell in a public folder to keep access.

How I'd catch it

Normal access logs never see the POST body, and the upload progress field is used legitimately too. So no single signal is enough. I stack them:

01
Web server spawning a shellThe PHP or web server process (php-fpm, apache2, httpd) starting sh, bash, curl or wget.
02
New .php files in web foldersA .php file written into a public directory by the web server user, the classic webshell drop.
03
Upload progress probes plus crashesMultipart POSTs carrying PHP_SESSION_UPLOAD_PROGRESS, caught by an Azure WAF custom rule, followed by 502s and php-fpm segfaults.

The detection

php2shell_webshell_drop.kqlT1505.003
// Correlation rule (on GitHub). A web server process spawning a shell AND
// a new .php file in a web folder on the same host within 30 minutes.
let ShellSpawn = DeviceProcessEvents
| where InitiatingProcessFileName startswith "php-fpm"
    or InitiatingProcessFileName in~ ("apache2", "httpd")
| where FileName in~ ("sh", "bash", "dash", "curl", "wget")
| project DeviceName, ShellTime = Timestamp, ProcessCommandLine;
let PhpDrop = DeviceFileEvents
| where ActionType == "FileCreated" and FileName endswith ".php"
| where FolderPath has_any ("/var/www/", "/uploads/", "/public_html/")
| where InitiatingProcessAccountName in~ ("www-data", "apache", "nginx")
| project DeviceName, DropTime = Timestamp, FilePath = strcat(FolderPath, FileName);
ShellSpawn
| join kind=inner PhpDrop on DeviceName
| where abs(datetime_diff('minute', DropTime, ShellTime)) <= 30
| summarize FirstSeen = min(ShellTime), Files = make_set(FilePath),
            Commands = make_set(ProcessCommandLine, 5) by DeviceName

Walkthrough: the attack, stage by stage

This is a scenario walkthrough, not a lab replay: it shows what each query should see at each stage. Recon at T+0, the probe at T+2 minutes, crashing workers at T+3, www-data running curl at T+6, a cache.php webshell in the uploads folder at T+7, and a High incident at T+8. Plus two false-alarm scenarios and why the rule stays quiet. The correlation rule is in my KQL library on GitHub.

What defenders should do

1. Patch PHP to 8.5.12, 8.4.27, 8.3.36 or 8.2.35 (or your distro's backport), then restart every PHP worker. 2. Hunt for new or changed .php files in web folders since 21 October. 3. Turn on the detection above and review any hits.

References

← Back to portfolio