GHSL-2021-076: Arbitrary command execution in Gerapy - CVE-2021-32849
Two functions in Gerapy build shell commands from user-supplied input without sanitisation, allowing an authenticated attacker to run arbitrary commands on the server. The attacker could execute code on the host.
Originally disclosed on GitHub Security Lab
The function projectclone is vulnerable to command injection while handling attacker controlled data. The address (1) variable is used in the creation of a git clone command (2) in an insecure way that allows an attacker to craft the url of a repository that contains shell commands (3).
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
User-controlled input is interpolated into a shell command string that is executed with shell=True, without any sanitisation or escaping.
Impact
An authenticated attacker could execute arbitrary commands on the system, leading to code execution.
What the attacker needed
Authenticated user account
How it was found
- Send a POST request to the project_clone endpoint with an address value that contains shell metacharacters.
- The server builds a git clone command using that address and runs it through the shell.
- The injected shell commands execute on the host.
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 report has not been written yet. The Original tab links to the source.
The application takes text from a user and pastes it directly into a command that the computer runs. Because special characters in that text are not cleaned, an attacker can add their own commands, which the computer then executes as if the attacker were sitting at the keyboard.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.