PHP-CGI on Windows Best-Fit Encoding Argument Injection
Windows code-page best-fit character mapping allows unauthenticated remote attackers to inject CLI arguments into PHP running in CGI mode.

- CVE Identifier
- CVE-2024-4577
- CVSS v3.1 Base Score
- 9.8 (Critical)
- Published Date
- Jun 9, 2024
- Scope / Region
- Global
- Affected Products
- PHP 8.1 (< 8.1.29), 8.2 (< 8.2.20), 8.3 (< 8.3.8) in CGI mode on Windows
Technical Summary
Scored 9.8 Critical under CVSS v3.1, CVE-2024-4577 affects PHP 8.1 before 8.1.29, 8.2 before 8.2.20, and 8.3 before 8.3.8 running on Windows with Apache and PHP-CGI under affected locales. Windows converts soft-hyphen characters into standard hyphens, bypassing earlier CVE-2012-1823 mitigations and enabling remote code execution.
The PHP Group released patched versions 8.1.29, 8.2.20, and 8.3.8 and advised administrators to migrate away from legacy PHP-CGI deployments where possible.
Defender Briefing: Mechanism, Impact & Response
What Happened
- When PHP runs in CGI mode (or exposes `php.exe`/`php-cgi.exe` via `ScriptAlias`, as in default XAMPP for Windows) on affected Windows code pages, Windows Best-Fit character conversion turns soft-hyphen (`0xAD` / `%ad`) bytes into `-` when passing command-line arguments to Win32 APIs (DEVCORE).
- This behavior bypassed PHP's earlier CVE-2012-1823 guard, allowing unauthenticated HTTP requests to inject PHP CLI flags such as `-d` and execute arbitrary PHP code (NVD).
Impact
- Scored 9.8 Critical under CVSS v3.1 (`AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`); verified directly exploitable on Windows systems running Traditional Chinese (CP950), Simplified Chinese (CP936), and Japanese (CP932) locales, with default XAMPP for Windows installations exposed (DEVCORE).
What to Do
Disclosure & Patch Timeline
- Disclosed and patched by the PHP development team in PHP 8.1.29, 8.2.20, and 8.3.8.
- CVE record published in NVD and CVE Program catalogs.
Public References
- PHP Group / CVE Program (Primary Record):https://www.cve.org/CVERecord?id=CVE-2024-4577 →
- NVD Vulnerability Record (CVE-2024-4577):https://nvd.nist.gov/vuln/detail/CVE-2024-4577 →
- DEVCORE Security Alert: CVE-2024-4577:https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-vulnerability-en/ →


