Brian Ray LLC
Risk

AI found PHP2Shell in a week. Your pipeline had ten years.

The flaw sat in C code behind 70% of the web for a decade. The defense is the same AI the researchers used, pointed at your own code before it ships.

By Brian Ray 13 min read

The short version

PHP2Shell is not a new bug; it is a ten-year-old bug that became cheap to exploit the day a frontier model could run the attacker's loop. Observational AI in the development lifecycle runs that same loop against your own code on every change, and I put the odds that it catches the next PHP2Shell before production well above anything else on the defense list.

What happened, in business terms

On Wednesday the PHP Foundation disclosed two critical flaws in the PHP runtime, patched them, and the US National Security Agency and Europe's cybersecurity agency told everyone to apply the fix immediately. PHP sits under roughly 70% of the world's websites, which is why the headline on CNN was not about a programming language. It was about websites going dark.

The flaws, named PHP2Shell, were found in late August by teams at OpenAI, the Google-owned security company Wiz, and a third firm. They had been in the code for about a decade. Exploiting them takes a chain of steps that Wiz described as sitting at the edge of what a human researcher could practically pull off. So the researchers handed the chain to AI: the models adapted exploit techniques, ran them, read the results, and adapted again. Wiz says one researcher with frontier models finished in a week what would have taken a world-class team months. The models named in the write-up were Google's Gemini 4 Argon, OpenAI's GPT-5.6 Sol, and Wiz's own Atlas.

The mechanism is a memory-lifecycle bug. When a request ends unexpectedly, PHP can leave data behind in memory that a later request can read or corrupt. IBM's Patrick Fussell gave CNN the best plain-language version: it is "a hotel room where you check out, but your key still works." Passwords, session tokens and card details are the things you might find in the next guest's room.

The business consequences arrived within 48 hours. ANA, JR West and MUFG in Japan took web services down. Government sites in France, Denmark, Finland and the Netherlands went offline while fixes were applied, including the Dutch cyber-security agency's own site. Nearly three dozen UK government services were unavailable. Wikimedia pulled systems as a precaution. Cloudflare's CEO reported millions of exploit attempts on its network. Japan's prime minister asked companies to check whether their public websites run PHP and to patch tonight; the fact that a head of government had to ask that question is its own finding, and I come back to it below.

Last week's note promised the cyber side of the coding-agent fleet as the next piece. PHP2Shell moved it up the queue and handed it a case study.

PHP2Shell by the numbers

70%
of the world's websites run on PHP, per the NSA and ENISA advisories
10yr
the flaws sat in the codebase before anyone found them
1wk
for one researcher with frontier models; months for a team without them
60%
my estimate of the odds an observed pipeline catches the next one first (argued below)

PHP was a library pretending to be a language

I wrote PHP for money in the early 2000s, so this one is personal. PHP began in 1995 as Rasmus Lerdorf's Personal Home Page tools: a handful of C programs run as CGI binaries, written to track visits to his résumé. It was a toolkit, not a language. In 1998 Zeev Suraski and Andi Gutmans rewrote the parser and PHP 3 became something you could call a language with a straight face, and PHP 4 in 2000 put the Zend Engine underneath it.

What never changed was the standard library. It was C libraries stitched together with the thinnest possible wrapper. The string functions kept their C names. Argument order flipped from one function to the next because each wrapper kept whatever order the underlying C library used. User input became global variables by default because that was the easiest thing for a C program to do with a query string. Real objects did not arrive until PHP 5 in 2004, and by then I had moved to Python, which was a language that happened to ship a library rather than a library that happened to ship a language. I have not written PHP for money since.

To be fair to the community, it had style. The PHP crowd ran developer sprints in castles in Europe back then; the venues were better than the type system. And the language earned its place. WordPress, Wikipedia and Facebook's first decade ran on it, and running 70% of the web is not an accident.

But the thing I left in 2003 is the thing that broke this week. PHP2Shell is not a PHP bug in the sense that a PHP developer could have seen it. It lives in the request lifecycle: start, run, shut down, and the awkward branch where shutdown does not go to plan. That lifecycle is C code in the engine, managing C memory, exactly as it was in 1998. A PHP developer never sees it. A C reviewer reading it sees a function that frees what it allocated, not a ten-step sequence of requests that leaves the key working. That is the class of bug humans are worst at, and the class a tireless experimenter with a sandbox and a budget is best at.

Scroll sideways to see the whole timeline

PHP, 1994 to 2026: language eras above the line, exploits below, ending in PHP2Shell A timeline of PHP from the PHP/FI C scripts of 1995 through PHP 8, with the major vulnerabilities plotted beneath, culminating in PHP2Shell in October 2026, two memory flaws found with AI after sitting in the code for a decade. PHP, 1994 TO 2026 LANGUAGE ERAS ABOVE THE LINE · EXPLOITS BELOW 1994 1998 2002 2006 2010 2014 2018 2022 PHP/FI Rasmus Lerdorf's C CGI binaries. A toolkit, not yet a language. PHP 3 Suraski and Gutmans rewrite the parser. Now it is a language. PHP 4 Zend Engine. User input becomes variables by default: register_globals. PHP 5 Real objects at last. The year it got serious for enterprise work. PHP 7 Engine rewrite, 2x faster. By the arithmetic, the PHP2Shell bugs date here. PHP 8 JIT compiler. Still a C program underneath, managing C memory. register_globals off 4.2 turns it off by default after years of injection bugs. Same year: a file- upload buffer overflow. Month of PHP Bugs Stefan Esser publishes dozens of engine-level C bugs in 31 days. CVE-2012-1823 php-cgi reads query strings as command-line flags. Remote code execution, exploited within days. Heartbleed OpenSSL, not PHP. The yardstick Wiz reached for when sizing PHP2Shell. CVE-2019-11043 PHP-FPM pointer underflow in C. Remote code execution on nginx stacks. php-src backdoor Two malicious commits pushed under maintainers' names. Caught by a human reading the diff. CVE-2024-4577 CGI argument injection on Windows. Ransomware exploiting it inside about 48 hours. OCT 2026 · PHP2SHELL Two memory flaws, ten years old, in code behind 70% of the web. Found with frontier models in a week. Millions of exploit attempts within two days of disclosure. Language era Exploit or vulnerability Reference point, not PHP Sources: php.net release history, NVD, CNN (Oct 21, 2026) · Brian Ray LLC
PHP, 1994 to 2026: language eras above the line, exploits below. The bugs behind PHP2Shell date from roughly the PHP 7 era. Open full size

The bug was found by observing, not by reading

Read the Wiz description again. The researchers did not ask a model to read the PHP source and spot the flaw. They had a hypothesis about the memory lifecycle and let AI adapt exploit techniques, run them, analyze the results and adapt again. That is an observation loop: hypothesize, attempt, observe, adjust. The decisive ingredient was not a smarter reader. It was an experimenter that does not get bored on the four hundredth attempt and keeps notes on every one.

Here is the asymmetry that should worry every CTO. The models that found PHP2Shell were commercially available to any engineering organization months before August. Nobody pointed them at php-src's shutdown paths and left them running. The attackers now will, against PHP and against everything else, because the cost of discovery just fell from team-months to one person-week. Your cost of review did not move at all.

The attacker's cost of discovery fell from team-months to one person-week. Your cost of review did not move.

Observational AI in the SDLC would have caught this

I will make the bold claim first and then earn it. Observational AI in the software development lifecycle means instrumented AI agents running an adversarial loop against every change, with everything the loop tries, finds, skips and decides recorded and joined to the diff by session ID, so that humans observe the observers. Had PHP's pipeline run that loop over the last decade, PHP2Shell would in all likelihood have been a line item in a quarterly report rather than a global outage.

Three reasons. First, the bug class has an address. Request shutdown and abnormal termination are a small, well-defined region of the engine. A standing policy of "every diff touching the request lifecycle gets an agent whose only job is to make a request end unexpectedly and read what is left" aims at exactly this. You do not need to search the whole codebase; you need to keep pressure on the one part that handles memory after things go wrong.

Second, the math of chances. It took a week of model time to find. A pipeline that spends one agent-week a quarter on that region gets forty attempts over a decade, each one with better models than the last. The researchers needed one.

Third, observation already works in this codebase; it just does not scale. In 2021 someone pushed two backdoored commits into php-src under the names of its own maintainers. A human reading the diff caught it within hours. That is observational security done by hand. The gap is not whether the technique works. The gap is that a human can read one diff and an agent can run a thousand experiments against it.

So, the number. It is my estimate, not a measurement: a 60% chance that a well-run observational AI pipeline on php-src would have surfaced PHP2Shell before it hit production, and that number rises every quarter the models improve. Compare the rest of the list. Human review of the C code had ten years and found nothing; call it under 5% a year. Conventional fuzzers had ten years and found nothing; the exploit chain is too long for random inputs. Patch speed is 0% prevention by definition; it is recovery. Web firewalls work after someone else has written the signature. Nothing else on the list clears 20%. That makes observational AI during development not just a good defense but the best one available, and the cheapest, since a week of model time costs less than one hour of an airline's web outage.

And PHP is the example, not the limit. Every runtime most companies depend on is a C program underneath: Python's extension modules, Node's native add-ons, the JVM's native layer, every image and compression library. The same loop points at all of them.

If you run PHP today

The patch exists; apply it before you finish reading. Exploit attempts are already in the millions. IBM's view that the attack needs several conditions to line up is correct and is not a reason to wait; it is a reason to assume the attackers are using AI to line them up. Then answer the question Japan's prime minister had to ask the whole country: which of your public systems run PHP, and which version. If that answer took more than ten minutes, that is the first thing the rest of this article fixes.

The counter-offense: run the attacker's loop on your own code first

AI made this exploit practical. The counter is not less AI. It is the same AI, run earlier, by you, with the results observed. Here is the loop, in the order I would stand it up.

  1. Put a frontier model on every diff as an adversary, not a linter.The prompt is not "review this code." It is "make a request end unexpectedly and read what is left," or whatever the equivalent is for the component. The agent gets a sandbox, a build, a budget and the diff. Linters find style; adversaries find keys that still work after checkout.
  2. Fuzz the paths where things go wrong, not the paths where they go right.PHP2Shell lived in abnormal termination. Most test suites and most fuzzers spend their budget on requests that complete. Make coverage of shutdown, error, timeout and cancel paths a tracked number, and let the agent generate the multi-step setups that random fuzzing never reaches.
  3. Join everything by session ID.The diff, the agent's attempts, what it found, what it could not reach, every permission it asked for and every policy decision that answered it. This is the same plumbing as last week's coding-agent telemetry; the hook path and the session ID are already there if you run agents at all. Without the join you have an opinion from a bot. With it you have an audit trail you can defend.
  4. Observe the observers.An agent that reports "no findings" is only useful if you can see what it tried. Attack-path coverage, attempts per diff and time-to-first-finding are the dashboards. A quiet agent with 20% coverage is not a clean bill of health; it is an agent that did not look.
  5. Keep a live runtime inventory with a patch clock.Which services run which runtimes at which version, generated from deployment, not from a spreadsheet. Set the patch SLO in hours. This week the exploit window opened the moment the advisory went out; the organizations that got hurt were the ones still answering "do we run PHP?"
  6. Watch production for the shape of the exploit, not the signature.Cloudflare saw millions of attempts because it observes traffic at scale. Your own observability should already know what a request ending abnormally looks like at normal volume, so a spike reads as an attack hours before anyone publishes a rule.
  7. Budget it as development, not security.One agent-week per quarter per critical component is a token line item. Compare it to the cost of the airline, the bank and the government portals that went dark on Wednesday. This is the cheapest insurance on the list, and it also makes the code better between incidents.

The development techniques that have to change

This is a change to how software gets built, not a product you bolt on at release. The table is the before and after, component by component of the lifecycle.

PracticeHow it has workedHow it has to work now
Code reviewA peer reads the diff for correctness and styleAn agent attacks the diff first; the peer reviews the agent's findings and its coverage
TestingCoverage of the happy pathCoverage of abnormal termination, error and cancel paths as a tracked number
FuzzingRandom inputs against single entry pointsModel-driven multi-step setups that chain requests the way an exploit does
Security reviewA gate at release, onceContinuous, on every merge, with results joined to the session that produced the change
Time to reviewDays, set by human availabilityHours, set by the attacker's time to exploit, which is now about two days
Dependency inventoryA spreadsheet someone updated last quarterGenerated from deployment, with a patch clock measured in hours
Production detectionFirewall signatures written after the first waveBehavioral baselines that flag the shape of an exploit before a rule exists
Who paysThe security budget, after an incidentThe engineering budget, as tokens, before one

The through-line is the same one that runs through everything on this site: you cannot defend what you do not observe. The PHP Foundation did the disclosure right, found the bug in August, patched before telling the world, and still watched airlines go dark, because the defense that would have mattered had to happen in development, years earlier. The techniques above are how that happens from now on.

Where this lands on the four pillars

PerformanceAttack-path coverage and attempts per diff are measured numbers, not sentiments; an agent that did not look is not a clean result.
ROIAn agent-week of tokens per quarter against one hour of an airline's web outage. The arithmetic is not close.
RiskThe attacker's discovery cost collapsed; the only move that restores the balance is running the same loop first, on your own code.
ResponsibilityThe Foundation disclosed well. The next bar is an audit trail that shows what your pipeline tried before a bug reached production.

Key takeaways

  • PHP2Shell was a decade-old C memory-lifecycle bug under 70% of the web; AI did not create it, AI made it cheap to exploit, and the same AI pointed at the code in development could have found it first.
  • The flaw was found by an observation loop (attempt, observe, adapt), not by reading code. That loop belongs in the pipeline on every change, with its attempts and findings joined to the diff by session ID.
  • My estimate, not a measurement: a 60% chance an observed pipeline catches the next PHP2Shell before production, against under 20% for anything else on the list. It is the best defense available and the cheapest.
  • The attacker's time to exploit is now about two days; review, patching and inventory have to run on that clock, which means hours, not sprints.
  • This is a development technique, paid for in tokens from the engineering budget, not a security product bought after the incident.

Discussion

Comments run on Giscus, backed by GitHub Discussions. A GitHub account is required to post; nothing is tracked beyond that.

Want a second set of eyes on your AI stack?

Brian Ray LLC helps leadership teams pick the right tools, cut token spend, and design deployments that hold up under scrutiny.

Start a conversation
Brian Ray

Observational AI consultant and founder of Brian Ray LLC. Previously at Atos, Deloitte, Maven Wave, and Caltech CTME. Author of a forthcoming book on AI observability built around four pillars: Performance, ROI, Risk, Responsibility. LinkedIn

← All field notes