Tech • AI • Robotics • Game

ENFR

I Tested Codex on PHP2Shell: A Frightening Demonstration!

5/10
AIParlons IAOctober 23, 2026 at 03:20 PM15:41
Audio player

TL;DR

Two severe PHP-CGI memory-handling flaws exposed a large share of the web to possible remote code execution, prompting emergency shutdowns, rapid patching and warnings that exploitation could spread before defenses were fully deployed.

KEY POINTS

Why the flaws were so dangerous

PHP underpins online shops, applications and public services, so a server-side compromise can expose databases, disrupt operations and provide a foothold deeper into internal networks. The risk centered on remote code execution, meaning an attacker could seize control of the compromised process without stealing an account or password first.

The first bug: failure during cleanup

One flaw stemmed from how PHP handled memory allocation failures while preparing a request. When an allocation failed, cleanup could begin before certain internal structures were fully initialized, creating a window in which invalid data might be treated as legitimate program structures. That mismatch could redirect execution flow and turn an error-handling path into an attack path.

The second bug: use-after-free

A related weakness involved use-after-free, a classic memory corruption condition in which a program continues using references to memory that has already been released. If that memory region is reused for attacker-controlled content, stale pointers can be leveraged to hijack execution instead of merely crashing the process.

A narrow but critical timing issue

The attack chain relied on a brief interval between memory reservation, request interruption, cleanup and reuse. The sequence was not simple traffic saturation but a precise progression: object creation, interruption in a corrupted state, memory release, then malicious reuse. Reproducing that sequence was key to turning a crash condition into a practical exploit.

Emergency response and public impact

The severity triggered shutdowns of multiple public-facing services, including some municipal, government and tax websites in France. In the United States, the NSA urged immediate protective action, including taking vulnerable systems offline if they could not be patched at once. The pressure came not only from the bug itself but from the lag between patch availability and real deployment across thousands of servers.

Why patching was difficult

Even after fixes became available, operators could not update every server simultaneously. During that gap, any unpatched PHP-CGI deployment remained exposed. The practical dilemma for administrators was stark: keep services online and vulnerable, or suspend them and absorb the cost of interruption.

How defenders investigated the bug

Testing focused on older PHP branches, especially changes between PHP 5.4 and PHP 5.5, and on lab setups using Ubuntu and AddressSanitizer. ASan helped surface memory faults by flagging invalid reads and use-after-free behavior, allowing researchers to trace where the corrupted access occurred and confirm whether a suspected path was real.

AI sped up analysis, but not reliably

Generative coding tools accelerated version comparisons, environment setup and hypothesis building, lowering the barrier to advanced testing. But they also produced false leads, including resurfacing already patched issues as if they were new. In practice, the tools were useful for narrowing possibilities, not for replacing expert judgment in exploit analysis.

Scale changed the threat model

AI-assisted automation also altered offensive scale. Large numbers of parallelized requests and testing attempts can now be launched cheaply and quickly, increasing the speed of reconnaissance and exploit development. That does not make every user a capable attacker, but it does make broad experimentation easier for teams that already understand the underlying systems.

What still limited full exploitation

Turning a proof of concept into a reusable exploit still required overcoming protections such as ASLR, which randomizes memory addresses. To go further, an attacker would need not just the use-after-free condition but also a way to leak internal addresses from the target and make the corruption reliably land on useful memory structures.

CONCLUSION

The PHP-CGI flaws showed how a split-second memory error in a widely deployed language runtime can escalate into an internet-scale crisis. The episode also underscored that while AI can accelerate both defense and attack research, expertise remains the deciding factor in whether a dangerous bug is actually understood and exploited.

Ask a question

More from AI