PHPocalypse: Finding, Exploiting, and Disclosing php2shell

Ryan Austin, Thai Duong

[un]prompted II 2026 — The AI Security Practitioner Conference · Day 2 · Stage 1

Overview

This talk, "PHPocalypse: Finding, Exploiting, and Disclosing php2shell," delivered by Ryan Austin and Thai Duong at [un]prompted II, unveils a series of critical remote code execution (RCE) vulnerabilities within the core of PHP. The researchers detail how they leveraged advanced "agentic" research techniques, guided by decades of PHP exploitation experience, to uncover a family of bugs that had remained hidden for over 20 years. These vulnerabilities, collectively dubbed "php2shell," impact a vast array of PHP installations, including popular web servers running Mod PHP and PHP FPM, and affect widely used applications like WordPress, Drupal, and WHMCS.

Watch on YouTube

Visual summary for PHPocalypse: Finding, Exploiting, and Disclosing php2shell by Ryan Austin, Thai Duong
Visual summary for PHPocalypse: Finding, Exploiting, and Disclosing php2shell by Ryan Austin, Thai Duong

Key moments

  1. 0:00 Introduction: Finding 22-year-old RCE in PHP
  2. 4:20 Research methodology and initial agent prompts
  3. 6:10 First RCE finding: Hash table memory limit (Bug 1)
  4. 9:15 Second RCE finding: Session upload progress (Bug 2)
  5. 11:00 Bugs 3 & 4: Application-specific RCE in FPM
  6. 17:00 Live RCE demos on WHMCS, Drupal, WordPress
  7. 20:45 Challenges of disclosure and not publishing full exploit
  8. 23:50 PHP Foundation's efforts to fix the entire bug class

PHPocalypse: Finding, Exploiting, and Disclosing php2shell

Speakers: Ryan Austin, Thai Duong

Conference: [un]prompted II

YouTube: https://www.youtube.com/watch?v=z5zWF_Ut5nw

Overview

This talk, "PHPocalypse: Finding, Exploiting, and Disclosing php2shell," delivered by Ryan Austin and Thai Duong at [un]prompted II, unveils a series of critical remote code execution (RCE) vulnerabilities within the core of PHP. The researchers detail how they leveraged advanced "agentic" research techniques, guided by decades of PHP exploitation experience, to uncover a family of bugs that had remained hidden for over 20 years. These vulnerabilities, collectively dubbed "php2shell," impact a vast array of PHP installations, including popular web servers running Mod PHP and PHP FPM, and affect widely used applications like WordPress, Drupal, and WHMCS.

The significance of these findings cannot be overstated. PHP powers a substantial portion of the internet, and fundamental flaws in its memory management and session handling components expose countless applications to pre-authentication RCE. The talk not only presents the technical intricacies of these bugs and their reliable exploitation but also provides a rare glimpse into the complex and often fraught process of disclosing critical vulnerabilities to open-source projects with limited resources, highlighting the human element and the challenges of patching widespread infrastructure.

Background

▶ Watch: Introduction: Finding 22-year-old RCE in PHP (0:00)

Ryan Austin, with over 20 years of experience in PHP exploitation and 15 years in PHP memory corruption, frames this research within a recurring pattern in vulnerability discovery: "what's old is always new again." His deep understanding of PHP internals, particularly its memory management and hash table implementations, proved crucial in guiding the automated research agent. The team's investigation was spurred by a belief that fundamental, widespread bugs could still exist in core PHP components, despite extensive prior auditing.

Austin traces the lineage of these new findings back through several historical PHP vulnerabilities:

  • 2002 RFC 1867 Heap Overflow: A bug in file uploads, exploited by "Teso Fun," demonstrated early memory corruption issues.
  • 2004 Memory Limit Issue: A direct ancestor to the primary vulnerability discussed, this bug involved an interruption in Zend hash init during hash table creation due to memory limits. Crucially, the original advisory noted multiple similar unaddressed patterns, which over time became default configurations, setting the stage for the current discoveries.
  • 2006 Zend Hash Key Delete/Index: This vulnerability, prevalent during the register globals era, allowed attackers to reset variables and manipulate control flow by unsetting and then re-setting global variables.
  • 2012 Max Input Vars Directive: Ironically, this directive was added as a patch for a hash table collision denial of service (DoS) vulnerability but inadvertently introduced a new RCE vector, a common pattern in PHP's patch history.

With this historical context, the researchers identified several promising areas for investigation: the unserialize function (though previously researched), file/image parsers (deemed less likely to yield strong primitives), opcache (suspicious due to its bytecode optimization), RFC 1867 (multipart file uploads, known for past issues), the session extension, and fundamental core logic issues related to PHP's failure to properly clean up resources during bailout from memory limit errors. Their "agent" (an advanced fuzzer/research tool) was specifically instructed to focus on core PHP script lifetime, memory limit patterns, interactions between zend thread safe and non-thread safe SAPIs, and patterns resembling the Zend hash key delete bug, while avoiding scenarios requiring custom code uploads or direct eval calls. The goal was to find widespread, generic bugs affecting any PHP application.

Key Findings

▶ Watch: First RCE finding: Hash table memory limit (Bug 1) (6:10)

The research yielded a family of four significant vulnerabilities, collectively demonstrating long-standing weaknesses in PHP's core architecture.

  1. Bug 1: Hash Table Finding (Mod PHP RCE)
  • Discovered within two days of initial research, this bug is almost identical in principle to the 2004 memory limit issue.
  • It occurs when adding a string index to an existing hash table. If a memory limit is hit during this operation (specifically within zend_string_init's emalloc call), PHP's bailout mechanism (a longjmp) skips crucial cleanup routines.
  • This leaves a dangling pointer (referred to as 'P') in memory. By reallocating memory in the same request, attackers can manipulate this dangling pointer, leading to a weak but exploitable decrement primitive.
  • This vulnerability results in RCE for Mod PHP installations running PHP 7.3 and above, affecting any PHP file regardless of application-specific code.
  1. Bug 2: Session Upload Progress (Mod PHP RCE with Pointer Leaks)
  • This bug, found in the session upload progress mechanism, provides a more robust exploitation primitive than Bug 1.
  • It allows attackers to leak pointers directly over the wire, which can then be used to forge fake Zvals, fake hash tables, and fake objects.
  • Ultimately, this enables arbitrary zend_function_call execution with attacker-controlled PHP code, leading to full RCE.
  • Like Bug 1, this is a Mod PHP only vulnerability and occurs during pre-script execution, meaning it affects any PHP file before application code even runs.
  • The researchers demonstrated reliable exploitation against default Mod PHP 7 and 8 installations on Ubuntu, Debian, and CentOS, as well as XAMPP on Windows (where the lack of ASLR made exploitation even simpler).
  1. Bug 3: Session Serialization (Application-Dependent RCE for Mod PHP and PHP FPM)
  • After PHP developers indicated a focus on PHP FPM environments, the researchers refined their agent to find vulnerabilities impacting FPM. This led to a critical bug in session serialization (and deserialization).
  • While technically "application-specific," it resides in functions (session_start, session_decode, unserialize, serialize) that are called by virtually every PHP application. Crucially, attackers do not need to control the input to these functions; their mere usage is sufficient.
  • This bug, affecting PHP 5.4 and above (for both Mod PHP and PHP FPM), offers the strongest exploitation primitives without requiring a full corruption chain or pointer leaks.
  • Attackers can "flip a byte" within session files, injecting pop chains for pre-authentication RCE. Many applications, even those that removed direct unserialize calls, remain vulnerable due to existing pop chains.
  • Alternatively, the vulnerability allows for full control over the session file path, enabling the writing of arbitrary PHP files to any writable location using relative offsets.
  • If pop chains are unavailable and no writable path can be found, attackers can inject an SPL object and then leverage type confusion for native execution.
  1. Bug 4: Session Deserialization (PHP FPM RCE)
  • A related bug in session deserialization, affecting PHP 7.0 and above, falls into the same class of vulnerabilities as Bug 3, further emphasizing the systemic nature of these issues in PHP's session handling. The talk gives less specific detail on this bug, but it is part of the same "bug family."

These findings demonstrate a profound and long-standing vulnerability debt within PHP's core, highlighting the effectiveness of guided agentic research in uncovering deeply embedded flaws.

Technical Deep Dive

▶ Watch: Bugs 3 & 4: Application-specific RCE in FPM (11:00)

The core mechanism underpinning many of these vulnerabilities is PHP's handling of out-of-memory conditions and its bailout routine. When emalloc (PHP's internal memory allocation function) fails due to a memory limit, a fatal error is triggered. PHP then attempts to recover by calling zend_bailout, which performs a longjmp. This longjmp bypasses all intermediate C stack frames and cleanup routines, leaving dynamically allocated structures in an inconsistent state, specifically with dangling pointers or partially initialized data.

For Bug 1, the hash table finding, this occurs during the addition of a string index to an existing hash table. The zend_string_init function, called to initialize the key string, attempts an emalloc. If this emalloc fails, the longjmp leaves the hash table in a state where a bucket might point to freed or uninitialized memory, creating a dangling pointer. The researchers found they could reallocate this memory within the same request and, by carefully crafting subsequent operations, achieve a weak decrement primitive that could be leveraged for RCE. This vulnerability specifically impacts Mod PHP because FPM (FastCGI Process Manager) typically bails out and restarts the worker process upon encountering a fatal error during pre-script execution, thus preventing the necessary memory reuse within the same request.

Bug 2, in session upload progress, capitalizes on a similar memory management flaw but offers stronger exploitation primitives. The talk implies that during the processing of multipart form data and session updates, memory corruption can occur that allows for information leakage. By leaking pointers to internal PHP structures (like Zvals and hash tables), attackers gain the ability to accurately craft fake structures in memory. This allows for arbitrary object instantiation and, crucially, the ability to control the arguments and target of a zend_function_call, effectively executing arbitrary PHP code. The lack of ASLR on Windows XAMPP installations made this particularly straightforward, as memory addresses were predictable.

Bugs 3 and 4, concerning session serialization and deserialization, represent the most versatile and widespread of the discoveries, affecting both Mod PHP and PHP FPM. These vulnerabilities exploit the fact that session data, often serialized and stored on disk, can be manipulated.

  • Pop Chain Injection: One of the most potent exploitation techniques involves manipulating the session file to "flip a byte." This allows for the injection of pop chains into the deserialized session data. A pop chain is a sequence of PHP class methods that are automatically called when an object is deserialized (e.g., __wakeup(), __destruct()). By controlling the session data, an attacker can trigger these methods with controlled arguments, leading to arbitrary function calls or RCE within the context of the application. This is particularly effective because many applications, even those that have removed direct unserialize() calls, still have vulnerable pop chains in their codebase.
  • Arbitrary File Write: Another powerful primitive is the ability to control the session file path. By manipulating the session ID or related parameters, an attacker can specify a relative path, causing PHP to write the session file (containing attacker-controlled data) to an arbitrary location on the server. If this location is web-accessible or executable, an attacker can write a PHP shell or other malicious code, achieving RCE. The researchers emphasized that this is possible without pointer leaks, relying solely on relative offsets derived from memory grooming.
  • SPL Object Type Confusion for Native Execution: In scenarios where pop chains are not available or arbitrary file writes are not feasible, the researchers demonstrated that an attacker could inject an SPL object into the session. Through type confusion (where one data type is treated as another), they could achieve native execution, essentially running C code within the PHP process. This is a more complex primitive but provides a fallback for RCE in highly constrained environments.

To make exploitation reliable and efficient, the researchers developed several key optimizations:

  • Reduced Data for OOM Fatal: Initial proof-of-concepts often required over 100 MB of data to trigger the memory limit fatal error. By leveraging a "blank file name expansion" technique, they could achieve the same memory exhaustion with only 2 MB of data over the wire, significantly improving attack efficiency and stealth.
  • Reliable Grooming: Addressing concerns about reliability in multi-threaded environments (like Apache with multiple workers), the researchers devised a method using a "small bounded amount" of requests with different session IDs. This ensures reliable memory grooming and exploitation even under normal traffic conditions, rather than requiring the attacker to reserve all server workers.

The talk briefly shows a hash value associated with the original vulnerability, hinting at the specific internal PHP structures or code sections involved, though the exact translation is not elaborated upon in the presentation.

Demo / Proof of Concept

▶ Watch: Live RCE demos on WHMCS, Drupal, WordPress (17:00)

The talk included compelling real-time demonstrations of the php2shell vulnerabilities being exploited against various widely used PHP applications. These demonstrations were critical in dispelling online skepticism regarding the reliability and applicability of the findings, particularly for PHP FPM environments.

The speaker showcased successful RCE against:

  • Latest WHMCS: Demonstrated using a pop chain injection, leading to immediate code execution.
  • Latest Drupal: Also exploited via a pop chain, highlighting the widespread impact on content management systems.
  • Latest WordPress: This demo specifically utilized the file write primitive to upload a malicious PHP file, proving that direct file system interaction is a viable and fast exploitation method. Crucially, this demonstration was performed against a PHP FPM instance, directly countering online confusion about FPM's exploitability.

All demos were conducted in real-time and completed within a few seconds, underscoring the high reliability and speed of the developed exploits. The speaker emphasized that despite online discussions questioning the reliability or "skill issue" on the part of other attackers, his exploits were developed over two months during the disclosure process, allowing for extensive refinement and optimization for various environments and PHP versions. He noted that his "agent" could easily profile a target and then port the exploit across different versions and distributions of PHP.

Defensive Implications

▶ Watch: PHP Foundation's efforts to fix the entire bug class (23:50)

The discovery of the php2shell vulnerability family carries profound implications for defenders. The fundamental nature of these bugs, residing deep within PHP's core memory management and session handling, means that a vast number of PHP applications are potentially vulnerable.

The most immediate and critical defensive action is to update PHP installations to patched versions as soon as they become available. The disclosure process, as detailed by the speakers, was lengthy and complex, involving two months of collaboration with the PHP Foundation. This effort resulted in significant patches, reportedly involving changes to over 200 files, indicating the depth and breadth of the underlying issues. Users should monitor official PHP releases and distribution updates closely.

Beyond patching, organizations should:

  • Understand the "Bug Family": These are not isolated vulnerabilities but a class of related memory corruption issues. This suggests that similar patterns might exist or could re-emerge, necessitating continued vigilance in code auditing and security practices.
  • Review Session Management: Applications should critically review how they handle PHP sessions, including session serialization formats, storage locations, and input validation for session-related parameters. While these bugs are in PHP's core, good application-level security practices can help mitigate the impact of future zero-days.
  • Monitor for Exploitation Attempts: Defenders should update their intrusion detection and prevention systems (IDS/IPS) signatures to detect common exploitation patterns, such as large data uploads (even optimized to 2MB), attempts to write to unusual file paths, or suspicious session ID manipulations.
  • Support Open-Source Maintainers: The talk highlighted the immense pressure on the small team of PHP Foundation developers (just three individuals) responsible for maintaining a critical piece of global infrastructure. Challenges like developer illness and the need to achieve consensus on complex, breaking changes significantly impact the patching timeline. The speakers explicitly called for financial and community support for projects like the PHP Foundation to ensure the security and stability of widely used software.

The disclosure process itself was described as "ugly" and "complicated," with multiple researchers and distributors involved. Despite best efforts, the vulnerabilities leaked just two days before the coordinated disclosure date. This underscores the difficulty of managing high-impact vulnerability disclosures, especially for foundational software components, and the constant tension between protecting users and the realities of public security research.

Key Takeaways

  • Deep, Long-Standing Vulnerabilities: PHP's core architecture contained critical memory management and session handling flaws for over 20 years, demonstrating the persistence of "vulnerability debt" in widely used software.
  • Effectiveness of Agentic Research: Guided by human expertise, advanced fuzzing and "agentic" research tools proved highly effective in uncovering these deeply embedded, complex memory corruption bugs.
  • Mod PHP and FPM are Both Vulnerable: While the specific attack vectors differ, both Mod PHP and PHP FPM environments are susceptible to RCE, debunking earlier assumptions about FPM's resilience to these types of pre-script execution flaws.
  • Reliable and Versatile Exploitation: The vulnerabilities offer diverse and highly reliable exploitation primitives, including pointer leaks, pop chain injection, arbitrary file writes, and SPL object type confusion for native execution.
  • Critical Need for Patching and Support: Immediate patching of PHP installations is crucial. Furthermore, the talk underscores the urgent need for the wider community to financially and technically support the small teams maintaining critical open-source infrastructure like the PHP Foundation.
  • Complexities of Disclosure: Disclosing widespread, high-impact vulnerabilities is an inherently challenging process, fraught with coordination difficulties, human factors, and the risk of premature leaks.

About the Speaker(s)

Ryan Austin is a seasoned security researcher with extensive experience in PHP exploitation. He has been involved in PHP exploitation for approximately 20 years, with a particular focus on PHP memory corruptions for the past 15 years. His work often involves post-exploitation techniques for hardened environments, such as re-enabling safe mode and bypassing disabled functions. Austin possesses a deep and specialized knowledge of PHP internals, which was instrumental in guiding the "agentic" research that led to the discovery of the php2shell vulnerabilities.

Thai Duong is a security researcher who collaborated with Ryan Austin on the disclosure of these vulnerabilities. While the talk does not provide a detailed biography for Thai, his contributions to the discussion, particularly regarding the complexities of the disclosure process and the challenges faced by open-source maintainers, indicate a strong background in vulnerability research and experience with high-profile disclosures (e.g., mentioning past iOS jailbreak work). He emphasizes the human element in vulnerability response and the importance of supporting core open-source projects.

Reviews

  • Dr. Zero (Offensive Security Researcher) — MUST SEE ★★★★★
  • Heather Calloway (CISO) — MUST SEE ★★★★★

→ Top-rated talks at [un]prompted II 2026 — The AI Security Practitioner Conference

All talks from [un]prompted II 2026 — The AI Security Practitioner Conference