CVE-2024-4577

9.8 CRITICAL

📋 TL;DR

This is a critical PHP CGI argument injection vulnerability affecting Windows servers running Apache with PHP-CGI. It allows attackers to bypass protections and execute arbitrary PHP code on vulnerable systems, potentially leading to complete server compromise. Only Windows systems using Apache with PHP-CGI and certain code page configurations are affected.

💻 Affected Systems

Products:
  • PHP
Versions: PHP 8.1.* before 8.1.29, 8.2.* before 8.2.20, 8.3.* before 8.3.8
Operating Systems: Windows
Default Config Vulnerable: ✅ No
Notes: Only affects Windows systems running Apache with PHP-CGI (not PHP-FPM or other SAPI) and using certain code pages like Traditional Chinese, Simplified Chinese, or Japanese.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full remote code execution leading to complete server takeover, data exfiltration, lateral movement, and persistent backdoor installation.

🟠

Likely Case

Remote code execution allowing attackers to read sensitive files, execute commands, and potentially compromise the entire web application.

🟢

If Mitigated

Limited impact if proper network segmentation, WAF rules, and least privilege principles are implemented.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: CONFIRMED
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Multiple public proof-of-concept exploits exist and active exploitation has been observed in the wild.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: PHP 8.1.29, 8.2.20, 8.3.8

Vendor Advisory: https://www.php.net/archive/2024.php#2024-06-06-1

Restart Required: Yes

Instructions:

1. Identify affected PHP versions. 2. Download and install patched versions from php.net. 3. Restart Apache service. 4. Verify PHP version with php -v.

🔧 Temporary Workarounds

Disable PHP-CGI on Apache

windows

Switch from PHP-CGI to PHP-FPM or other SAPI modules that are not vulnerable.

# Configure Apache to use PHP-FPM instead of CGI
# Comment out AddHandler cgi-script .php in httpd.conf
# Configure PHP-FPM and proxy_fcgi module

Use WAF Rules

all

Implement web application firewall rules to block malicious CGI arguments.

# Example ModSecurity rule: SecRule ARGS "@rx -[drs]" "id:1001,phase:2,deny"

🧯 If You Can't Patch

  • Switch from PHP-CGI to PHP-FPM or another SAPI immediately
  • Implement strict network segmentation and limit access to affected servers

🔍 How to Verify

Check if Vulnerable:

Check if running Windows, Apache with PHP-CGI, and affected PHP versions. Verify code page settings.

Check Version:

php -v

Verify Fix Applied:

Confirm PHP version is 8.1.29, 8.2.20, or 8.3.8 or higher using php -v command.

📡 Detection & Monitoring

Log Indicators:

  • Unusual CGI arguments in Apache logs
  • Requests with special characters in URLs
  • Multiple failed attempts followed by successful exploitation

Network Indicators:

  • HTTP requests containing -d, -s, or -r parameters in URLs
  • Unusual outbound connections from web servers

SIEM Query:

source="apache_access" AND (uri="*%2Dd*" OR uri="*%2Ds*" OR uri="*%2Dr*")

🔗 References

📤 Share & Export