Threat Feed

CVE-2024-4577: PHP · Remote code execution

Exploitation: In the wild · CVSS 9.8 Critical · Unauthenticated · Published 2024-06-09

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.

Enclave's analysis

PHP-CGI on Windows can be tricked into treating attacker-sent characters as PHP command-line options. That lets an unauthenticated remote user read script source or run code on the server. It is on CISA KEV, has a known ransomware link, and public exploit code exists. Only Windows hosts running PHP in CGI mode with a Best-Fit code page are hit. Upgrade to 8.1.29, 8.2.20 or 8.3.8, or stop using CGI mode.

Fix

Upgrade PHP 8.1 (CGI on Windows) to 8.1.29; PHP 8.2 (CGI on Windows) to 8.2.20; PHP 8.3 (CGI on Windows) to 8.3.8. No fixed version is listed for PHP; follow the vendor advisory.

Affected versions

ProductVulnerableFixed in
PHP8.1.x before 8.1.29Not listed
PHP8.2.x before 8.2.20Not listed
PHP8.3.x before 8.3.8Not listed
PHP 8.1 (CGI on Windows)>=8.1.0, <8.1.298.1.29
PHP 8.2 (CGI on Windows)>=8.2.0, <8.2.208.2.20
PHP 8.3 (CGI on Windows)>=8.3.0, <8.3.88.3.8

Seen in 4 sources