# CVE-2024-4577: Argument Injection in PHP-CGI

> CVE-2024-4577 is a critical-severity vulnerability with a CVSS 3.1 base score of 9.8, classed as Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (CWE-78), in github.com/php/php-src (Git repository). Affected versions: >= 8.1.0, < 8.1.29; >= 8.2.0, < 8.2.20; >= 8.3.0, < 8.3.8. It is fixed in 8.1.29, 8.2.20 or 8.3.8, depending on the release line. CISA lists it as a known exploited vulnerability (added 12 Jun 2024).

Canonical page: https://cveminer.com/vulnerabilities/CVE-2024-4577

| Field | Value |
| --- | --- |
| CVE | CVE-2024-4577 |
| Other GHSAs | GHSA-3qgc-jrrr-25jv, GHSA-vxpp-6299-mxw3 |
| Severity | Critical |
| CVSS 3.1 | 9.8 `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H` (CVE.org) |
| CWE | CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') |
| EPSS | 99.98% (higher than 99.9% of CVEs) |
| CISA KEV | Listed 12 Jun 2024, due 3 Jul 2024 |
| SSVC | exploitation active, automatable yes, technical impact total |
| Published | 9 Jun 2024 |
| Modified | 21 Oct 2025 |

## Description

In PHP versions 8.1.* before 8.1.29, 8.2.* before 8.2.20, 8.3.* before 8.3.8, when using Apache and PHP-CGI on Windows, if the system is set up to use certain code pages, Windows may use "Best-Fit" behavior to replace characters in command line given to Win32 API functions. PHP CGI module may misinterpret those characters as PHP options, which may allow a malicious user to pass options to PHP binary being run, and thus reveal the source code of scripts, run arbitrary PHP code on the server, etc.

## Affected packages

| Package | Ecosystem | PURL | Vulnerable versions | Fixed in |
| --- | --- | --- | --- | --- |
| https://github.com/php/php-src | GIT | `pkg:github/php/php-src` | >= 8.1.0, < 8.1.29; >= 8.2.0, < 8.2.20; >= 8.3.0, < 8.3.8 | 8.1.29, 8.2.20, 8.3.8 |

## Fix commits

- Pull request: https://github.com/rapid7/metasploit-framework/pull/19247
- Release: https://github.com/php/php-src/commit/fc4973fb0dfae6085742868b8f0f05163e150a0c (8.1.29)
- Release: https://github.com/php/php-src/commit/40298a988fca728ddc47316938da61e0f768c872 (8.2.20)
- Release: https://github.com/php/php-src/commit/ce51bfac759dedac1537f4d5666dcd33fbc4a281 (8.3.8)

## Questions

**What is the CVSS score of CVE-2024-4577?**

CVE-2024-4577 has a CVSS 3.1 base score of 9.8 (Critical), vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.

**Which versions are affected by CVE-2024-4577?**

https://github.com/php/php-src (GIT): >= 8.1.0, < 8.1.29; >= 8.2.0, < 8.2.20; >= 8.3.0, < 8.3.8.

**How do I fix CVE-2024-4577?**

Upgrade to 8.1.29, 8.2.20 or 8.3.8, depending on the release line. The fix is in pull request #19247.

**What is the Package URL (PURL) for CVE-2024-4577?**

The affected package's PURL is pkg:github/php/php-src.

**Is CVE-2024-4577 exploited in the wild?**

CISA lists it as a known exploited vulnerability (added 12 Jun 2024). CISA's SSVC assessment rates exploitation as "active". EPSS estimates a 99.98% chance of exploitation in the next 30 days, higher than 99.9% of CVEs.

## References

- https://github.com/rapid7/metasploit-framework/pull/19247 (fix)
- https://cert.be/en/advisory/warning-php-remote-code-execution-patch-immediately (advisory)
- https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/4xxx/CVE-2024-4577.json (advisory)
- https://github.com/php/php-src/security/advisories/GHSA-3qgc-jrrr-25jv (advisory)
- https://nvd.nist.gov/vuln/detail/CVE-2024-4577 (advisory)
- https://security.netapp.com/advisory/ntap-20240621-0008/ (advisory)
- https://github.com/11whoami99/CVE-2024-4577 (evidence)
- https://github.com/watchtowrlabs/CVE-2024-4577 (evidence)
- https://github.com/xcanwin/CVE-2024-4577-PHP-RCE (evidence)
- https://blog.orange.tw/2024/06/cve-2024-4577-yet-another-php-rce.html (article)
- https://blog.talosintelligence.com/new-persistent-attacks-japan/ (article)
- https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-vulnerability-en/ (article)
- https://www.imperva.com/blog/imperva-protects-against-critical-php-vulnerability-cve-2024-4577/ (article)
- https://github.com/php/php-src (package)
- http://www.openwall.com/lists/oss-security/2024/06/07/1
- https://arstechnica.com/security/2024/06/php-vulnerability-allows-attackers-to-run-malicious-code-on-windows-servers/
- https://isc.sans.edu/diary/30994
- https://labs.watchtowr.com/no-way-php-strikes-again-cve-2024-4577/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PKGTQUOA2NTZ3RXN22CSAUJPIRUYRB4B/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W45DBOH56NQDRTOM2DN2LNA2FZIMC3PK/
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2024-4577
- https://www.php.net/ChangeLog-8.php#8.1.29
- https://www.vicarius.io/vsociety/posts/php-cgi-argument-injection-to-rce-cve-2024-4577
- https://www.vicarius.io/vsociety/posts/php-cgi-os-command-injection-vulnerability-cve-2024-4577

---

Source: CVEminer (https://cveminer.com/vulnerabilities/CVE-2024-4577), compiled from OSV (CVE record), CVE.org, CISA KEV catalog, FIRST EPSS. OSV and GitHub Advisory Database content is licensed CC BY 4.0.
