# CVE-2024-4577: PHP-CGI OS Command Injection

> Attackers can execute arbitrary code or read source code via argument injection in PHP-CGI on Windows with specific code pages.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Yes, since 12 Jun 2024 (CISA KEV), used in ransomware
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 9 Jun 2024
- **Updated:** 21 Oct 2025
- **Also known as:** AZL-42424, AZL-42433, BIT-libphp-2024-4577, BIT-php-2024-4577, BIT-php-min-2024-4577, ECHO-96a3-1302-f796, GHSA-3qgc-jrrr-25jv, GHSA-vxpp-6299-mxw3

## What is CVE-2024-4577?

CVE-2024-4577 is a critical command injection vulnerability in Fedoraproject Fedora, published on 9 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-78 (Improper Neutralization of Special Elements used in an OS Command)

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

3 open source packages ship an affected version, including libphp, php and php-min. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libphp` | Bitnami | All versions | 8.1.29, 8.2.20, 8.3.8 |
| `php` | Bitnami | All versions | 8.1.29, 8.2.20, 8.3.8 |
| `php-min` | Bitnami | All versions | 8.1.29, 8.2.20, 8.3.8 |

Products: Fedoraproject Fedora, Php Php.

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

Upgrade libphp to a fixed version for your release line: 8.1.29, 8.2.20 or 8.3.8. US federal agencies must fix it by 3 Jul 2024.

## Is CVE-2024-4577 being exploited?

Yes. Attackers have exploited CVE-2024-4577 in the wild since at least 12 Jun 2024, including in ransomware campaigns.

Public exploit code:

- PHP CGI Argument Injection (CVE-2024-4577) Remote Code Execution PoC (github_poc): https://github.com/watchtowrlabs/CVE-2024-4577
- [漏洞复现] 全球首款利用PHP默认环境（XAMPP）的CVE-2024-4577 PHP-CGI RCE 漏洞 EXP。 (github_poc): https://github.com/xcanwin/CVE-2024-4577-PHP-RCE
- CVE-2024-4577 is a critical vulnerability in PHP affecting CGI configurations, allowing attackers to execute arbitrary commands via crafted URL parameters. (github_poc): https://github.com/TAM-K592/CVE-2024-4577
- 一個測試CVE-2024-4577和CVE-2024-8926的安全滲透工具 (github_poc): https://github.com/Night-have-dreams/php-cgi-Injector
- POC & $BASH script for CVE-2024-4577 (github_poc): https://github.com/11whoami99/CVE-2024-4577
- PHP CGI Argument Injection vulnerability (github_poc): https://github.com/Chocapikk/CVE-2024-4577

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2021-39226](https://insights.sbomify.com/CVE-2021-39226/): Grafana Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2019-5544](https://insights.sbomify.com/CVE-2019-5544/): VMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2024-4947](https://insights.sbomify.com/CVE-2024-4947/): Google Chromium V8 Type Confusion (critical 9.6, exploited in the wild)
- [CVE-2024-4671](https://insights.sbomify.com/CVE-2024-4671/): Google Chromium Visuals Use-After-Free (critical 9.6, exploited in the wild)
- [CVE-2022-3075](https://insights.sbomify.com/CVE-2022-3075/): Google Chromium Mojo Insufficient Data Validation (critical 9.6, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-4577 and fix it if it is affected.

What it is: CVE-2024-4577 is a critical command injection vulnerability in Fedoraproject Fedora, published on 9 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: Yes. Attackers have exploited CVE-2024-4577 in the wild since at least 12 Jun 2024, including in ransomware campaigns.

Affected packages and fixed versions:
- libphp (Bitnami): affected all versions; fixed in 8.1.29, 8.2.20, 8.3.8
- php (Bitnami): affected all versions; fixed in 8.1.29, 8.2.20, 8.3.8
- php-min (Bitnami): affected all versions; fixed in 8.1.29, 8.2.20, 8.3.8

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-4577/ (Markdown: https://insights.sbomify.com/CVE-2024-4577/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-4577
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-4577
- OSV: https://osv.dev/vulnerability/CVE-2024-4577

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-4577/
Summaries are generated and may contain mistakes; the official description above is the record.
