Skip to content
RCE Write-up Advanced

Critical RCE vulnerability in PHP CGI: everything you need to know

A critical remote code execution vulnerability in PHP CGI on Windows allows unauthenticated attackers to execute arbitrary code via argument injection, bypassing previous protections. Attackers could exploit this to deploy ransomware and webshells.

Merav Bar Follow

Published on wiz.io

Researchers discovered a critical remote code execution vulnerability in PHP CGI, assigned CVE-2024-4577, affecting all Windows versions of PHP CGI. This vulnerability allows unauthenticated attackers to execute arbitrary code on remote servers via argument injection, bypassing previous protections.

Merav Bar, on wiz.io

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 an oversight in PHP's implementation of Windows encoding conversion (Best-Fit feature) allows specific character sequences to bypass the protection for CVE-2012-1823, leading to argument injection.

Impact

Attackers could execute arbitrary code, and the TellYouThePass ransomware gang has exploited it to deploy webshells and ransomware, though exploitation is proven only on Windows systems with Traditional Chinese, Simplified Chinese, and Japanese locales.

What the attacker needed

Windows system; PHP CGI mode or exposed PHP binary; Traditional Chinese, Simplified Chinese, or Japanese locale

The fix

It was fixed by upgrading to PHP versions 8.3.8, 8.2.20, or 8.1.29; temporary mitigations include rewrite rules or disabling PHP CGI.

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.

This is a flaw in how PHP runs on Windows servers. An attacker can send a specially crafted request that tricks the server into running harmful commands, letting them take control. It is serious because no login is needed.

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 Merav Bar

View all

27 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.