Skip to content
RCE Write-up Advanced

php2shell in Practice: Exploitable, Conditional, and Hard to Mass-Exploit

Two pre-auth RCE vulnerabilities in PHP core (php2shell) allow an attacker to trigger an out-of-memory condition during multipart upload parsing, leaving dangling pointers in session globals that can be reused to leak heap data and eventually execute code. Exploitation is heavily version- and build-dependent, and the default display_errors=Off setting makes the required heap layout extremely difficult to achieve.

Michelle Rhodes Follow

Published on praetorian.com

On October 20, details of php2shell, two pre-auth RCE vulnerabilities in the PHP core discovered by Calif (CVE-2026-109618 and CVE-2026-109619), leaked ahead of coordinated disclosure. Advisories listing affected versions followed quickly, along with a flood of PoCs, many AI-generated and non-functional.

Michelle Rhodes, on praetorian.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 of the PS(id) session global variable caused by an out-of-memory error during multipart form parsing, which leaves a dangling pointer that can be reclaimed with attacker-controlled data.

Impact

An attacker could achieve remote code execution, but only under specific conditions: the target must run a vulnerable PHP version with a known build layout, the attacker must win a race to pair two requests on the same worker, and the default display_errors=Off setting makes the heap manipulation extremely difficult.

What the attacker needed

Vulnerable PHP version (e.g., 8.4.26); Apache with mod_php or php -S server; ability to send two requests to same worker; display_errors=Off (default) makes it harder

How it was found

  1. Submit a multipart form with a PHPSESSID field and a PHP_SESSION_UPLOAD_PROGRESS field to enable upload progress tracking.
  2. Trigger the MULTIPART_EVENT_FILE_START branch so that the attacker-controlled progress->sid is copied into PS(id).
  3. Cause php_session_send_cookie to fail (e.g., by triggering an error when display_errors=On, or by precisely triggering an out-of-memory condition during php_url_encode when display_errors=Off) so that PS(send_cookie) remains set to 1.
  4. Trigger an out-of-memory condition that leaves PS(id) pointing to stale data.
  5. On a subsequent request, spray the heap to reclaim the stale PS(id) pointer with an attacker-controlled string object.
  6. Leak adjacent heap data via the Set-Cookie header generated from the attacker-controlled PS(id) value.

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.

PHP has a feature that tracks file upload progress using a session variable. A bug in that feature can leave a stale pointer to memory after an out-of-memory error, and an attacker can reuse that stale pointer to read adjacent memory and eventually run their own code. However, the attacker must know the exact PHP version and build, and the default configuration makes the timing very hard.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Michelle Rhodes

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.