CVE DatabaseCVE-2024-4577
한국어 권고문 →
CVE-2024-45779.8/CRITICALCISA KEVCWE-78CWE-78

PHP-CGI Remote Code Execution (RCE) Vulnerability Urgent Security Advisory (CVE-2024-4577)

⚡ Jump to Patch
Affected Vendors
php, apache
Affected Components
php
Published Date
2024-06-09
CVSS v3.1
9.8
CRITICAL
EPSS (30d)
100.0%
FIRST.org
CISA KEV
Exploited

Executive & SecOps Summary

SECOPS ASSESSMENT
Affected Scope

PHP versions 8.1.x (before 8.1.29), 8.2.x (before 8.2.20), and 8.3.x (before 8.3.8) running on Windows with Apache and PHP-CGI configuration under specific system code pages

Impact

Unauthenticated remote attackers can inject arbitrary command-line options into the PHP binary, leading to remote code execution (RCE) and source code disclosure

Mitigation

Immediately upgrade to patched PHP versions (8.1.29, 8.2.20, 8.3.8 or later) or apply Apache Rewrite rules to block malicious query strings

Affected Products & Version Scope

PHP versions 8.1.x before 8.1.29, 8.2.x before 8.2.20, and 8.3.x before 8.3.8 running on Windows OS with Apache and PHP-CGI. (Commonly found in default XAMPP installations and environments utilizing Apache Action directives)

Remediation & Live Workaround Commands

PATCH & WORKAROUND

1. Official Patch & Version Upgrade Commands

The primary remediation is upgrading PHP to the latest secure releases. For Windows environments utilizing the Chocolatey package manager, execute the following commands to update PHP:

powershell
# Upgrade PHP package via Chocolatey
choco upgrade php --yes

# Verify that the installed version is secure
php -v

2. Temporary Workaround & Hardening Configuration

If an immediate upgrade is not feasible, configure Apache (httpd.conf or .htaccess) to block requests containing the malicious character sequences used to trigger the Best-Fit mapping vulnerability.

nginx
# Add the following Rewrite rules to Apache configuration to block argument injection
<IfModule mod_rewrite.c>
    RewriteEngine On
    # Block soft hyphen and other characters mapped to hyphens on Windows
    RewriteCond %{QUERY_STRING} ^(%2d|%ad) [NC]
    RewriteRule .? - [F,L]
</IfModule>

3. Log Audit & IoC Verification Commands

Use the following PowerShell script to inspect Apache access logs for potential exploitation attempts and verify the local PHP configuration.

powershell
# Scan Apache access logs for PHP-CGI exploit patterns (%ad or %2d)
$LogPath = 'C:\xampp\apache\logs\access.log'
if (Test-Path $LogPath) {
    Select-String -Path $LogPath -Pattern 'cgi-bin' | Select-String -Pattern '%ad|%2d'
}

# Check current PHP version and environment details
$phpVersion = php -v
Write-Host 'Current PHP Version: ' $phpVersion
Interactive SecOps Remediation Checklist
0/4 (0%)
Recommended Security Control & Mitigation Partner
Cloudflare Enterprise & Pro WAF
Organizations running PHP-CGI on Windows must immediately upgrade to the latest patched PHP versions or apply Apache Rewrite rules to mitigate active exploitation.

Block Exploits Instantly with Managed Virtual Patching Rules

Can't patch production immediately? Deploy managed WAF rules at the edge to intercept RCE, SQLi, and deserialization payloads before they hit your origin server.

3-min setup · Automated Zero-Day Managed Rules
Practice Exploiting & Patching This Web Vulnerability in an Interactive Lab
Launch Hands-On Security Lab

Technical Root Cause & Exploitation Mechanics

1. Vulnerability Overview & Root Cause

This vulnerability stems from an unexpected interaction between the Windows operating system's 'Best-Fit' character encoding mapping and the command-line argument processing of PHP-CGI. When converting wide-character Unicode strings to specific ANSI code pages (such as CP949, CP950, or CP932), the Windows Win32 API automatically maps unsupported characters to visually similar ASCII characters (Best-Fit behavior). Consequently, characters like the soft hyphen (0xAD) or full-width hyphen are converted into a standard hyphen ('-', 0x2D). Because PHP-CGI decodes query string parameters into command-line arguments without sufficient validation, these mapped hyphens bypass input filters and are interpreted as command-line options by the PHP binary.

2. Exploitation Mechanics & Attack Scenario

An attacker sends a crafted HTTP request containing specific character sequences (such as '%ad') in the query string. When Apache processes this request and invokes the PHP-CGI binary, the Win32 API translates '%ad' into '-'. This allows the attacker to inject command-line arguments directly into the PHP execution environment. In a typical exploitation scenario, the attacker injects the '-d' option to override PHP configuration directives, enabling 'allow_url_include=1' and setting 'auto_prepend_file=php://input'. By supplying arbitrary PHP code within the HTTP request body, the attacker achieves immediate remote code execution (RCE) on the target server.

3. Infrastructure & Business Impact

With a CVSS score of 9.8 (Critical) and its inclusion in the CISA KEV catalog, this vulnerability represents an active and severe threat. Successful exploitation allows unauthenticated remote attackers to compromise the underlying operating system, leading to complete server takeover, lateral movement within the corporate network, deployment of ransomware, data exfiltration, and severe business disruption.

Official Vendor Advisories & References

NVD Original English 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.

Frequently Asked SecOps Questions (CVE-2024-4577)

FAQ

Q1. How critical is CVE-2024-4577 and is it actively exploited in the wild?

CVE-2024-4577 is rated CVSS 9.8 (CRITICAL) with a 30-day EPSS exploitation probability of 100.0%. It is listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, requiring immediate emergency remediation.

Q2. Which vendors and products are affected by CVE-2024-4577?

Primary impacted vendors include php, apache across php. Scope summary: PHP versions 8.1.x before 8.1.29, 8.2.x before 8.2.20, and 8.3.x before 8.3.8 running on Windows OS with Apache and PHP-CGI. (Commonly found in default XAMPP installations and environments utilizing Apache Action directives)

Q3. What temporary mitigations or workarounds exist for CVE-2024-4577 before patching?

[Mitigation] Immediately upgrade to patched PHP versions (8.1.29, 8.2.20, 8.3.8 or later) or apply Apache Rewrite rules to block malicious query strings Follow the CLI remediation commands and interactive SecOps checklist on this page to restrict exposure prior to your maintenance window.

SECOPS WORKBENCH INTEGRATION

Generate an Internal Engineering Notice or CISO Report for CVE-2024-4577

Instantly format this advisory into an executive CISO summary or engineering patch ticket.

Generate Report →

🔗 Related Advisories in Similar Stack (php)

View Category →
SecOps Advisory Dispatch & RSS Feed

Subscribe to Daily Vulnerability Briefings & KEV Alerts

Concise morning briefings for SecOps, DevSecOps, and SRE teams covering newly exploited CVEs and mitigation priorities.

Slack / Teams / RSS Feed:
PatchKO
CVE-2024-4577 PHP-CGI Remote Code Execution (RCE) Vulnerability Urgent Security Advisory (CVE-2024-4577) (CVSS 9.8) - Patch & Workaround | CVE Pulse