Skip to content
Memory corruption Write-up Advanced

PHP2Shell(CVE-2026–109618 and CVE-2026–109619): Everything You Need to Know: Part 4 — Stage 2

A use-after-free in PHP's session handling lets an attacker overwrite freed memory that a stale session ID pointer still references, causing PHP to read a forged length and leak heap data in the Set-Cookie header. The leaked heap base is then used in later stages of the exploit chain.

Albert Lab Follow

Published on medium.com

PHP2Shell(CVE-2026–109618 and CVE-2026–109619): Everything You Need to Know: Part 4 — Stage 2

Albert Lab, on medium.com

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a use-after-free: an out-of-memory bailout skips clearing the session ID pointer, leaving it dangling to freed memory that attacker-controlled form data later reuses.

Impact

An attacker could leak heap memory addresses, which is a step toward further exploitation; the text does not claim direct code execution in this stage.

What the attacker needed

Ability to send multipart form data; trigger an out-of-memory condition; same PHP worker reused

How it was found

  1. Trigger an out-of-memory condition during a PHP session so the session ID string is freed but the pointer remains.
  2. Send a multipart form with many fields so one field's value is allocated over the freed session ID memory.
  3. Include a crafted field whose bytes set a fake length in the reused memory.
  4. Observe the Set-Cookie header returning heap data beyond the original session ID length.
  5. Derive the heap base from the leaked pointers.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When PHP handles a session, it keeps a pointer to the session ID string. If memory runs out, PHP abandons cleanup and the memory is freed, but the pointer is not cleared. Later, an attacker sends form fields that reuse that freed memory with crafted bytes, so PHP reads a fake length and copies extra memory into a cookie, revealing internal addresses.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Albert Lab

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.