CriticalCVE-2024-4577

    Argument Injection in PHP-CGI (CVE-2024-4577)

    Published In CISA KEV since Sources: NCSC NZ, CVE.org, SingCERT, pwn.watch, OSV, BSI

    What is affected, what to do

    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.

    The vulnerability is being actively exploited; treat it as a priority. CISA lists it as used in ransomware campaigns. Update PHP to version 8.1.29, PHP to version 8.2.20, PHP to version 8.3.8. Immediate actions, mitigation and detection rules are in the runbook below.

    Affected
    • PHP lt 8.1.0..8.1.29
    • PHP lt 8.2.0..8.2.20
    • PHP lt 8.3.0..8.3.8
    Fixed in
    • PHP 8.1.29
    • PHP 8.2.20
    • PHP 8.3.8

    Not sure whether and how you are affected? Ask a question about this vulnerability

    Metrics

    9.8

    Priority

    XIEM Effective CVSS: highest available CVSS rating from NVD and vendor data.

    Source: NVD, CVSS v3

    9.8

    CVSS v3

    Severity Critical on the scale from 0 to 10.

    Source: NCSC NZ, CVE.org, SingCERT, pwn.watch, OSV, BSI

    99.99 %

    EPSS score

    High — model estimates ≥ 50% chance of real-world exploitation within 30 days.

    Source: FIRST EPSS, percentile 99.98

    Show all metrics
    Severity
    Critical
    Priority (0–325)

    The priority score is a consolidated metric that condenses several individual signals into a single, action-guiding ranking: technical severity (CVSS), exploitation likelihood (EPSS), known-exploited status (KEV) and the context of the affected asset. The aim is to answer the only truly important question in vulnerability management: what first?

    Read in glossary
    259.38 Methodology
    Exploit maturity

    An exploit is code or a technique that specifically uses a concrete vulnerability to force unintended behaviour — such as executing code or escalating privileges. It is the tool that turns a theoretical flaw into a practical attack.

    Read in glossary
    actively exploitedSource: VulnCheck KEV (opens in a new tab), NCSC NZ, CSA/SingCERT How we classify
    XIEM Effective CVSS

    XIEM® is the tiered managed-security operating model from NEOSEC and a registered trademark of NEOSEC GmbH. It extends classic SIEM — the central collection, normalisation and correlation of security-relevant events — with endpoint forensics, network visibility and deception technology, and consolidates them into three building tiers: Sentry, Orchestrate and Command.

    Read in glossary
    9.8 Methodology
    CVSS v3

    CVSS is the globally established, open standard for assessing the technical severity of a vulnerability on a scale from 0 to 10. It describes how easily a flaw can be exploited and what damage it can cause — but not how likely its actual exploitation is. CVSS and the complementary EPSS deliberately answer different questions.

    Read in glossary
    9.8
    EPSS score

    The EPSS score is the absolute model output for an individual vulnerability: the estimated probability of real-world exploitation within the next 30 days, expressed as a value between 0 and 1 (i.e. 0 % to 100 %). A score of 0.42 means „the model estimates a 42 % chance of real-world exploitation within 30 days“.

    Read in glossary
    99.99 %
    High — model estimates ≥ 50% chance of real-world exploitation within 30 days.
    EPSS percentile

    The EPSS percentile is the relative position of a vulnerability within all EPSS-scored CVEs, expressed as a value between 0 and 1. A percentile of 0.90 means „this CVE has a higher EPSS score than 90 % of all other scored CVEs“. Unlike the EPSS score, it is not a probability — but a positioning within a ranking.

    Read in glossary
    99.98
    Critical — this CVE ranks in the top fifth of all CVEs scored today (rank ≥ 80%).
    KEV status

    The KEV catalogue is a list maintained by the US authority CISA of vulnerabilities for which active exploitation in the wild has been confirmed. It answers not the question „how severe?“ but „is it already being attacked?“ — thereby sharply prioritising patching.

    Read in glossary
    Actively exploited
    Published
    In CISA KEV since

    The KEV catalogue is a list maintained by the US authority CISA of vulnerabilities for which active exploitation in the wild has been confirmed. It answers not the question „how severe?“ but „is it already being attacked?“ — thereby sharply prioritising patching.

    Read in glossary
    CWE

    CWE is a catalogue of typical weakness types in software and hardware — such as flawed input validation, unsafe memory handling or poor authentication. Where a CVE names a concrete vulnerability in a concrete product, a CWE describes the underlying class of defect.

    Read in glossary
    CWE-78

    Response and mitigation

    Why act now?

    Prioritisation rationale

    This is one of the most heavily exploited CVEs of 2024: unauthenticated remote code execution over HTTP, no user interaction, public exploits in Metasploit and Nuclei, and CISA-confirmed use in ransomware campaigns. Mass scanning identifies vulnerable Windows Apache PHP-CGI stacks within hours of exposure. Typical targets are SME web-shops, XAMPP development hosts accidentally exposed to the internet, and legacy line-of-business applications on Windows Server. Treat this as critical for any Windows host running PHP-CGI at the perimeter. Linux-only estates and pure PHP-FPM deployments carry lower immediate urgency but should still receive the patch in the next change window.

    1. Runbook step 1

      Immediate response (0-24 h)

      • Upgrade PHP to a patched release: 8.3.8, 8.2.20 or 8.1.29. End-of-life branches (8.0, 7.x) receive no fix — migrate or disable PHP-CGI immediately.
      • Prioritise Windows hosts running Apache with PHP-CGI. Inspect configs for cgi.force_redirect = 0 and any ScriptAlias/Action directive invoking php-cgi.exe. That combination is the attack surface.
      • Compensating control if patching is blocked: replace PHP-CGI with mod_php, PHP-FPM or FastCGI. Alternatively, use mod_rewrite to drop requests containing %AD (soft hyphen) in the query string or -d, -T, -s style arguments.
      • Confirm which Windows code page the server runs under. Code pages 932 (Japanese), 936 (Simplified Chinese), 949 (Korean) and 950 (Traditional Chinese) are confirmed vulnerable via Best-Fit mapping, but no code page should be considered safe without the patch.
      • Fence internet-exposed PHP-on-Windows hosts behind a WAF or take them offline until patch status is confirmed. Mass scanning and automated exploitation have been continuous since June 2024.
      • Review for post-exploitation: inspect PHP sessions, admin credential hashes, API keys, and any modifications to web.config/.htaccess or webroot files since June 2024.
    2. Runbook step 2

      Mitigation layers

      • Network segmentation: PHP-CGI hosts should only accept inbound HTTP(S) from the reverse proxy/WAF. Egress-filter outbound TCP 443/4444/8080 to unknown destinations to break reverse-shell callbacks.
      • WAF/IPS rule: block query strings containing %AD as well as those with a dash followed by PHP CLI switches (-d allow_url_include, -d auto_prepend_file, -T, -s, -n). Suricata/Snort signatures for CVE-2024-4577 are published by Emerging Threats and Talos — keep rulesets current.
      • Apache hardening: set cgi.force_redirect = 1, remove ScriptAlias entries pointing to php-cgi.exe, switch to mod_fcgid or a PHP-FPM socket. XAMPP installs with the default /php-cgi/php-cgi.exe alias must be reconfigured.
      • Endpoint hardening: switch Windows system locale to en-US or similar where Best-Fit behaviour is less exploitable. This does NOT replace the patch but shrinks the attack surface.
      • Least privilege: deny the Apache service account write access to webroot and block spawning of cmd.exe/powershell.exe from php-cgi.exe via AppLocker or WDAC.
      • Enable a monitoring tap on the reverse proxy and capture all 4xx/5xx responses with unusual query strings — attackers brute-force code-page variants.
    3. Runbook step 3

      Detection rules

      • Web-server access logs: grep for %AD or decoded soft hyphens in query strings paired with .php paths. Sigma shape: selection.cs-uri-query|contains: ['%AD', '-d+allow_url_include', '-d+auto_prepend_file', '%ADd+'].
      • Sysmon EID 1 on Windows: php-cgi.exe as ParentImage spawning cmd.exe, powershell.exe, certutil.exe, curl.exe, whoami.exe — the standard post-exploitation chain. KQL: DeviceProcessEvents | where InitiatingProcessFileName == "php-cgi.exe" and FileName in ("cmd.exe","powershell.exe","certutil.exe","mshta.exe").
      • Sysmon EID 3/EID 22: outbound connections or DNS lookups from the php-cgi.exe process tree to non-business destinations — commonly Cobalt Strike beacons, Mirai variants, or cryptominer droppers.
      • File monitoring: new .php, .aspx or .bat files written to the webroot by the Apache service account (Sysmon EID 11). Short files in upload directories are classic webshell artefacts.
      • Network telemetry (Zeek/Suricata): HTTP requests carrying the %AD byte in the URI, especially in long query strings or POST bodies. Enable the ET OPEN signatures for CVE-2024-4577.

    Detection rules

    No NEOSEC detection rule is available for this vulnerability yet.

    Classification under NIS2 and CRA

    Rule-based classification from exploitation status and severity. It does not replace a case-by-case assessment.

    NIS2

    NIS2 is EU Directive (EU) 2022/2555 to raise the level of cybersecurity across the Union. It substantially broadens obligations compared with the first NIS directive: more sectors, mandatory risk management, staged reporting duties and personal accountability of senior management.

    Read in glossary
    Actively exploited: treat the vulnerability as a priority in vulnerability handling under Art. 21(2)(e) NIS2. If it is exploited in your environment, check the reporting obligation under Art. 23 (early warning within 24 hours).
    CRA

    The CRA is EU Regulation (EU) 2024/2847 setting horizontal cybersecurity requirements for „products with digital elements“ — from industrial controllers and software to connected consumer devices. For the first time manufacturers must ensure security across the entire product lifecycle, handle vulnerabilities and provide security updates.

    Read in glossary
    Since 11.09.2026, manufacturers of affected products with digital elements must report actively exploited vulnerabilities under Art. 14 CRA, with an early warning within 24 hours via ENISA's single reporting platform.
    ISO/IEC 27001

    ISO/IEC 27001 is the internationally leading standard for an information security management system (ISMS). It describes a risk-based, process-oriented framework to systematically plan, implement, review and improve information security.

    Read in glossary
    Control A.8.8, management of technical vulnerabilities: assess relevance to your systems, plan remediation and keep evidence.

    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.

    Source: NCSC NZ (CC BY 4.0), NVD (NIST), CISA KEV Catalog, CVE.org (MITRE), CSA/SingCERT, pwn.watch, OSV (Open Source Vulnerabilities), cvelistv5, BSI CSAF, BSI WID Portal

    Affected products

    The following versions are affected. Older releases of the same product line are also vulnerable unless stated otherwise.

    Affected products
    Affected versionsFixed in
    PHP GroupPHP
    • 8.1.0 – < 8.1.29
    • 8.3.0 – < 8.3.8
    • 8.2.0 – < 8.2.20
    • 8.1.29
    • 8.3.8
    • 8.2.20
    phpphp
    • 8.2.0 – < 8.2.20
    • 8.1.0 – < 8.1.29
    • 8.3.0 – < 8.3.8
    • 8.2.20
    • 8.1.29
    • 8.3.8
    OracleCommunications
    • 17.0.1
    • 23.4.0
    • 15.0.0.0.0
    • 24.1.0
    • 5.1
    • 14.0.0.1
    • 24.1.0.0.0
    • 24.2.2
    • 24.1.1
    • 12.11.0
    • 9.3.0
    • 9.0.1.10.0
    • 12.6.1.0.0
    • 9.1.1.3.0
    • 4.2.0
    • 23.4.3
    • 23.4.4
    • 4.1.0
    • 9.1.1.9.0
    • 9.1.0
    • 9.2.0
    • 5.2
    • 23.4.2
    • 24.2.1
    • 9.1.5
    • 14
    • < 10.4.0.4
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • 10.4.0.4
    Distribution and container packages (2)

    Downstream packages (e.g. Bitnami, Debian, Ubuntu, Red Hat). Versions refer to the distribution, not the vendor.

    Distribution and container packages
    Affected versionsFixed in
    bitnamiphp-min
    • 8.3.0
    • 8.2.0
    • —
    • —

    Vendors and products

    Affected operating systems

    Affected operating systems
    Otherfedoraprojectfedora39
    Otherfedoraprojectfedora40

    Weakness classes (CWE)

    • CWE-78Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

      Base

      The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.

      Entry at MITRE CWE-78

    Public exploit references

    Publicly reported proof-of-concepts, exploit modules and detection templates for this vulnerability. NEOSEC links to the original sources only and does not provide any exploit code.

    Public exploit references
    CISA KEV CatalogCISA Known Exploited Vulnerability (opens in a new tab)cisa.govactively exploited
    CSA/SingCERTCritical Vulnerability in Hypertext Preprocessor (PHP) Software (opens in a new tab)CSA/SingCERTactively exploited
    NCSC NZVulnerability affecting PHP on Windows (opens in a new tab)NCSC NZactively exploited
    Reference tagged as exploitblog.talosintelligence.com (opens in a new tab)PoC (publicly reported)reported, not verified—
    Reference tagged as exploitgithub.com (opens in a new tab)PoC (publicly reported)reported, not verified—
    Reference tagged as exploitlabs.watchtowr.com (opens in a new tab)PoC (publicly reported)reported, not verified—
    GitHub11whoami99/CVE-2024-4577 (opens in a new tab)github.comPoC (publicly reported)reported, not verified—
    Metasploit Framework (Pull Request)Metasploit PR #19247 (opens in a new tab)github.comPoC (publicly reported)reported, not verified—
    GitHubwatchtowrlabs/CVE-2024-4577 (opens in a new tab)github.comPoC (publicly reported)reported, not verified—
    GitHubxcanwin/CVE-2024-4577-PHP-RCE (opens in a new tab)github.comPoC (publicly reported)reported, not verified—
    PoC-in-GitHub (nomi-sec)edu-recon (opens in a new tab)github.comPoC (publicly reported)reported, not verified
    PoC-in-GitHub (nomi-sec)HTSOC (opens in a new tab)github.comPoC (publicly reported)reported, not verified
    PoC-in-GitHub (nomi-sec)cve-2024-4577-phpcgi_rce_reproduction (opens in a new tab)github.comPoC (publicly reported)reported, not verified

    References & sources

    • openwall.comlists/oss-security/2024/06/07/1web, Mailing list, Third-party advisory
    • arstechnica.comsecurity/2024/06/php-vulnerability-allows-attackers-to-run-mali…web, Exploit, Press coverage, Third-party advisory
    • blog.orange.tw2024/06/cve-2024-4577-yet-another-php-rce.htmlweb, Third-party advisory
    • cert.been/advisory/warning-php-remote-code-execution-patch-immediatelyweb, Third-party advisory
    • devco.reSecurity alert: CVE-2024-4577, PHP CGI argument injection vulnerabilityweb, Exploit, Third-party advisory, pwn-watch
    • github.com11whoami99/CVE-2024-4577web, Exploit
    • github.comGHSA-3qgc-jrrr-25jv: argument injection in PHP-CGIweb, Exploit, Third-party advisory, pwn-watch
    • github.comrapid7/metasploit-framework/pull/19247web, Exploit, Issue tracking, Patch
    • github.comwatchtowrlabs/CVE-2024-4577web, Exploit, Third-party advisory
    • github.comxcanwin/CVE-2024-4577-PHP-RCEweb, Exploit, Third-party advisory
    • isc.sans.edudiary/30994web, Exploit, Third-party advisory
    • labs.watchtowr.comno-way-php-strikes-again-cve-2024-4577web, Exploit, Third-party advisory
    • lists.fedoraproject.orgarchives/list/package-announce@lists.fedoraproject.org/message/…web, Mailing list
    • lists.fedoraproject.orgarchives/list/package-announce@lists.fedoraproject.org/message/…web, Mailing list
    • security.netapp.comadvisory/ntap-20240621-0008web, Third-party advisory
    • imperva.comblog/imperva-protects-against-critical-php-vulnerability-cve-20…web, Third-party advisory
    • php.netChangeLog-8.phpweb, Release notes
    • php.netChangeLog-8.phpweb, Release notes
    • php.netChangeLog-8.phpweb, Release notes
    • vicarius.iovsociety/posts/php-cgi-argument-injection-to-rce-cve-2024-4577web, Exploit, Third-party advisory
    Embed badge

    Show the severity and KEV status of this vulnerability on your site – with a link back here. The image is updated hourly.

    Badge preview for CVE-2024-4577
    <a href="https://intel.neosec.eu/en/cve/CVE-2024-4577"><img src="https://intel.neosec.eu/badge/cve/CVE-2024-4577.svg?lang=en" alt="CVE-2024-4577 – NEOSEC Intel" height="20"></a>