Skip to content
HN On Hacker News ↗

PHP2Shell Deep Dive — CVE-2026-109618 & CVE-2026-109619 OOM to RCE Exploit Analysis

▲ 45 points • 11 comments • by moebrowne • 2w ago • HN discussion ↗

Pangram verdict · v3.3

We believe that this text is a mix of AI and human-written content.

66 %

AI likelihood · overall

Mixed
34% human-written 66% AI-generated
SEGMENTS · HUMAN 15 of 31
SEGMENTS · AI 14 of 31
WORD COUNT 1,499
PEAK AI % 100% · §1
Analyzed
Nov 10
backend: pangram/v3.3
Segments scanned
31 windows
avg 48 words each
Distribution
34 / 66%
human / AI fraction
Verdict
Mixed
Pangram v3.3

Article text · 1,499 words · 31 segments analyzed

Human AI-generated
§1 AI · 100%

I started writing this research on October 26, 2026, and I'm not entirely sure when I'll finish it. At the time of writing, there is still very little information available about PHP2Shell, particularly when it comes to detailed technical analysis of the vulnerabilities and the exploitation process. Honestly, I was getting tired of finding explanations that only scratched the surface without actually showing what was happening internally. I wanted to do something different: a proper, in depth technical walkthrough that explores the entire process, examining every important detail and explaining not just WHAT happens, but WHY and HOW it happens. This research is based on my own understanding of the PHP source code, my experiments, and the investigations I've conducted while trying to understand these vulnerabilities. I wanted to put all these pieces together, share my findings, and hopefully make some of the underlying concepts easier to understand for others. One of my main goals was to make this accessible without sacrificing technical depth. I want someone with basic C knowledge and general programming experience to be able to follow along, even without any previous experience in low level memory exploitation. I also hope this research can help clarify some of the things that are currently poorly explained or misunderstood. However, I want to be transparent: this is my own technical understanding of the vulnerabilities, not an official analysis or an infallible reference. I'm still learning, investigating, and connecting the dots myself. There may be mistakes, inaccuracies, or things I've misunderstood along the way. If you notice something incorrect, have a different interpretation, or think something deserves further investigation, please don't hesitate to contact me. I'd genuinely appreciate corrections, discussions, and contributions that could help make this research more accurate and useful to everyone. After all, the whole point of sharing this is to learn together and help more people understand what's actually happening under the hood.

§2 AI · 100%

Quick Navigation Already familiar with the basics??

§3 Human · 0%

Jump straight to the part you care about: Before we start: stack vs heap, memory allocation basics How is This Dangerous?: the tale of the stale pointer, UAF reads and writes The Stale Pointer: where it comes from:the UAF origin story inside PHP's session + OOM interaction Building the attack request: the actual HTTP request that triggers the OOM The Goal: what we need to leak and why (heap pointer + code pointer) The Target Struct: zend_string: the struct PHP reads when building the session cookie Reclaiming the Memory: Request #2 and the target zend_string struct Heap Grooming Deep Dive: how we position forged data into the exact right memory slot The multipart_buffer_read_body Mystery: the hidden allocation that almost broke my brain Two Leaks Not One: why the heap leak and code leak need different calibrations Code Leak (Stage 3): leaking a function pointer to defeat ASLR Fingerprinting: how we know we got the right pointer Parsing the Heap Leak: finding the chunk base in 256 bytes of chaos The 1+8 Pipeline: how both leaks are actually delivered Reusing the Allocator to Forge a Structure: the pDestructor hijack idea The Trigger: PHP does the dirty work, real zend_hash_destroy code Three Structures in One: ForgedArray + FakeExecuteData + FakeString in 384 bytes Final Payload (Stage 4): forging a HashTable to hijack pDestructor and get RCE The Primer Mechanism: how the freed primer's ghost in bucket[2] triggers the destruction chain Command Output Trick: finding your own TCP socket in /proc The Full Pipeline: all four stages end to end Calibrating for a Different Build: how every number comes from heap analysis of a specific PHP build Real World Friction: why this attack is way harder on a real production server Steal My Bitcoin CTF: the challenge that started all this Acknowledgements: credits and references If you're new to heap exploitation or want the full experience, just keep scrolling.

§4 Human · 3%

I wrote this to be read start to finish.

§5 Human · 0%

Before we start There are a few things everyone should keep in mind before we dive in.

§6 Human · 0%

They'll become particularly useful as we progress through the research.

§7 AI · 100%

As I mentioned earlier, I want this walkthrough to be accessible to everyone, so I'll take the time to explain even the more fundamental concepts. If you're already familiar with them, feel free to skip ahead!

§8 Human · 0%

Stack vs.

§9 Human · 0%

heap In a typical program, memory is organized into different regions, including the stack and the heap.

§10 Human · 0%

For example, in C++: int main() { int a = 30; // Typically stored on the stack int* b = new int(30); // b is typically on the stack, // but the integer it points to is on the heap } Here, a is a local variable containing the value 30.

§11 Human · 0%

The pointer b is also a local variable, but it contains the address of an integer allocated on the heap.

§12 Human · 0%

How memory allocation works PHP is written mainly in C, so we have to understand how memory allocation works. The OS provides a process with its own virtual address space.

§13 Human · 0%

The process's memory allocator then manages allocations within the memory available to it. For example, in C++, we have new, malloc(), and other ways to allocate memory.

§14 AI · 100%

Allocators often try to reuse freed memory instead of requesting new memory from the OS every time.

§15 AI · 100%

Also, when an object's lifetime ends, the data that was stored in its memory isn't necessarily erased immediately.

§16 AI · 100%

That memory can simply be marked as available for reuse.

§17 Human · 0%

To better understand this, let's take a small look at the following code: #include <cstdlib> #include <iostream> int main() { void* a = malloc(64); free(a); void* b = malloc(64); std::cout << a << "\n" << b << std::endl; free(b); return 0; } Here, when we print a and b, we may find that they contain the same numerical memory address.

§18 Mixed · 51%

Why?

§19 AI · 100%

Because malloc() may reuse the memory previously allocated to a after we call free(a), avoiding the need to obtain another block of memory. This isn't guaranteed to happen every time, but it's a common behavior.

§20 AI · 100%

How is This Dangerous?

§21 AI · 100%

The Tale of the Stale Pointer This brings us to the core of the issue.

§22 AI · 100%

We know that memory gets recycled, but what happens to the variables that were holding those memory addresses? When you call free(a), the memory allocation system simply updates its internal records to mark that chunk of memory as available for reuse. However, the data inside that memory is not wiped clean, and the pointer variable itself doesn't magically reset to NULL. Unless the programmer explicitly clears it the pointer continues to hold the exact same memory address it did before. This leftover variable is what we call a stale pointer (or a dangling pointer). Having a stale pointer can be dangerous in several ways. Two of the most critical are reading data that no longer belongs to the original object, and corrupting a new object by writing through the old pointer. Reading another object's data (Use-After-Free) Imagine we allocate memory for a user account: struct User { char username[24]; int is_admin; }; int main() { // 1. Allocate memory for a user User* a = (User*)malloc(sizeof(User)); // Initialize the original user strcpy(a->username, "alice"); a->is_admin = 0; // We keep a copy of the pointer to demonstrate the bug User* a_stale = a; // 2.

§23 AI · 100%

Free the memory.

§24 AI · 100%

The object is gone, but a_stale still holds the address! free(a); Now, just after this, suppose the program does another allocation somewhere else, and the allocator reuses the same address: User* b = (User*)malloc(sizeof(User)); strcpy(b->username, "jack"); b->is_admin = 1; So, b now lives exactly where a used to live. But a_stale still points there because we freed a, and nothing updated a_stale. So, the code that still uses a_stale thinks it's looking at Alice's data, but it may actually be accessing Jack's data: if (a_stale->is_admin) { // This may run, even though Alice was never an admin printf("Welcome admin %s\n", a_stale->username); } With this, we may access data we're not supposed to see, such as Jack's username, and the program might make an incorrect authorization decision. Technically, accessing freed memory is "undefined behavior" in C/C++, so the exact result isn't guaranteed depending on the compiler and system.

§25 Mixed · 34%

But this illustrates the underlying problem.

§26 Human · 0%

In reality, however, it's not quite this simple.

§27 Human · 0%

You're probably thinking: "Yeah, this is nice, but..." For this to work, we need a stale pointer in the first place.

§28 AI · 100%

In a real attack, we aren't writing the victim's program, so we can't just intentionally save a pointer to a variable like we did with a_stale.

§29 AI · 100%

The bug has to already exist inside the code... The attacker only gets to influence what lands in that freed memory slot.

§30 Human · 0%

For now, just make sure you understand this deeply, because the answer to that question will be the most important part of the PHP CVEs we're discussing.

§31 Human · 0%

Modifying another object's data (Memory Corruption) Now imagine the opposite: the program keeps using an old pointer to write to memory after it has been freed.