Skip to content
RCE Write-up Advanced

PHP2Shell: Two Vulnerabilities, One Serious Risk

Two critical PHP memory-safety flaws were disclosed: one where an out-of-memory condition leaves request data half-initialised, and one where a worker reuses freed request state. Unauthenticated attackers could potentially turn either into remote code execution on vulnerable installations.

medium.com

Published on medium.com

🚀An overview of the reported flaws, their potential impact, and why PHP security updates matter.

CyberSec Sentinel, 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 memory-safety errors in PHP's request handling: incomplete initialisation after an out-of-memory error, and stale references to freed request state reused by the next request on the same worker.

Impact

An attacker could run commands as the PHP process account, potentially reading data and credentials, altering the site, crashing services, or pivoting to connected systems; the text notes these are potential outcomes, and that a WAF or restricted access only reduces risk rather than replacing the patch.

What the attacker needed

Internet-facing PHP install; vulnerable PHP version; no login needed

The fix

It was fixed in PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35, with services restarted afterwards; interim mitigations such as disabling session upload progress or limiting request size are stopgaps only.

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 is the software many websites use to build pages on the server. These two bugs are mistakes in how PHP manages its working memory while handling a request, so a specially crafted request can confuse it into running the attacker's commands. The attacker does not need an account, and the problem sits below the website's own login checks.

What is RCE?

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

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.