28 October 2026 / Security operations / 8 chapters

A healthy website doesn't prove the fix

From Patching php2shell across a mixed PHP fleet

The first verification on each server was an availability check: production, staging, preview and login pages, compared against their behaviour before the update, through both the public address and directly against the origin server. Across four servers that produced 540 HTTP check records to review. Every site responded the way it had before.

That was necessary, and it told us nothing about the vulnerabilities. A 200 response shows the site still works after the update. It doesn't show that a request hitting the memory limit at the wrong moment no longer corrupts memory, or that state from one request can't leak into the next.

I asked the agent directly whether there was a way to test what we were actually patching. Its answer set out the right method, and we ran it:

  1. Compare before and after in isolation. Set up the original packages and the patched ones with the same handler setup, and run the relevant upstream regression tests against both. The vulnerable version is the control. A test that passes on both doesn't prove anything about the fix.
  2. Exercise the failure paths themselves. Cover memory exhaustion, request parsing and cleanup. For the stale-state bug, send successive requests through a persistent worker. Starting a fresh command-line PHP process for each test can't reproduce state carried between requests.
  3. Tie the result back to production. Confirm that the binaries tested are the ones installed and loaded on the live workers.

On the isolated copy of one 8.4 server, the original packages passed four of the five relevant upstream test cases and failed one. The patched packages passed all five, with no failures, skips or errors. The case that separated them covers upload-progress and session-state handling, which is the area of the stale-state bug. The other four passed on both builds, so they're supporting checks only.

A separate check on the same setup sent a normal request, then a request that deliberately exhausted memory, then a normal request again, all to the same FPM worker. The responses were 200, then the expected 500, then 200, from the same worker process ID. The worker recovered cleanly from the out-of-memory error, and the next request was handled normally.

What counts as correct depends on the branch. The official 7.4 backport deliberately terminates the affected worker when memory runs out. That's its fail-closed design, and it would look like a failure if you judged it by the newer branches' recovery behaviour. We ran a bounded check on the 7.4 server for that specific behaviour instead.

Deliberately failing requests belong on isolated copies. I wouldn't send memory-exhaustion requests at a production worker serving customers just to see what happens.

All articles