Skip to content
Exploit for Improperly Controlled Sequential Memory Allocation in Php

Exploit for Improperly Controlled Sequential Memory Allocation in Php

Sploitus • October 26, 2026

Unauthenticated remote code execution chain exploiting OOM memory corruption and stale global state in PHP.

| GHSA | GHSA-w8hw-w9fx-j79w | GHSA-6wmf-4rv5-p3rp |

| CVSS v4.0 | 9.2 (Critical) | 9.2 (Critical) |

| Type | RCE via OOM memory corruption | RCE via stale global state (use-after-free) |

| Role in chain | Main exploit — leak + forge + exec | Write primitive + worker state control |

| Disclosed | October 20, 2026 | October 20, 2026 |

| Patched | October 21, 2026 | October 21, 2026 |

| Fixed in | PHP 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12 | PHP 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12 |

### CVE-2026-109618 — OOM Memory Corruption

PHP enforces `memory_limit` using `longjmp()` to abort requests that exceed it. The flaw is that this interruption can happen while internal PHP request structures are **only partially initialized**. The cleanup routine processes that half-initialized data as valid, leaking raw heap and `libphp` pointers into the `Set-Cookie` response header. An attacker reads those pointers to defeat ASLR, then forges fake internal PHP structures that redirect execution to `zif_system()`.

### CVE-2026-109619 — Stale Global State (Use-After-Free)

PHP worker processes retain internal global state pointing to memory owned by a request, even after that memory has been freed. A subsequent request in the same worker can read or branch on those freed regions. In this chain it serves two purposes: the `session.upload_progress` feature acts as the **write primitive** to place forged structures at predictable heap addresses, and deliberate worker rotation via `rotate()` positions that stale state exactly where the OOM corruption stage needs it.

Neither CVE alone is sufficient for reliable RCE — they are chained:

CVE-2026-109619 CVE-2026-109618

───────────────────────────── ──────────────────────────────────────────

session.upload_progress → write primitive: place forged structs

rotate() (stale worker state) → positions freed memory for OOM to land on

OOM longjmp() → partial init → pointer leak

rotate() — Worker Preparation (CVE-2026-109619)

Forces a fresh PHP worker into a known state by sending a large multipart request that exhausts the current worker, then seeds session.upload_progress with a fixed session ID (attacksessionid0001). This ensures the stale freed memory from the request is in the right position for the subsequent OOM stages.

Stage 1 — Heap Base Leak (CVE-2026-109618)

A crafted multipart body exceeds memory_limit, triggering longjmp() mid-initialization. The partially initialized session structure leaks raw Zend MM allocator chunk pointers inside the Set-Cookie: PHPSESSID header. chunk_base_from_cookie() scans for userspace heap addresses (0x7F0000000000–0x7FFFFFFFFFFF) aligned to 2 MB boundaries and extracts the Zend chunk base — ASLR layer 1 bypassed.

Stage 2 — libphp Base Leak (CVE-2026-109618)

A second OOM request leaks a zval_ptr_dtor function pointer from libphp.so through the same cookie mechanism. libphp_base_from_cookie() identifies it by matching the low 12 bits against the known dtor offset and subtracts to get the libphp load address — ASLR layer 2 bypassed.

Stage 3 — Code Execution (CVE-2026-109618 + CVE-2026-109619)

With both bases known, the exploit computes:

- htdata = chunk_base + htdata_offset — address of forged structure in controlled heap

- zif = libphp_base + zif_offset — address of zif_system() in libphp

A fake HashTable + zend_function struct is placed via session.upload_progress at that heap address. When zval_ptr_dtor() fires during cleanup, it follows the forged pointers and calls zif_system(cmd). Output is redirected to a file on the server and retrieved with a plain GET request.

| `zif_system` | `0x43A870` | `0x43A870` |

| `zval_ptr_dtor` | `0x613C50` | `0x613C50` |

Custom offsets can be entered manually at runtime, obtained via reverse engineering the target's `libphp.so`.

- No external dependencies — stdlib only: `socket` `ssl` `struct` `re` `uuid` `threading` `urllib.parse`

[+] Insert the IP address of the domain vulnerable to php2shell (CVE-2026-109618):

[+] PHP endpoint path [/index.php]: /index.php

[+] Command (max 14 bytes) [id>p2sXXX.out]: id>p2sXXX.out

[+] Output path to fetch [/p2sXXX.out]: /p2sXXX.out

[+] Target profile (bookworm/lab) [bookworm]: bookworm

[+] OOM field size in MB (must exceed memory_limit) [12]:

Target format: ` ` or bare IP (defaults to port 80).

> The command is limited to **14 bytes** — it must fit inside the forged structure placed in heap memory. Use output redirection (`id>/tmp/out`) and adjust the fetch path accordingly.

- Works against any PHP endpoint — no LFI required.

- ASLR is bypassed in two layers: Zend heap (stage 1) then libphp (stage 2).

- Worker rotation runs between every stage to maintain a predictable heap layout.

- Reliability depends on heap layout matching the selected profile. Up to 3–5 attempts per stage with rotation between each.

- The OOM field size (`huge_mb`) must exceed the server's configured `memory_limit`.

| Target | PHP 8.3.x (unpatched, intentionally vulnerable) |

| OS | Debian 12 Bookworm — isolated NAT VM |

- Update PHP to 8.2.35, 8.3.36, 8.4.27 or 8.5.12+

- Set `memory_limit = -1` via `php_admin_value` — prevents OOM trigger (CVE-2026-109618)

- Set `session.upload_progress.enabled = 0` in `php.ini` — removes write primitive (CVE-2026-109619)

- On PHP 8.5: also set `fatal_error_backtraces = 0`

- Enforce multipart request size, part count and nesting limits at the web server or reverse proxy level

- [PHP Advisory — GHSA-w8hw-w9fx-j79w (CVE-2026-109618)](

- [PHP Advisory — GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)](

- [PHP Official Release — 8.3.36 / 8.4.27](

- [Datadog Security Labs — PHP2Shell walkthrough](

- [Rapid7 — ETR CVE-2026-109618 & CVE-2026-109619](

- [Palo Alto Unit42 — PHP2Shell Threat Brief](

- [Tenable — PHP2Shell FAQ](

- [CERT-EU Advisory 2026-018](

- [NCSC — Critical Security Issue Affecting PHP](

This tool is provided for **educational and authorized penetration testing purposes only**. Using it against any system without explicit written permission from the owner is illegal and may violate local and international laws. The author assumes no responsibility for misuse or damage caused by this tool. Only use it in environments you own or have written authorization to test.

*By [nostraxiten](