A Hunt Lead on Threat Hunting Labs: a short investigation released alongside a live threat, in this case PHP2Shell, a pair of critical memory-handling flaws in PHP itself (CVE-2026-109618 and CVE-2026-109619) disclosed in October 2026.
Written under Threat Hunting Labs’ write-up pilot: this covers the investigation and what it found, not the lab’s questions or answers.
One Linux web server running Apache with PHP, flagged as compromised, and a short observation window. Six telemetry sources to work with: Linux EDR process and file events, auditd, Linux Sysmon, Zeek HTTP and connection logs, derived endpoint alerts and Suricata alerts, plus a redacted PCAP of the web traffic. A day after release THL added a seventh: Apache’s own access and error logs, extracted from the web container.

A single external client sent 30 multipart POST requests to the web service in well under a minute, in a fixed four-request cycle repeated every few seconds. Each cycle pushed PHP into a memory-exhaustion failure during request start-up, sent a small request carrying PHP’s session upload-progress field, then sent a payload request. Once the payload switched to a 4 KB body full of forged in-memory structures carrying a shell command, the Apache worker handling it stopped responding and, at the same moment, spawned a system shell that ran an identity-discovery command and wrote its output to disk. That happened five times; every command completed successfully. The server advertised PHP 8.4.26, one release before the first fixed 8.4 version. Read alone, the web logs show a run of requests with no response; the host telemetry shows code execution as the web user, and the PCAP shows how the exploit was put together. Nothing in the web-worker chains goes beyond proving execution: no download, no persistence and no lateral movement. The evidence matches the published descriptions of both PHP2Shell flaws, but it can’t prove which code path was hit.
flowchart LR
A(["External client"]) -->|~15 MB POST, 1,000+ fields| B["Apache + PHP 8.4.26 worker"]
B -->|memory limit exhausted, fatal error| A
A -->|small POST, session upload-progress field| B
A -->|4 KB POST, forged structures + command| B
B -.->|no response| A
B -->|then segfaults| F["Worker crash"]
B -->|worker spawns| C["System shell"]
C -->|runs| D["Identity-discovery command<br/>exit code 0"]
C -->|redirects output| E[("Output file on disk")]
The cycle repeats every few seconds; the last step lands five times.
Starting from the host. The brief pointed at process execution, so I started with the EDR table and looked for any web or PHP worker launching a shell. That returned five rows straight away: the Apache worker starting a shell every few seconds, all with the same short command line. A web server should essentially never do this, so the rest of the hunt was about proving what those shells did and where the trigger came from.
Finding the source. With the shell times in hand I pivoted to the Zeek HTTP logs and summarised POST requests by client. Only one client showed up, and its 30 POSTs to the web service started just before the first shell launch and stopped just after the last. Shared timing is correlation, not a recorded link, so this placed the client at the scene rather than tying any single request to any single shell.
Following the process chain. The first query only went one generation deep. Filtering on the shells’ own children showed each one launching the same identity-discovery command, and the parent IDs lined up exactly with the five shell PIDs, giving five complete web-worker → shell → command chains. One detail worth remembering: the recorded process name for the shell didn’t match how the command line invoked it. Hunt queries need to match on what the sensor records, not on what the command line suggests.
Linking command to file. The shells’ command lines redirect the command’s output to a file, and a file-creation event carries the same process entity ID as the first shell, so the write is attributed directly to that shell rather than inferred from timing. Only one creation event exists even though all five shells write to the same path, which most likely means later runs overwrote an existing file. The EDR records the operation, not the contents, so the page can say output was written, not what it said.
Missing responses ≠ failure. The POSTs closest to the shell launches have no HTTP response status at all. On the web logs alone that looks like requests that never completed. The host disagrees: each command has an exit code of 0 in the EDR, and auditd independently records a successful execve for the same processes, with the two clocks a little out of step. auditd also records 13 Apache workers terminating abnormally across the same window, and the signals split cleanly. Five are segmentation faults (signal 11), and their PIDs are exactly the five Apache parents of the shells: each worker spawned its shell and then crashed. The other eight are aborts (signal 6). That explains the missing responses: the worker died after the command ran, not before.


The logs proved what ran; the redacted PCAP of the same window shows how. With port 8080 decoded as HTTP, every request is a multipart POST to the same PHP page, and they fall into a strict four-step cycle:
| Step | Request | What the server did |
|---|---|---|
| 1 | ~15.6 MB body, well over 1,000 form fields | Warned that max_input_vars was exceeded, then died with Allowed memory size of 8388608 bytes exhausted during request start-up, before any PHP script ran. 200 with the error page |
| 2 | 192 bytes: a fixed session ID plus a PHP_SESSION_UPLOAD_PROGRESS field | No response: PHP reports zend_mm_heap corrupted and the worker aborts (signal 6) |
| 3 | ~12.6 MB body | The same start-up memory exhaustion, at a different allocation size |
| 4 | Small payload: the same session fields plus sprayed fields | First two cycles (~90 KB, hundreds of numbered fields): 200 with session errors, one carrying an 11 KB session cookie made of the same 64-character session ID repeated ~178 times. Next five cycles (4,278 bytes): no response; the worker spawns a shell, then segfaults (signal 11) |


What that looks like. Steps 1 and 3 force allocation failures in the middle of request parsing, which is exactly the condition the first PHP2Shell advisory describes. Step 2 uses the session upload-progress mechanism the second advisory’s mitigations target, and the corrupted session cookie in step 4’s early responses looks like state from one request bleeding into the next. I can’t prove from traffic alone how the two combine, or which flaw did the work; the lead’s own analysis is careful about that too.
The payload. The 4,278-byte requests carry fifteen identical 167-byte fields. In hex each one is a forged in-memory structure: small integer header fields, several hard-coded little-endian 0x7f… user-space addresses, and the shell command string at the end with its length stored just in front of it, the way PHP lays out its own strings. Hard-coded addresses would normally be fragile against ASLR, but Apache’s prefork workers are forked from one parent and share its memory layout, so addresses that work in one worker work in the next.

The grooming. The two ~90 KB requests before them are heap grooming. The second one carries 998 fields named a0000[0] upward, each holding sixteen x characters: the [0] makes PHP build a separate small array per field, packing the heap with hundreds of same-sized allocations so later objects land somewhere predictable. Add the session ID and upload-progress fields and it comes to exactly 1,000 inputs, PHP’s default max_input_vars, where the 15 MB requests deliberately blow straight past it. The grooming requests got normal responses; once the forged structures arrived, the workers stopped answering.
![Heap-grooming request: the session hook fields followed by hundreds of a0000[0]-style array fields](/_astro/grooming.CXZwmYUe_Z131iYe.webp)
Closing the gap between network and host. Two things tie the PCAP to the host far more tightly than “same client, same minute”:
execve, all five of them. The PCAP shares auditd’s clock; the EDR runs a little behind both. That offset is why the EDR shell times looked like they preceded the requests that triggered them.There’s still no shared process ID between a packet and a process, so this stays correlation, but it’s about as strong as network-to-host correlation gets. Counting the gaps: 14 of the 30 requests never got a response, and auditd accounts for 13 of them. All eight upload-progress requests line up with the eight worker aborts and all five payloads with the five segfaults; the fourteenth, one of the large requests, has no matching crash record. Apache’s own logs explain that one (below).
THL added the web container’s Apache logs after the lead went out, and they give the server’s side of the same burst: 17 access records and 21 error-log lines.
The error log counts the same crashes. Thirteen AH00052: child pid … exit signal lines, eight Abort (6) and five Segmentation fault (11), in exactly the order auditd recorded them. Before each of the eight aborts sits a bare zend_mm_heap corrupted: PHP’s own allocator noticed its heap had been damaged and called abort(). That lines up with the upload-progress request in step 2, so step 2 is where memory gets corrupted. The segfaults after the payloads have no heap message: those workers ran the shell before anything checked.

Two things that would trip up a careless join:
The access log closes the last gap. It holds 17 completed requests, all POST /index.php with status 200, one more than the 16 responses in the PCAP. The extra one is one of the last 15.6 MB requests (stream 24), which has no server packets at all in the capture. Apache answered it; the capture just didn’t record the reply. That makes the 14 missing responses 13 worker crashes plus one capture gap, with nothing unexplained. (The access records also carry a byte counter, but without the server’s LogFormat it can’t be read as request or response size, so I’ve left it alone.)
| Tactic | Technique | Where it showed up |
|---|---|---|
| Initial Access | T1190 Exploit Public-Facing Application | Memory-exhaustion, session upload-progress and forged-structure POSTs against a vulnerable PHP 8.4.26 web service |
| Execution | T1059.004 Unix Shell | Apache worker spawning a system shell five times |
| Discovery | T1033 System Owner/User Discovery | Each shell running an identity check as the web user, output redirected to a file |
The client IP and the output filename sit at the bottom of the pyramid: both are trivial for an attacker to change on the next run, and the lead explicitly asks for a hunt that doesn’t depend on either. The top of the pyramid here is the behaviour: a web-facing worker process starting a shell, and that shell immediately running discovery. That relationship holds no matter which client sends the requests, which PHP2Shell variant is used, or where the output lands.
apache2, httpd, nginx, php-fpm, lsphp, frankenphp and versioned variants) starting a command shell. Baseline legitimate admin tooling first; after that it should be close to silent.whoami, uname, hostname or another identity check within seconds is the “am I in?” step and a much higher-confidence signal than the shell alone.max_input_vars warnings, is not normal traffic.X-Powered-By: PHP/8.4.26 sits one release below the first fixed 8.4 build. Verify the runtime that actually serves requests, not the CLI version.zend_mm_heap corrupted followed within a second by AH00052 … exit signal Abort (6), repeating, means PHP’s allocator is being damaged on purpose. In a container, match these to host crash records by order and time, not PID.All five objectives answered with evidence; verified Hunt Lead badge earned 23 October 2026.
Verify: https://www.threathuntinglabs.com/leads/php2shell/completed/426951d89c117cd50f81be2d43592637
The lead is free, including its researcher analysis and hunt pack: investigate PHP2Shell on Threat Hunting Labs.