How a composer install Becomes Remote Code Execution: Inside CVE-
Composer's Perforce VCS driver built shell commands from package metadata and composer.json values without escaping, so a crafted source reference or p4user value could inject and run arbitrary commands during composer install. An attacker could execute code on a developer's machine or in CI by supplying a malicious package or project file.
Published on hafiqiqmal93.medium.com
You clone a repository. Fresh project, fresh machine.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The Perforce driver concatenated untrusted values (package source reference and composer.json VCS parameters) into shell command strings without escaping them.
Impact
An attacker could run commands as the user running composer install, potentially reaching CI tokens, cloud credentials and SSH keys; Packagist blocked the registry path but other registries and local project files remained exposed until Composer was updated.
What the attacker needed
Unpatched Composer below 2.9.6 or 2.2.27; install from source or dev version; or run Composer in an untrusted project
The fix
Both issues were fixed in Composer 2.9.6 and 2.2.27 LTS by escaping the interpolated values with escapeshellarg().
How it was found
- Craft a package whose metadata declares Perforce as the source type with a malicious source reference.
- Install that package with --prefer-source or a dev-prefixed version so Composer installs from source.
- Composer builds the p4 sync command and passes it to the OS, which runs the injected command.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Composer is a tool that downloads PHP libraries for a project. It also supports several version-control systems, including Perforce, and it builds a text command for the operating system to run. Because parts of that command came from package or project files without being made safe, someone could slip extra commands into it and have them run on your computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.