Remote Code Execution on packagist.org
Packagist passed a user-supplied repository URL into shell commands for the p4 and svn tools without proper escaping, so a crafted URL could run arbitrary commands on the server. An attacker could therefore execute commands of their choosing on packagist.org.
justi.cz
Published on justi.cz
tl;dr There was a remote code execution vulnerability on packagist.org, the default package server behind Composer, a PHP package manager. Packagist currently serves around 400 million package downloads per month.
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 application built shell command strings from a user-controlled repository URL and the p4 and svn wrappers failed to escape that argument properly.
Impact
An attacker could execute arbitrary commands on the packagist.org server, which serves hundreds of millions of package downloads per month.
What the attacker needed
Ability to submit a package repository URL
How it was found
- Provide a repository URL containing a shell command substitution when adding a package
- Packagist shells out to git, hg, p4 and svn using that URL as an argument
- The p4 and svn wrappers fail to escape the URL, so the command runs in a shell
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.
When a website needs to run another program, it builds a command line as text. If part of that text comes from the user and is not carefully quoted, the user can sneak in extra commands that the computer then runs. Here, the repository URL field was placed into such a command line, letting an attacker run their own commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.