Detecting PHP2Shell exploitation and webshell drops
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:
The detection
// 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.