PHP2Shell Explained: Understanding CVE-2026–109618 and CVE-2026–109619 from the Memory Up
Two PHP memory-safety flaws are described: one where an out-of-memory condition during request parsing leaves internal state partially initialised, and another where a worker keeps a reference to request-scoped memory after it is freed. An attacker could potentially turn these into memory corruption and remote code execution.
Published on medium.com
Cve
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This is a conceptual explainer rather than a bug bounty report. It walks through two PHP memory-safety vulnerabilities, CVE-2026-109618 and CVE-2026-109619, which the author describes as critical and as leading to Remote Code Execution. The article's stated aim is to show how small mistakes in memory management can become RCE, and it deliberately builds the required background first: processes, stack and heap, allocation, pointers, malloc() and free(), allocators, dangling pointers, Use-After-Free, memory reuse, heap grooming, memory corruption, OOM, memory_limit, partial initialization, invariants, longjmp(), global state, request-scoped memory, PHP workers, worker persistence, the request lifecycle, mod_php, PHP-FPM, producer/consumer patterns, exploitation primitives and RCE.
No target application, endpoint, parameter or HTTP exchange is shown. The two CVEs are discussed at the level of internal state and lifetime, not at the level of a reproducible request.

Setup
The article does not describe a lab, accounts, roles, tool versions or a vulnerable build. What it does establish as the environment model is the PHP execution model itself:
- PHP runs inside a process with program code, global data, a heap for dynamic allocations and a stack for local variables and function calls.
- PHP uses dynamic memory heavily for strings, arrays, hash tables, objects, request data and parser structures, so both CVEs sit in heap and object lifetime management.
- PHP enforces a memory limit, illustrated with:
memory_limit = 128M
- Workers are reused across requests. Under PHP-FPM the master spawns workers:
PHP-FPM master
│
├── Worker 1
├── Worker 2
├── Worker 3
└── Worker 4
and a single worker serves request after request:
Worker 2
Request A
↓
finish
↓
Request B
↓
finish
↓
Request C
- The simplified request lifecycle is:
HTTP request
↓
request startup
↓
input parsing
↓
PHP initialization
↓
application execution
↓
request shutdown
↓
cleanup
↓
worker reused
- With
mod_php, PHP is loaded directly into Apache:
Apache process
┌───────────────────────┐
│ Apache │
│ │
│ PHP module │
│ │
└───────────────────────┘
so a request is handled inside an Apache process that contains the PHP runtime. PHP-FPM instead separates the web server from execution:
Internet
↓
Nginx
↓
FastCGI
↓
PHP-FPM master
│
├── PHP worker
├── PHP worker
└── PHP worker
Apache can also use PHP-FPM. The article notes that lifecycle and failure behaviour differ between the two, which can affect exploitability, and that the demonstrated CVE-2026-109618 path depends on how PHP startup failure and shutdown interact under mod_php.
Finding it
The article does not present a discovery narrative. It presents the two bugs as consequences of two different lifetime mistakes, and it spends most of its length on the primitives needed to see why each mistake is dangerous.
Pointers are not objects
A pointer is a variable containing a memory address. If ptr = 0x5000, the pointer holds the location of the object, not the object:
ptr
│
▼
0x5000
┌─────────────┐
│ Object A │
└─────────────┘
The distinction matters when the lifetime of the object and the lifetime of the pointer diverge.

free() releases ownership, it does not erase
After free(ptr), the memory is not necessarily physically empty. The allocator may leave old bytes in place and may overwrite parts of the region with its own metadata. What changes is ownership:
BEFORE
0x2000 [Object A]
AFTER free()
0x2000 [AVAILABLE]
Accessing the allocation through the old pointer is no longer valid.

The pointer keeps the address
free(ptr) does not generally set ptr = NULL:
Before:
ptr = 0x2000
After:
ptr = 0x2000
The allocator knows the allocation at 0x2000 was released; the variable ptr is just a number and carries no is_free flag.

Dangling pointers and aliases
A pointer to memory whose original allocation is no longer alive is a dangling pointer:
ptr
│
▼
0x2000 [FREE]
The defensive pattern
free(ptr);
ptr = NULL;
does not cover aliases:
ptr1 = 0x2000;
ptr2 = 0x2000;
free(ptr1);
ptr1 = NULL;
leaves ptr2 dangling at the freed allocation.

Use-After-Free and reuse
Using a dangling pointer is a Use-After-Free:
allocate
↓
ptr → Object A
↓
free(Object A)
↓
ptr still contains address
↓
use ptr
↓
USE-AFTER-FREE
Sometimes this crashes the process; sometimes it does something far more dangerous. If the allocator later hands the same region to a new allocation, the old pointer now refers to a different object:
old ptr ──────┐
▼
0x2000
┌───────────┐
│ Object B │
└───────────┘
▲
│
new_ptr ───────┘
The old code still believes ptr → Object A, while reality is 0x2000 → Object B. If the program interprets Object B according to Object A's structure, memory corruption follows.
Heap grooming
Heap grooming is the attempt to influence the arrangement of heap allocations so that reuse becomes predictable:
AAAA | BBBB | CCCC | DDDD
Release BBBB:
AAAA | FREE | CCCC | DDDD
A stale pointer still references that slot. If a later allocation lands there:
AAAA | XXXX | CCCC | DDDD
the stale pointer now references XXXX:
stale pointer
│
▼
AAAA | XXXX | CCCC | DDDD
The article is explicit that a Use-After-Free does not automatically mean RCE; turning memory unsafety into reliable execution control is usually the difficult part.

OOM and partial initialization
OOM means Out Of Memory. With a limit of 128 MB, a process that has accounted for roughly 127 MB and needs another 2 MB cannot proceed:
127 MB used
+2 MB requested
──────────────
129 MB
limit = 128 MB
OOM by itself is not a vulnerability. What matters is the state the program is in when the allocation fails and how that failure is handled. If a structure was being built field by field:
A = initialized
B = initialized
C = initializing
D = not initialized
and an allocation fails, the structure is partially initialized. Other code must not treat [A][B][?][?] as [A][B][C][D]. This is the concept the article calls central to CVE-2026-109618.
Invariants and longjmp()
An invariant is an assumption expected to always hold, for example:
If global_context != NULL,
then global_context points to a fully initialized object.
Code can then safely do:
if (global_context != NULL)
cleanup(global_context);
without rechecking every field. If an unusual error path leaves global_context != NULL while the structure is incomplete, the invariant is broken. The cleanup code is not necessarily wrong by itself; the problem happened earlier, when the system entered a state that was supposed to be impossible.
setjmp() and longjmp() provide non-local control flow. Conceptually, longjmp() means "stop what you are doing and jump back to a previously established recovery point", replacing a chain of returns:
Function C
↓
return error
↓
Function B handles error
↓
return error
↓
Function A handles error
with a direct jump:
Function A
↓
Function B
↓
Function C
↓
ERROR
│
│ longjmp
│
└──────────────► recovery point
This is not inherently insecure. The danger appears when code between those locations temporarily violates invariants and expects normal control flow to restore them.
Request-scoped memory and global state
Much request state only needs to exist while the request is alive:
Request A begins
↓
allocate request memory
↓
process request
↓
Request A ends
↓
release request memory
Other state belongs to the longer-lived worker:
WORKER
│
├── global state
│
├── Request A memory
│
└── other runtime state
The dangerous shape is a global reference pointing into request memory:
global state
│
▼
memory belonging to Request A
When Request A disappears and the global reference survives, it points at freed memory:
global state
│
▼
FREED MEMORY
That lifetime mismatch is the one the article ties to CVE-2026-109619.

Producer and consumer
The producer creates dangerous stale state:
Request A
↓
creates state
↓
state references Request A memory
↓
abnormal path
↓
Request A memory released
↓
reference survives
The consumer later uses it:
Request B
↓
same worker
↓
reads stale state
↓
Use-After-Free
Combined:
PRODUCER CONSUMER
Request A Request B
│ │
▼ ▼
create state same worker
│ │
▼ ▼
free memory ───────────► stale state
│
▼
UAF

Primitives and RCE
A memory corruption bug is not synonymous with RCE. Attackers need useful capabilities, often called primitives: reading memory, writing memory, controlling a pointer, controlling an object field, influencing allocation placement. The progression is:
memory bug
↓
useful memory primitive
↓
stronger control
↓
control-flow manipulation
↓
RCE
The exact chain depends heavily on runtime, allocator, build, architecture and mitigations. RCE also does not automatically mean root: the code starts with the privileges of the compromised process, which for a web service may be an account such as www-data. Further privilege escalation is a separate step.
Exploitation
The article does not give a request-level exploit for either CVE. It gives the state sequences that exploitation has to arrange.
Step 1: understand the CVE-2026-109618 chain
The concepts combine as:
memory_limit
+
OOM
+
partial initialization
+
broken invariant
+
non-local error handling
+
request shutdown
=
memory corruption
The simplified sequence is:
HTTP request
↓
PHP parses input
↓
allocations occur
↓
PHP approaches memory_limit
↓
internal structure starts changing
↓
another allocation is required
↓
OOM
↓
error handling interrupts operation
↓
intermediate state survives
↓
request shutdown
↓
cleanup assumes valid state
↓
memory corruption
The subtle point is that OOM itself is not the vulnerability. PHP can encounter OOM while internal state is temporarily inconsistent, and a later cleanup path can operate on that state under assumptions that are no longer true.

Step 2: time the OOM to the sensitive window
An OOM at an arbitrary location is not the goal. With a 128 MB limit, the attacker does not conceptually want:
100 MB
↓
huge allocation
↓
OOM
The interesting condition is:
Memory almost full
↓
PHP enters interesting operation
↓
state becomes intermediate
↓
next allocation fails
↓
OOM at vulnerable point
The glass analogy: capacity 128 ml, filled to 126 ml. PHP performs +0.5 → OK, +0.5 → OK, the internal state changes, then +3 → OOM. The OOM lands while the program is in the sensitive intermediate state.
Step 3: follow the full CVE-2026-109618 diagram
Attacker-controlled HTTP input
│
▼
PHP parsing
│
▼
memory pressure
│
▼
partial state
│
▼
allocation fails
│
▼
OOM
│
▼
non-local error handling
│
▼
broken PHP invariant
│
▼
request shutdown
│
▼
unsafe cleanup
│
▼
memory corruption
│
▼
possible primitives
│
▼
RCE
Step 4: understand the CVE-2026-109619 chain
The second vulnerability combines a different set of concepts:
request-scoped memory
+
persistent worker
+
global state
+
free()
+
dangling reference
+
next request
=
Use-After-Free
Request A creates a worker global that points at a request object:
Worker global state
GLOBAL
│
▼
0x5000
0x5000
┌────────────────────┐
│ Request A object │
└────────────────────┘
Request A finishes and its request memory is released:
0x5000
┌────────────────────┐
│ FREE │
└────────────────────┘
But the worker still contains GLOBAL = 0x5000:
GLOBAL
│
▼
0x5000 [FREE]
That is stale state.

Step 5: reuse the freed region
A later malloc(...) may reuse the region:
0x5000
┌────────────────────┐
│ New Object B │
└────────────────────┘
Now the global and the new pointer alias the same address:
GLOBAL ──────┐
▼
0x5000
▲
│
new pointer ─┘
The old code may interpret that address according to the old object's type and assumptions, which can lead to memory corruption.
Step 6: land the consumer on the same worker
Process-local state is not shared across workers. If Request A created stale state inside Worker 2, a Request B that reaches Worker 1 does not necessarily see it. The chain is:
Request A
↓
Worker 2
↓
producer
↓
stale state
──────────────
Request B
↓
Worker 2
↓
consumer
↓
Use-After-Free
Worker reuse is therefore fundamental to this vulnerability.
Step 7: follow the full CVE-2026-109619 diagram
REQUEST A
│
▼
Worker X
│
▼
request memory allocated
│
▼
GLOBAL ──────► Object A
│
▼
abnormal lifecycle
│
▼
Request A memory freed
│
▼
GLOBAL ──────► FREE MEMORY
│
│ stale reference
│═════════════════╪══════════════════
│
▼
REQUEST B
│
▼
same Worker X
│
▼
stale GLOBAL accessed
│
▼
USE-AFTER-FREE
│
▼
memory corruption
│
▼
possible primitives
│
▼
RCE
Root cause
The two bugs are two directions of the same class of mistake.
CVE-2026-109618: something is used before it has safely finished becoming valid.
Construction:
████████░░░░
│
💥 OOM
│
▼
incomplete state
│
▼
later treated as valid
The central concept is partial initialization and a broken invariant after OOM. The article's summary is that PHP can be interrupted while building something and later behave as though that thing was safely completed.
CVE-2026-109619: something is used after it has stopped being valid.
Object A
↓
FREE
↓
old reference survives
↓
later access
↓
UAF
The central concept is object lifetime, stale state and Use-After-Free: a worker-persistent global reference outlives the request-scoped memory it points to, and the next request on the same worker consumes it.
The mnemonic the article offers:
109618
──────────────
TOO EARLY
PHP treats something as usable
before its state is safely established.
109619
──────────────
TOO LATE
PHP continues using a reference
after its underlying memory lifetime ended.
The article does not name the affected PHP versions, the specific internal structures, the functions involved, or the patches, so the exact code-level defect for each CVE is not stated here.
Impact
Both CVEs are described as critical and as leading to Remote Code Execution. The path in each case runs from memory corruption through exploitation primitives to control-flow manipulation and then RCE, with the caveat that the exact chain depends on runtime, allocator, build, architecture and mitigations, and that a Use-After-Free does not automatically mean RCE.
The resulting code runs with the privileges of the compromised process, for a web service possibly an account such as www-data; privilege escalation beyond that is a separate step.
The conditions differ between the two:
- CVE-2026-109618 is described through attacker-controlled input that drives PHP parsing and allocation while memory is close to
memory_limit, so that the next allocation fails at the sensitive point. The article ties the demonstrated exploitation path tomod_php, because of how PHP startup failure and shutdown interact there, and notes that PHP-FPM's different lifecycle and failure behaviour can affect exploitability. - CVE-2026-109619 is described through a persistent, reused worker, an abnormal lifecycle that frees request memory while a global reference survives, and a subsequent request that lands on the same worker and consumes the stale reference.
The article does not state which deployments, versions or configurations are affected beyond these conditions.
Fix
The article does not describe a patch, a commit or a configuration change for either CVE. It frames the fixes as design properties:
- For CVE-2026-109618, a robust design must ensure that other code cannot mistakenly treat a partially initialized structure as complete. The article states the problem in terms of what must hold rather than what was changed.
- For CVE-2026-109619, the lifetime mismatch is between request-scoped memory and worker-persistent global state; the article identifies the mismatch but does not state the remediation applied.
Because no patch detail is given, the specific code changes cannot be described here.
Variants to test
These are directions suggested by the concepts in the article, not findings it reports.
- OOM at a sensitive allocation point. Drive parsing of attacker-controlled input while memory sits just under
memory_limit, so that the failing allocation lands mid-construction of an internal structure. A positive result is a request that reaches shutdown with a structure that later cleanup treats as complete, visible as a crash, a sanitizer report, or corrupted state in a subsequent request on the same worker. - Startup failure under
mod_php. Exercise paths where PHP startup fails and shutdown still runs, since the article ties the demonstrated CVE-2026-109618 path to that interaction. A positive result is cleanup operating on state that startup never finished establishing. - Non-local error handling around invariants. Look for
setjmp()/longjmp()recovery points that skip code which would normally restore an invariant. A positive result is a recovery path after which a global pointer is non-NULL but its target is incomplete. - Request-scoped pointer in worker-global state. Look for globals that can be made to reference request memory on an abnormal lifecycle. A positive result is a global still holding an address after the request's memory is released.
- Producer/consumer across requests on one worker. Create the stale state with one request, then send a second request that reads it, pinning both to the same worker. A positive result is the second request interpreting reused memory as the old type, shown by a crash or by controlled data appearing where the old object's fields are read.
- Heap grooming for predictable reuse. Arrange allocations so the freed slot is taken by an object whose contents the attacker influences. A positive result is the stale reference resolving to attacker-influenced data rather than to allocator metadata or an unrelated object.
- Worker reuse assumptions. Compare behaviour under PHP-FPM with several workers against a single worker, and against
mod_php. A positive result is the Use-After-Free reproducing only when the consumer request reaches the worker that produced the stale state, which confirms the process-local nature of the bug.
What happened, in plain words
Two security bugs in PHP, the programming language that powers a large share of the websites you visit, are tracked as CVE-2026-109618 and CVE-2026-109619. The author of the write-up calls both critical and says both can lead to Remote Code Execution, which means an attacker somewhere on the internet could make the server run code of their choosing.
The point of the article is not to hand you a ready-made attack. It is to show that these two bugs come from small, ordinary mistakes in how a program handles its own memory, and that those small mistakes can grow into something very serious. To see that, you first need to know what memory is, how a program asks for it, how it gives it back, and what happens when a web server keeps a program alive between visitors.
The article builds all of that from zero and only then connects it to the two CVEs. This version follows the same path, in the same order, but explains every idea as if you have never opened a terminal.

1. The concepts you need to understand
The article lists the ideas it will use before it uses any of them. Here they are, in its order:
- Process and process memory
- Stack and heap
- Memory allocation
- Pointers and memory addresses
malloc()andfree()- Logical memory release vs physical erasure
- Memory allocator
- Dangling pointers
- Use-After-Free
- Memory reuse
- Heap grooming
- Memory corruption
- Out-of-Memory conditions
memory_limit- Partial initialization
- Program invariants
- Error handling and
longjmp() - Global state
- Request-scoped memory
- PHP workers
- Worker persistence
- Request lifecycle
mod_php- PHP-FPM
- Producer/consumer exploitation patterns
- Memory exploitation primitives
- Remote Code Execution
That is a long list, but each item is small on its own. We go through them one at a time.
2. Processes and memory
When PHP runs, it runs inside a process. A process is simply a running program: the operating system gives it its own virtual address space to work in. Think of it as a flat with its own address and its own front door.
Inside that flat, the memory is divided into rooms with different jobs. The article draws it like this:
PHP process
┌──────────────────────┐
│ Program code │
├──────────────────────┤
│ Global data │
├──────────────────────┤
│ Heap │
│ │
│ Dynamic allocations │
│ │
├──────────────────────┤
│ Stack │
│ Local variables │
│ Function calls │
└──────────────────────┘
Line by line:
- The outer box is the whole process, the private memory the operating system handed to PHP.
- Program code is the instructions themselves, the PHP engine's own machine code.
- Global data is information that lives for as long as the process does, shared by everything inside it.
- Heap is the flexible area where the program puts things it creates while running, such as the text of a form you submitted.
- Stack is the area used while a function is executing, holding its local variables and the record of who called whom.
The operating system gives the process its own virtual address space, meaning the process sees a range of numbered slots it can store things in. The article shows addresses conceptually as:
0x1000
0x2000
0x3000
...
Each line is one address: a number, written in hexadecimal (base 16, which programmers use because it maps neatly onto bytes), that names one location in memory. These numbers are how the program finds its own data again. You can think of them as flat numbers in a building: 0x1000 is one flat, 0x2000 is another.
3. Stack vs Heap
Two of those rooms matter most for the rest of the article: the stack and the heap.
Stack
The stack is tied to function calls. A function is a named block of code that does one job and can be called from elsewhere. When a function runs, it gets a small slice of the stack for its local variables, and that slice is thrown away automatically when the function returns.
The article's example:
void hello() {
int age = 22;
}
Line by line:
void hello() {starts the definition of a function calledhello. The wordvoidmeans it gives nothing back when it finishes.int age = 22;creates a local variable namedage, of typeint(a whole number), and sets it to 22.}closes the function.
age can live on the stack. When hello() returns, its stack frame disappears automatically. The article draws it as:
hello()
STACK
┌──────────┐
│ age = 22 │
└──────────┘
return
STACK
┌──────────┐
│ │
└──────────┘
Before the return, the stack holds the value 22. After the return, the slot is empty, with no action needed from the programmer. That automatic cleanup is the stack's great strength.
Heap
The heap is for things whose lifetime cannot be tied to a function returning. If you upload a photo, the server needs to keep that data around while it processes the request, and it cannot simply vanish when some internal function finishes. So the program asks for a chunk of heap, uses it, and later says when it is done with it.
Conceptually:
ptr = malloc(100)
could produce:
HEAP
0x5000
┌───────────────────┐
│ 100-byte region │
└───────────────────┘
ptr = 0x5000
Line by line:
ptr = malloc(100)asks the memory system for 100 bytes and stores the address it gets back in a variable calledptr.- The drawing shows that the 100 bytes ended up at address
0x5000, and thatptrnow holds the number0x5000.
PHP uses dynamic memory heavily: for strings (text), arrays (lists), hash tables (lookup tables), objects (bundles of data and behaviour), request data, parser structures and other runtime information. Because of that, both CVEs are about heap memory and about how long objects live.
4. Pointers
A pointer is a variable that contains a memory address. That is the whole definition. It does not contain the object; it contains the number of the slot where the object sits.

Suppose:
ptr = 0x5000
Then:
ptr
│
▼
0x5000
┌─────────────┐
│ Object A │
└─────────────┘
Line by line:
ptris the variable, the little label the program uses.- The arrow means "contains the address of".
0x5000is the address itself.- The box is whatever is stored at that address, here called Object A.
The article stresses one distinction:
pointer ≠ object
The pointer contains the location of the object, not the object. A useful comparison: a hotel key card with "Room 42" printed on it is not Room 42. If the hotel later renumbers the rooms, the card still says 42, but it may now open a different room. That is exactly the problem this article is about: when the lifetime of the object and the lifetime of the pointer stop matching.
5. Memory allocation
When PHP needs memory, it asks its memory management system for an allocation. Allocation just means reserving a chunk of memory for a purpose.
Simplifying heavily:
ptr = malloc(size)
Line by line:
mallocstands for "memory allocate". It is a standard C function that hands out a chunk of memory.sizeis how many bytes you want.- The address of the chunk is stored in
ptr.
The allocator finds an available region:
Heap
0x1000 [used]
0x2000 [FREE]
0x3000 [used]
and may return:
ptr = 0x2000
Now:
0x2000 [used]
Line by line:
- The heap is shown as a row of slots.
0x1000and0x3000are already taken;0x2000is free. mallocpicks the free slot and returns its address,0x2000.- The slot is now marked as used, and
ptrholds its address.
The real mechanisms inside PHP and the underlying allocator are more complicated, but this model is enough to follow the vulnerabilities.
6. What free() really means

Suppose:
ptr = 0x2000
0x2000
┌─────────────┐
│ Object A │
└─────────────┘
Then the program performs:
free(ptr);
Line by line:
freeis the counterpart ofmalloc. It tells the memory system that the program is finished with the chunk.ptris the pointer to that chunk, sofree(ptr)releases the chunk at0x2000.- The semicolon just ends the statement.
A common misconception is that the memory becomes physically empty. It does not necessarily. free() primarily means:
This allocation is no longer owned by the caller and may be reused.
Conceptually:
BEFORE
0x2000 [Object A]
AFTER free()
0x2000 [AVAILABLE]
Line by line:
- Before the call, the slot at
0x2000holds Object A and belongs to the program. - After the call, the slot is marked available. The old bytes might still be sitting there, and the allocator may also overwrite parts of the region with its own bookkeeping data.
The important property is that accessing the allocation through the old pointer is no longer valid. Compare it to checking out of a hotel room: the room is not demolished, the furniture is still there, but it is no longer yours and the hotel may give it to someone else at any moment.
7. Why the pointer still contains the address

This surprises many people. Consider:
ptr = malloc(...);
free(ptr);
Line by line:
- The first line asks for some memory and stores its address in
ptr. - The second line releases that memory.
free(ptr) does not generally perform:
ptr = NULL
Line by line:
NULLis a special value meaning "points at nothing".- This line would overwrite the pointer with that special value, so it would no longer hold any address.
Therefore:
Before:
ptr = 0x2000
After:
ptr = 0x2000
The allocator knows that the allocation associated with 0x2000 has been released. But ptr is just a variable containing the number 0x2000. It does not automatically know:
"is_free = true"
Line by line:
- This is not real code; it is a way of writing "the pointer carries a flag saying it is free".
- The point is that no such flag exists. The pointer is a plain number and has no idea whether the memory it names is still valid.
This distinction is fundamental to everything that follows.
8. The memory allocator
The allocator is the part of the system that hands out memory and takes it back. The article compares it to a hotel receptionist who keeps track of rooms:
Room 20 → occupied
Room 21 → occupied
Room 22 → free
Room 23 → occupied
Line by line:
- Each line is one room and its current status.
- Room 22 is the only free one, so it is the one the receptionist can hand out next.
If somebody requests a suitable room, the receptionist can assign Room 22. Similarly:
malloc(...)
↓
allocator searches for suitable memory
↓
returns address
Line by line:
- The program calls
malloc. - The allocator looks through its records for a free chunk big enough.
- It returns the address of that chunk to the caller.
After:
free(ptr);
the allocator can mark that allocation as available for reuse. This does not invalidate every other variable in the program that happens to contain the same address. Going back to the hotel: the receptionist marks Room 22 as free, but every old key card that says "22" still says "22". The receptionist cannot reach into guests' pockets and erase the number.
9. Dangling pointers

Consider:
ptr = 0x2000
followed by:
free(ptr);
We now have:
ptr
│
▼
0x2000 [FREE]
Line by line:
ptrstill holds0x2000.- The slot at
0x2000is marked free. - So the pointer points at memory that no longer belongs to it.
ptr is called a dangling pointer: a pointer that references memory whose original allocation is no longer alive. "Dangling" is a good image: the pointer is hanging in the air, attached to nothing valid.
A common defensive pattern is:
free(ptr);
ptr = NULL;
Line by line:
- Release the memory.
- Immediately overwrite the pointer with
NULL, so it no longer names the freed slot.
But even that does not solve every lifetime problem if aliases exist:
ptr1 = 0x2000;
ptr2 = 0x2000;
free(ptr1);
ptr1 = NULL;
Line by line:
ptr1is set to the address0x2000.ptr2is set to the same address. Two variables now point at the same place; each is an alias of the other.- The memory at
0x2000is released throughptr1. ptr1is set toNULL, which is good hygiene forptr1.
Now:
ptr1 = NULL
ptr2 = 0x2000
↓
freed allocation
Line by line:
ptr1is safe: it points at nothing.ptr2still holds0x2000, which is now freed memory.
ptr2 is still dangling. Setting one pointer to NULL does nothing for its aliases. This is why memory bugs are so easy to introduce: you can fix the pointer you can see and forget the copy you cannot.
10. Use-After-Free
A dangling pointer becomes especially dangerous when the program uses it. Hence the name Use After Free: the program uses memory after it has been freed.
Sequence:
allocate
↓
ptr → Object A
↓
free(Object A)
↓
ptr still contains address
↓
use ptr
↓
USE-AFTER-FREE
Line by line:
- The program reserves memory and points
ptrat Object A. - The program releases Object A.
ptrstill holds the old address, becausefreedoes not clear it.- The program then reads or writes through
ptr. - That is the Use-After-Free.
Sometimes this simply crashes the process. Sometimes it does something much more dangerous, which the next sections explain.
11. Memory reuse
Suppose:
ptr = 0x2000
and then:
free(ptr);
The allocator now knows:
0x2000 = available
Later, another allocation occurs. The allocator may reuse the same region:
new_ptr = 0x2000
Now:
old ptr ──────┐
▼
0x2000
┌───────────┐
│ Object B │
└───────────┘
▲
│
new_ptr ───────┘
Line by line:
- The old pointer still holds
0x2000. - A new allocation was given the same address,
0x2000. - The slot now holds Object B, a completely different thing.
- Both pointers name the same address, but only the new one is legitimate.
The old code may conceptually believe:
ptr → Object A
while reality is:
0x2000 → Object B
If the program interprets Object B according to Object A's structure, memory corruption can follow. This is the hotel key card again: the card says Room 42, the room is now occupied by someone else, and a system that trusts the card will act on the wrong person's room.
12. Heap grooming

This leads to an important exploitation concept: heap grooming. Grooming means deliberately arranging things so that a later event happens where you want it to. Here, the attacker tries to influence the arrangement of heap allocations so that reuse becomes predictable.
Imagine:
AAAA | BBBB | CCCC | DDDD
Line by line:
- The heap is shown as four neighbouring slots, each holding a different object.
- The letters are just labels for four objects.
Then BBBB is released:
AAAA | FREE | CCCC | DDDD
A stale pointer still references that location. If a suitable later allocation occupies it:
AAAA | XXXX | CCCC | DDDD
the stale pointer now references XXXX. Conceptually:
stale pointer
│
▼
AAAA | XXXX | CCCC | DDDD
Line by line:
- The second slot was freed.
- A new object,
XXXX, was placed there. - The old pointer still points at that slot, so it now sees
XXXXinstead ofBBBB.
The goal of heap grooming is to make memory layout and reuse sufficiently predictable for exploitation. It is important to understand that a Use-After-Free does not automatically mean RCE. Turning memory unsafety into reliable execution control is usually the difficult part. In other words: finding the bug is one thing, making it do something useful and repeatable is another, much harder thing.
13. Memory corruption
Memory corruption occurs when a program's assumptions about its memory are violated. The program believed a slot held one thing, and it holds another, or the program wrote past the end of a slot and damaged a neighbour.
Examples include:
Buffer Overflow
Use-After-Free
Double Free
Out-of-bounds read/write
Uninitialized memory
Invalid pointer use
Line by line:
- Buffer Overflow: writing more data into a fixed-size space than it can hold, spilling into whatever is next to it.
- Use-After-Free: using memory after it was released, as above.
- Double Free: releasing the same memory twice, which confuses the allocator's records.
- Out-of-bounds read/write: reading or writing outside the area you were given.
- Uninitialized memory: using a slot before anything was written into it, so you get leftover garbage.
- Invalid pointer use: following a pointer that does not point at anything valid.
The two PHP vulnerabilities discussed here involve different paths toward unsafe memory state.
14. Out Of Memory, OOM
OOM means Out Of Memory. It is what happens when a program asks for memory and there is none left to give, or a limit forbids giving more.
PHP commonly enforces a memory limit such as:
memory_limit = 128M
Line by line:
memory_limitis a PHP setting that caps how much memory one PHP process may use.128Mmeans 128 megabytes.
Suppose PHP has already accounted for approximately:
127 MB
and needs another allocation. Conceptually:
127 MB used
+2 MB requested
──────────────
129 MB
limit = 128 MB
Line by line:
- PHP is already using 127 MB.
- It asks for 2 MB more.
- That would total 129 MB.
- The limit is 128 MB, so the request cannot be granted.
The allocation cannot proceed under that limit. An OOM condition occurs.
OOM itself is not necessarily a security vulnerability. Running out of memory is normal and happens to well-written programs. The vulnerability depends on what state the program is in when the allocation fails and how that failure is handled. That is the key sentence for the first CVE.
15. Partial initialization
Initialization means setting up a structure's fields to their starting values. Partial initialization means stopping halfway.
Imagine PHP needs to create:
Structure X
A
B
C
D
Line by line:
- A structure is a container with several named fields.
- Here it has four fields, labelled A, B, C and D.
Initialization progresses:
A = initialized
B = initialized
C = initializing
D = not initialized
Line by line:
- Field A is done.
- Field B is done.
- Field C is in the middle of being set up.
- Field D has not been touched yet.
Then an allocation fails. The structure is now only partially initialized. A robust design must ensure that other code cannot mistakenly treat:
as:
[A][B][C][D]
Line by line:
- The first line shows the real state: two fields are good, two are unknown.
- The second line shows what the rest of the program might wrongly assume: all four are good.
This concept is central to CVE-2026-109618. A comparison: a form that has been half filled in. If a clerk picks it up and treats it as complete, they will process missing information as if it were real.
16. Program invariants
An invariant is an assumption that programmers expect to always remain true. It is a rule the code relies on without checking every time, because checking everywhere would be slow and noisy.
For example:
If global_context != NULL,
then global_context points to a fully initialized object.
Line by line:
global_contextis a variable that lives for a long time and is visible in many places.!= NULLmeans "is not empty".- The rule says: if this variable holds an address at all, then whatever it points at is fully set up.
Code elsewhere can then safely do:
if (global_context != NULL)
cleanup(global_context);
Line by line:
- Check whether the variable holds an address.
- If it does, run the cleanup routine on whatever it points at.
This is safe only because of the invariant: the check for "not empty" is treated as a check for "fully set up". The programmer does not recheck every field.
If an unusual error path leaves:
global_context != NULL
but the underlying structure is incomplete, the invariant has been broken. The cleanup code is not necessarily wrong by itself. The problem happened earlier, when the system entered a state that was supposed to be impossible. This is an important habit of mind for security work: when something goes wrong, look for the moment the impossible state was created, not only at the place where it finally caused damage.
17. longjmp()
C provides mechanisms such as setjmp() and longjmp() for non-local control flow. Normal control flow is a function returning to its caller, which returns to its caller, and so on. Non-local means jumping out of that chain entirely.
For our conceptual model, think of longjmp() as:
Stop what you are doing and jump back to a previously established recovery point.
Instead of:
Function C
↓
return error
↓
Function B handles error
↓
return error
↓
Function A handles error
Line by line:
- Function C hits a problem and returns an error to Function B.
- Function B sees the error and passes it up to Function A.
- Function A finally deals with it.
That is orderly but slow and verbose. With longjmp() you can conceptually get:
Function A
↓
Function B
↓
Function C
↓
ERROR
│
│ longjmp
│
└──────────────► recovery point
Line by line:
- Function A calls B, which calls C.
- C hits an error.
- Instead of returning step by step, it jumps straight back to a recovery point that A set up earlier.
This is not inherently insecure. It is a legitimate technique. The danger appears when code between those locations temporarily violates invariants and expects normal control flow to restore them. If you jump over the cleanup steps that would have put things back in order, the invariant stays broken, and later code that trusts it will misbehave.
18. Request-scoped memory
PHP handles HTTP requests. An HTTP request is what your browser sends to a website when you open a page or submit a form: a message asking for something. A request in this article means one such visit from start to finish.
A request may cause PHP to allocate memory for:
POST data
uploaded files
strings
arrays
objects
session information
parser metadata
errors
...
Line by line:
- POST data: the contents of a form you submitted.
- Uploaded files: files you sent through the browser.
- Strings: pieces of text.
- Arrays: lists of values.
- Objects: bundles of data and behaviour.
- Session information: data that identifies you across pages, usually tied to a cookie.
- Parser metadata: bookkeeping about how PHP read the incoming request.
- Errors: messages about anything that went wrong.
Much of that state only needs to exist while the current request is alive. That is what request-scoped means: belonging to one request, and expected to disappear when the request ends.
Conceptually:
Request A begins
↓
allocate request memory
↓
process request
↓
Request A ends
↓
release request memory
Line by line:
- A request arrives.
- PHP reserves memory for it.
- PHP does the work.
- The request finishes.
- PHP releases the memory.
This distinction becomes essential for CVE-2026-109619.
19. Global state
Some state belongs to the longer-lived PHP runtime or worker rather than exclusively to one request. Global state is information that lives outside any single request and is visible to everything running in that process.
Conceptually:
WORKER
│
├── global state
│
├── Request A memory
│
└── other runtime state
Line by line:
- The worker is the process handling requests.
- It has global state that outlives requests.
- It has memory belonging to the current request, Request A.
- It has other runtime state, such as configuration and caches.
A dangerous situation appears when:
global state
│
▼
memory belonging to Request A
Line by line:
- A long-lived global variable holds the address of something.
- That something was allocated for Request A, so it is request-scoped.
Request A eventually disappears. If the global reference survives, we can get:
global state
│
▼
FREED MEMORY
Line by line:
- The request ended and its memory was released.
- The global variable still holds the old address.
- So the global now points at freed memory.
That is precisely the kind of lifetime mismatch relevant to CVE-2026-109619.
20. PHP workers

A worker is a process that handles requests. Instead of starting a fresh program for every visitor, PHP keeps a pool of workers ready and hands each incoming request to one of them.
For example:
PHP-FPM master
│
├── Worker 1
├── Worker 2
├── Worker 3
└── Worker 4
Line by line:
- The master is the parent process that manages the pool.
- It has four workers underneath it.
- Each worker is a separate process that can handle one request at a time.
Workers process PHP requests. Crucially, workers are commonly reused:
Worker 2
Request A
↓
finish
↓
Request B
↓
finish
↓
Request C
Line by line:
- Worker 2 handles Request A, then finishes it.
- The same worker then handles Request B.
- Then Request C.
This improves performance because PHP does not need to create a completely new process for every request. Starting a process is expensive; reusing one is cheap. But it also means that bugs involving improperly reset worker state can cross request boundaries. Something left behind by one visitor can be seen by the next visitor who lands on the same worker. That is the heart of the second CVE.
21. Request lifecycle
A simplified PHP request lifecycle looks like:
HTTP request
↓
request startup
↓
input parsing
↓
PHP initialization
↓
application execution
↓
request shutdown
↓
cleanup
↓
worker reused
Line by line:
- HTTP request: the browser's message arrives.
- Request startup: PHP prepares the per-request environment.
- Input parsing: PHP reads the form data, cookies, files and so on.
- PHP initialization: the engine sets itself up to run the script.
- Application execution: your PHP code runs and produces a page.
- Request shutdown: PHP winds the request down.
- Cleanup: memory and resources for the request are released.
- Worker reused: the same process is ready for the next request.
Both CVEs become much easier to understand once we ask:
At which stage does the state become inconsistent?
That question is the whole method. Instead of memorising the bug, find the stage where reality stops matching expectations.
22. mod_php
With mod_php, PHP is loaded directly into Apache, the web server. A web server is the program that listens for browser requests and sends back pages. A module is an optional piece of software plugged into a larger program.
Conceptually:
Apache process
┌───────────────────────┐
│ Apache │
│ │
│ PHP module │
│ │
└───────────────────────┘
Line by line:
- The outer box is one Apache process.
- Apache itself handles the network side.
- The PHP module sits inside the same process, so PHP code runs there too.
A request can therefore be handled inside an Apache process containing the PHP runtime. This integration matters for the demonstrated CVE-2026-109618 exploitation path because of how PHP startup failure and shutdown interact in this environment. In plain terms: when PHP is embedded this way, how a failure during startup and the shutdown that follows interact matters for the demonstrated exploitation path.
23. PHP-FPM
PHP-FPM stands for PHP FastCGI Process Manager. It separates the web server from PHP execution: the web server forwards requests to a separate pool of PHP processes. FastCGI is the protocol they use to talk to each other.
For example:
Internet
↓
Nginx
↓
FastCGI
↓
PHP-FPM master
│
├── PHP worker
├── PHP worker
└── PHP worker
Line by line:
- A visitor's browser reaches Nginx, a web server.
- Nginx passes the request over FastCGI.
- The PHP-FPM master receives it and hands it to one of its workers.
- The worker runs the PHP code and sends the result back.
Apache can also use PHP-FPM. The lifecycle and failure behaviour therefore differ from mod_php, which can affect exploitability. In other words, the same bug may be easier or harder to trigger depending on which of these two setups the site uses, because the two setups start up, fail and shut down differently.
24. Producer and Consumer

This model is especially useful for CVE-2026-109619. It splits an attack into two roles, played by two different requests.
The producer creates dangerous stale state:
Request A
↓
creates state
↓
state references Request A memory
↓
abnormal path
↓
Request A memory released
↓
reference survives
Line by line:
- Request A arrives.
- It causes PHP to create some state, some stored information.
- That state holds a reference, an address, pointing into Request A's own memory.
- Something goes wrong on an abnormal path, an error route rather than the normal one.
- Request A's memory is released as the request ends.
- The reference is not cleared, so it survives.
The consumer later uses it:
Request B
↓
same worker
↓
reads stale state
↓
Use-After-Free
Line by line:
- Request B arrives.
- It is handled by the same worker as Request A.
- That worker still holds the stale state from before.
- Request B reads it, and the read touches freed memory.
So:
PRODUCER CONSUMER
Request A Request B
│ │
▼ ▼
create state same worker
│ │
▼ ▼
free memory ───────────► stale state
│
▼
UAF
Line by line:
- The left column is the producer: Request A creates state and then frees the memory behind it.
- The right column is the consumer: Request B, on the same worker, reads that state.
- The arrow across the middle is the handover: the freed memory becomes stale state for the second request.
- The result is a Use-After-Free.
Thinking in producer and consumer is useful because it tells you what to look for: one action that leaves something behind, and a later action that picks it up.
25. Exploitation primitives
A memory corruption bug is not synonymous with RCE. Exploitation means turning a bug into actual control. A primitive is a small, reliable capability that an attacker builds up along the way, like a single move in a longer game.
Examples include the ability to:
read memory
write memory
control a pointer
control an object field
influence allocation placement
Line by line:
- Read memory: see data the attacker should not see.
- Write memory: change data the attacker should not change.
- Control a pointer: make a pointer hold an address of the attacker's choosing.
- Control an object field: set a specific value inside a structure.
- Influence allocation placement: decide where in memory a new allocation lands.
A simplified exploitation progression is:
memory bug
↓
useful memory primitive
↓
stronger control
↓
control-flow manipulation
↓
RCE
Line by line:
- Start with the bug.
- Turn it into one useful capability.
- Use that capability to gain a stronger one.
- Use the stronger one to influence which code the program runs next.
- Finally, run code of the attacker's choosing.
The exact exploitation chain depends heavily on the runtime, allocator, build, architecture and mitigations. Mitigations are defensive features built into the system to make exploitation harder. This is why a bug that is critical in one setup may be impractical in another.
26. Remote Code Execution
RCE means Remote Code Execution. An attacker can cause the remote system to execute attacker-chosen code. "Remote" means from somewhere else, over the network, without physical access.
Conceptually:
Attacker
│
│ network
▼
Web server
│
▼
vulnerability
│
▼
memory corruption
│
▼
execution control
│
▼
RCE
Line by line:
- The attacker sends traffic over the network.
- It reaches the web server.
- It triggers the vulnerability.
- The vulnerability causes memory corruption.
- The corruption gives control over execution.
- That control becomes RCE.
RCE does not automatically mean:
root
Line by line:
rootis the all-powerful administrator account on a Linux system.- Getting RCE does not hand you that account.
The resulting code normally starts with the privileges of the compromised process. Privileges are the permissions a process has. For a web service that may be an account such as:
www-data
Line by line:
www-datais a common low-privilege account used to run web servers on Linux.- It can read the website files but cannot take over the machine.
Further privilege escalation would be a separate step. Privilege escalation means going from a limited account to a more powerful one.
Part II: Connecting everything to CVE-2026-109618

Now we can understand the first vulnerability properly. The important concepts are:
memory_limit
+
OOM
+
partial initialization
+
broken invariant
+
non-local error handling
+
request shutdown
=
memory corruption
Line by line:
- A memory limit is in force.
- The program hits it and gets an Out Of Memory condition.
- The OOM arrives while a structure is only partly built.
- A rule the code relied on is now false.
- The error handling jumps over the normal cleanup.
- The request shuts down.
- The result is memory corruption.
A simplified sequence is:
HTTP request
↓
PHP parses input
↓
allocations occur
↓
PHP approaches memory_limit
↓
internal structure starts changing
↓
another allocation is required
↓
OOM
↓
error handling interrupts operation
↓
intermediate state survives
↓
request shutdown
↓
cleanup assumes valid state
↓
memory corruption
Line by line:
- A request arrives.
- PHP reads the incoming data.
- It reserves memory as it goes.
- Memory use climbs towards the configured limit.
- PHP begins modifying an internal structure.
- It needs one more allocation.
- The limit refuses it, so an OOM occurs.
- Error handling interrupts the operation partway through.
- The half-built state is not rolled back; it survives.
- The request shuts down.
- The cleanup code assumes the structure is complete.
- It acts on a false assumption, and memory is corrupted.
The subtle point is that OOM itself is not the vulnerability. The problem is:
PHP can encounter OOM while internal state is temporarily inconsistent, and a later cleanup path can operate on that state under assumptions that are no longer true.
Why timing the OOM matters
Imagine a 128 MB limit. An attacker does not conceptually want:
100 MB
↓
huge allocation
↓
OOM
Line by line:
- Memory is at 100 MB.
- A single enormous allocation is requested.
- It fails immediately.
That is an OOM at an arbitrary location, and it is not interesting. The interesting condition is:
Memory almost full
↓
PHP enters interesting operation
↓
state becomes intermediate
↓
next allocation fails
↓
OOM at vulnerable point
Line by line:
- Memory is nearly at the limit.
- PHP starts the operation that matters.
- The structure is now half built.
- The very next allocation fails.
- The OOM lands exactly where it hurts.
Think of a glass:
Capacity: 128 ml
██████████████████░
126 ml
Line by line:
- The glass holds 128 millilitres.
- It is filled to 126.
- There is very little room left.
PHP performs:
+0.5 → OK
+0.5 → OK
internal state changes
+3 → OOM
Line by line:
- A small addition fits.
- Another small addition fits.
- The internal state changes at this point.
- Then a larger addition does not fit, and the OOM occurs.
The OOM occurs while the program is in the sensitive intermediate state. That is the whole trick: not running out of memory, but running out of memory at the right moment.
CVE-2026-109618 in one diagram
Attacker-controlled HTTP input
│
▼
PHP parsing
│
▼
memory pressure
│
▼
partial state
│
▼
allocation fails
│
▼
OOM
│
▼
non-local error handling
│
▼
broken PHP invariant
│
▼
request shutdown
│
▼
unsafe cleanup
│
▼
memory corruption
│
▼
possible primitives
│
▼
RCE
Line by line:
- The attacker sends input they control.
- PHP parses it.
- Parsing pushes memory use up.
- A structure is left partly built.
- The next allocation fails.
- An OOM occurs.
- Error handling jumps out of the normal path.
- A rule PHP relied on is now false.
- The request shuts down.
- Cleanup runs on the broken state.
- Memory is corrupted.
- The corruption may yield exploitation primitives.
- Those may lead to RCE.
Part III: Connecting everything to CVE-2026-109619

The second vulnerability uses a different collection of concepts:
request-scoped memory
+
persistent worker
+
global state
+
free()
+
dangling reference
+
next request
=
Use-After-Free
Line by line:
- Memory belongs to one request.
- The worker outlives that request.
- Some global state lives in the worker.
- The request's memory is released.
- A reference to it is left dangling.
- The next request arrives on the same worker.
- The result is a Use-After-Free.
Suppose Request A creates:
Worker global state
GLOBAL
│
▼
0x5000
0x5000
┌────────────────────┐
│ Request A object │
└────────────────────┘
Line by line:
- The worker has a global variable called
GLOBAL. - It holds the address
0x5000. - At that address sits an object created for Request A.
Request A finishes. Its request memory is released:
0x5000
┌────────────────────┐
│ FREE │
└────────────────────┘
Line by line:
- The slot at
0x5000is now marked free. - Whatever was there is no longer owned by anyone.
But imagine the worker still contains:
GLOBAL = 0x5000
Line by line:
- The global variable was never cleared.
- It still holds the old address.
We now have:
GLOBAL
│
▼
0x5000 [FREE]
Line by line:
GLOBALpoints at0x5000.0x5000is freed memory.
This is stale state. Stale means out of date: it was true once, and it is no longer true.
Memory reuse makes it more dangerous
Later:
malloc(...)
may reuse that region:
0x5000
┌────────────────────┐
│ New Object B │
└────────────────────┘
Line by line:
- A new allocation asks for memory.
- The allocator hands out the free slot at
0x5000. - A new object, Object B, now lives there.
Now:
GLOBAL ──────┐
▼
0x5000
▲
│
new pointer ─┘
Line by line:
- The old global still points at
0x5000. - A new pointer also points at
0x5000. - Both name the same address, but they mean different things.
But the old code may interpret that address according to the old object's type and assumptions. That can lead to memory corruption. If the code expects a customer record and finds a shopping cart there instead, it will read the wrong fields and act on nonsense.
Why the same worker matters
Imagine:
Worker 1
Worker 2
Worker 3
Line by line:
- Three separate processes, each able to handle requests.
Request A creates stale state inside:
Worker 2
Line by line:
- The stale state lives in Worker 2's memory only.
If Request B reaches Worker 1, it does not necessarily see Worker 2's process-local state. Process-local means it exists only inside that one process and is invisible to the others. The relevant chain therefore looks like:
Request A
↓
Worker 2
↓
producer
↓
stale state
──────────────
Request B
↓
Worker 2
↓
consumer
↓
Use-After-Free
Line by line:
- Request A lands on Worker 2.
- It acts as the producer, leaving stale state behind.
- Later, Request B must also land on Worker 2.
- Only then does it act as the consumer and hit the Use-After-Free.
Worker reuse is therefore fundamental to understanding this vulnerability. If the second request goes to a different worker, it does not necessarily see the stale state. The two requests have to land on the same process.
CVE-2026-109619 in one diagram
REQUEST A
│
▼
Worker X
│
▼
request memory allocated
│
▼
GLOBAL ──────► Object A
│
▼
abnormal lifecycle
│
▼
Request A memory freed
│
▼
GLOBAL ──────► FREE MEMORY
│
│ stale reference
│═════════════════╪══════════════════
│
▼
REQUEST B
│
▼
same Worker X
│
▼
stale GLOBAL accessed
│
▼
USE-AFTER-FREE
│
▼
memory corruption
│
▼
possible primitives
│
▼
RCE
Line by line:
- Request A arrives at Worker X.
- The worker reserves memory for it.
- A global variable points at an object belonging to Request A.
- The request ends through an abnormal path.
- Its memory is freed.
- The global still points at the freed memory.
- That is the stale reference, the handover point.
- Request B arrives.
- It must reach the same Worker X.
- It reads the stale global.
- That is the Use-After-Free.
- Memory is corrupted.
- The corruption may yield primitives.
- Those may lead to RCE.
Part IV: The fundamental difference
The easiest way to distinguish the vulnerabilities is this.
CVE-2026-109618
Something is used before it has safely finished becoming valid.
Construction:
████████░░░░
│
💥 OOM
│
▼
incomplete state
│
▼
later treated as valid
Line by line:
- The bar shows a structure being built: most of it is done, the last part is not.
- An OOM interrupts the construction.
- The structure is left incomplete.
- Later code treats it as if it were complete.
The central concept is partial initialization / broken invariant after OOM.
CVE-2026-109619
Something is used after it has stopped being valid.
Object A
↓
FREE
↓
old reference survives
↓
later access
↓
UAF
Line by line:
- An object exists.
- It is freed.
- A reference to it is not cleared.
- Someone uses that reference later.
- That is a Use-After-Free.
The central concept is object lifetime / stale state / Use-After-Free.
A useful memory trick is:
109618
──────────────
TOO EARLY
PHP treats something as usable
before its state is safely established.
109619
──────────────
TOO LATE
PHP continues using a reference
after its underlying memory lifetime ended.
Line by line:
- The first CVE is the too-early mistake: using something before it is ready.
- The second CVE is the too-late mistake: using something after it is gone.
Part V: A completely non-technical explanation
Imagine PHP as a hotel. The PHP worker is one hotel employee. Each HTTP request is a customer.
CVE-2026-109618: The unfinished room
The employee prepares Room 42. He:
- cleans the floor,
- changes part of the bedding,
- starts preparing the bathroom.
Before everything is finished, the room becomes visible to the hotel's internal workflow. Then:
The hotel suddenly runs out of supplies.
The employee has to stop immediately. The room is only half prepared, but another internal process later assumes:
"If Room 42 is in this system, it must be completely ready."
It starts performing operations that only make sense for a properly prepared room. Things go wrong.
That is CVE-2026-109618:
An unexpected OOM interrupts PHP while internal state is incomplete, but later code can operate under assumptions that state was valid.
CVE-2026-109619: The old hotel key
Yanis receives:
Room 42
Line by line:
- A guest is assigned Room 42.
The hotel's system stores:
Yanis → Room 42
Line by line:
- The system records that Yanis is in Room 42.
Yanis leaves. The hotel correctly marks Room 42 as available. But somebody forgot to remove the old reference:
Yanis → Room 42
Line by line:
- The guest has gone.
- The room is free.
- The record still says Yanis is in it.
Alice arrives. The hotel reuses the available room:
Alice → Room 42
Line by line:
- A new guest is given the same room.
The old record still says:
Yanis → Room 42
Line by line:
- The stale record was never updated.
If another system trusts that stale record, it now accesses Alice's room while believing it is still dealing with Yanis's room. That is a Use-After-Free.
In memory:
ptr → 0x5000 [Yanis]
↓
FREE
↓
ptr → 0x5000 [available]
↓
reuse
↓
ptr → 0x5000 [Alice]
Line by line:
- The pointer names a slot holding Yanis's data.
- The slot is freed.
- The pointer still names it, and the slot is marked available.
- The slot is reused.
- The pointer now names Alice's data, while the old code still thinks it is Yanis's.
The address did not necessarily change. What that address represents changed. That is the heart of CVE-2026-109619.
Final mental model
If you remember only one diagram from this article, remember this one:
PHP2Shell
│
┌─────────────┴─────────────┐
│ │
▼ ▼
CVE-2026-109618 CVE-2026-109619
OOM Request A
│ │
▼ ▼
partial initialization global reference
│ │
▼ ▼
abrupt error path memory released
│ │
▼ ▼
broken invariant dangling reference
│ │
▼ ▼
unsafe cleanup Request B
│ │
▼ ▼
memory corruption same worker
│ │
│ ▼
│ Use-After-Free
│ │
└──────────────┬─────────────┘
│
▼
memory corruption
│
▼
exploitation primitives
│
▼
RCE
Line by line:
- The title at the top is the name the article gives to the pair of bugs.
- The left branch is the first CVE: an OOM during construction, a half-built structure, an abrupt error path, a broken rule, unsafe cleanup, memory corruption.
- The right branch is the second CVE: a request leaves a global reference, the memory is released, the reference dangles, a second request on the same worker reads it, and that is a Use-After-Free.
- Both branches meet at memory corruption.
- From there, exploitation primitives may be built.
- And from those, RCE.
The vulnerabilities look complicated because their exploitation involves PHP internals, allocators and heap behaviour. But their underlying ideas are surprisingly simple:
CVE-2026-109618: PHP can be interrupted while building something and later behave as though that thing was safely completed.
CVE-2026-109619: PHP can retain a reference to something after that thing has already been destroyed.
Those two mistakes, using something before it is safely valid and using something after it is no longer valid, are fundamental classes of memory-safety problems. Understanding them provides much more value than memorising these two CVE numbers: the same concepts appear repeatedly across browsers, operating systems, network services, interpreters and security vulnerabilities.
Glossary
- Address: a number naming one location in a process's memory, often written in hexadecimal such as
0x2000. - Alias: a second variable holding the same address as another, so both point at the same memory.
- Allocation: a chunk of memory reserved for a purpose, or the act of reserving it.
- Allocator: the part of the system that hands out memory on request and takes it back when released.
- Apache: a widely used web server program.
- Buffer Overflow: writing more data into a fixed-size space than it can hold, damaging what lies next to it.
- CVE: a public identifier for a known security vulnerability, so people can refer to the same bug unambiguously.
- Dangling pointer: a pointer that still holds the address of memory that has already been released.
- Double Free: releasing the same memory twice, which confuses the allocator.
- Exploitation: turning a bug into actual control over a system.
- FastCGI: a protocol a web server uses to pass requests to a separate PHP process manager.
- Function: a named block of code that performs a job and can be called from elsewhere.
- Global state: information that lives for as long as the process does and is visible to everything inside it, rather than belonging to one request.
- Heap: the memory area used for data whose lifetime is not tied to a function returning.
- Heap grooming: deliberately arranging allocations so that later reuse of memory becomes predictable.
- HTTP request: the message a browser sends to a web server asking for a page or submitting data.
- Initialization: setting a structure's fields to their starting values.
- Invariant: an assumption that programmers expect to always remain true, which other code relies on without rechecking.
longjmp(): a C mechanism for jumping out of the normal chain of function returns back to an earlier recovery point.malloc(): the standard C function that reserves a chunk of memory and returns its address.free(): the standard C function that releases a previously reserved chunk so it can be reused.- Memory corruption: a state where a program's assumptions about its memory are violated, for example because it read or wrote the wrong place.
memory_limit: a PHP setting that caps how much memory one PHP process may use.- Mitigation: a defensive feature that makes exploitation harder.
mod_php: a setup where PHP is loaded directly inside the Apache web server process.- Module: an optional piece of software plugged into a larger program.
- Non-local control flow: jumping out of the normal sequence of function calls and returns.
NULL: a special value meaning "points at nothing".- Object: a bundle of related data and behaviour stored together in memory.
- OOM (Out Of Memory): the condition where a program asks for memory and cannot be given it, often because a limit was reached.
- Out-of-bounds read/write: reading or writing outside the area a program was given.
- Partial initialization: a structure that was only partly set up before something interrupted the process.
- PHP: the programming language most commonly used to build websites.
- PHP-FPM: a process manager that runs PHP in a separate pool of worker processes, apart from the web server.
- Pointer: a variable that contains a memory address rather than the data itself.
- Primitive: a small, reliable capability an attacker builds up during exploitation, such as reading memory or controlling a pointer.
- Privilege escalation: going from a limited account to a more powerful one.
- Privileges: the permissions a process or account has.
- Process: a running program, with its own private memory given to it by the operating system.
- Producer/consumer: a pattern where one action leaves dangerous state behind and a later action picks it up.
- Program code: the instructions a process executes.
- RCE (Remote Code Execution): making a remote system run code of the attacker's choosing.
- Request lifecycle: the stages a request goes through, from arrival to cleanup and worker reuse.
- Request-scoped: belonging to one request and expected to disappear when that request ends.
root: the all-powerful administrator account on a Linux system.- Stack: the memory area used for function calls and their local variables, cleaned up automatically when a function returns.
- Stale state: information that was true once but is no longer true, such as a reference to memory that has been freed.
- Structure: a container holding several named fields together.
- Uninitialized memory: memory that is used before anything was written into it, so it holds leftover garbage.
- Use-After-Free (UAF): using memory after it has been released.
- Virtual address space: the range of numbered memory slots the operating system gives a process.
- Web server: the program that listens for browser requests and sends back pages.
- Worker: a process that handles requests, kept alive and reused for many requests.
- Worker persistence: the property that a worker stays alive across requests, so state can survive from one request to the next.
www-data: a common low-privilege account used to run web servers on Linux.