SecPod

Learn Search

Search across all Learn content

← Back to Security Research
RCE Flaw Discovered in PHP’s Windows Versions

RCE Flaw Discovered in PHP’s Windows Versions

The well-known open-source scripting language PHP (Hypertext Preprocessor) just had a critical RCE flaw patched and disclosed. Found and reported by security researcher Orange Tsai, CVE-2024-4577 affects the PHP-CGI module in the Windows version and impacts all releases post 5.x.

Jun 9, 2024By Meghana Raatni3 min read

The well-known open-source scripting language PHP (Hypertext Preprocessor) just had a critical RCE flaw patched and disclosed. Found and reported by security researcher Orange Tsai, CVE-2024-4577 affects the PHP-CGI module in the Windows version and impacts all releases post 5.x.

The flaw, which involves an OS command injection, is found within the ‘Best-Fit’ feature of encoding conversion and allows attackers to execute arbitrary code with specific character sequences. With a rather simple exploitation technique, it has been assigned a CVSS score of 9.8, and Watchtowr has released a public proof-of-concept. Despite attackers scrambling to find vulnerable systems, you needn’t fear; patch details are available in the final section of this blog.

Technical Details

CGI, or Common Gateway Interface, is popularly used to generate dynamic content on web pages. PHP-CGI is a protocol that transfers information between CGI scripts and web servers, parsing HTTP requests and sending them to PHP command-line interpreters. The parsing involves the conversion of unicode characters to ASCII.

PHP command line arguments begin with hyphens, which have a Unicode value of 0x2D. These are, of course, escaped during parsing to prevent code injections. Unnoticed by the developers, however, there exists another type of Unicode hyphen! The sneaky ‘soft hyphen’, with a value of 0xAD, is not escaped during parsing since it isn’t registered as a real hyphen.

Now, this wouldn’t be a problem, if not for the ‘Best Fit’ feature. While the interpreter does its job, it will see a soft hyphen, assume that the user meant to add in a real hyphen instead, and interpret 0xAD as 0x2D – without escaping it. This means that data from the HTTP request can be interpreted as command-line PHP arguments! With this information, it’s rather easy to construct a POST request containing 0xAD characters and achieve remote code execution.

Impact and Products Affected

This CVE affects every version of PHP for Windows below PHP 8.3.8, PHP 8.2.20, and PHP 8.1.29 with PHP-CGI enabled. Exploitation can reveal the source code of scripts and let attackers run arbitrary PHP code on the server.

Since the disclosure of the bug and PoC, many IP addresses have already been found to be scanning for vulnerable servers. The sheer range of affected versions implies a great number of impacted servers worldwide.

Solutions and Remediations

Users who have supported (not EOL) versions of PHP for Windows can upgrade to PHP 8.3.8, PHP 8.2.20, or PHP 8.1.29 with patch management tools like SanerNow.

Others can apply a mod_rewrite rule to prevent attacks, like so:

RewriteEngine OnRewriteCond %{QUERY_STRING} ^%ad [NC]RewriteRule .? – [F,L]

XAMPP has a ‘ScriptAlias’ directive in the Apache configuration file (usually at ‘C:/xampp/apache/conf/extra/httpd-xampp.conf’). Users who don’t need PHP-CGI can comment said directive out.

FastCGI, PHP-FPM, and Mod-PHP are all more secure alternatives to PHP-CGI, and it is recommended to migrate to one of them.

Instantly Fix Risks with SanerNow Patch Management

SanerNow patch management is a continuous, automated, and integrated software that instantly fixes risks exploited in the wild. It supports all major operating systems, such as Windows, Linux, and macOS, as well as 550+ third-party applications.

It also allows you to set up a safe testing area to test patches before deploying them in a main production environment. SanerNow patch management additionally supports a patch rollback feature in case of patch failure or a system malfunction.

Experience the fastest and most accurate patching software here.

Featured Posts

Open Beyond GitLab's Critical RCE: What CVE-2026-97229 Reveals About Exploitation, Patch Gaps, and Security Response
vulnerability researchBeyond GitLab's Critical RCE: What CVE-2026-97229 Reveals About Exploitation, Patch Gaps, and Security Response

CVE Research

Beyond GitLab's Critical RCE: What CVE-2026-97229 Reveals About Exploitation, Patch Gaps, and Security Response

Nov 6, 2026

Open Gorbag Targets Ukrainian Organizations with BeautyStealer and WinRAR Exploitation
malware researchGorbag Targets Ukrainian Organizations with BeautyStealer and WinRAR Exploitation

CVE Research

Gorbag Targets Ukrainian Organizations with BeautyStealer and WinRAR Exploitation

Gorbag uses spearphishing and weaponized WinRAR archives to deploy BeautyStealer against Ukrainian organizations. The malware steals browser credentials, VPN configuration files, and targeted documents before exfiltrating the data and deleting itself.

Nov 5, 2026

Open Synology NAS Under Siege: C3RB3R Ransomware Strikes Unpatched Devices
vulnerability researchSynology NAS Under Siege: C3RB3R Ransomware Strikes Unpatched Devices

CVE Research

Synology NAS Under Siege: C3RB3R Ransomware Strikes Unpatched Devices

Synology has warned customers about an ongoing wave of ransomware attacks targeting network-attached storage (NAS) devices running outdated versions of DiskStation Manager (DSM). The attacks have been associated with C3RB3R ransomware, a threat capable of encrypting stored files and demanding payment for their recovery.

Nov 4, 2026

Open CISA KEV Exploitation in October 2026: Threat Actors, CVEs and Attack Trend
threat intelligenceCISA KEV Exploitation in October 2026: Threat Actors, CVEs and Attack Trend

CVE Research

CISA KEV Exploitation in October 2026: Threat Actors, CVEs and Attack Trend

Nov 4, 2026