[create-git] RCE via insecure command formatting
The create-git NPM module passed user-supplied input directly into a shell command without validation, allowing an attacker to run arbitrary commands alongside git. A proof of concept showed that a crafted remote origin value could trigger a separate network request to a local endpoint.
- Triaged in 44 hours
- Fixed in 12 months
- Disclosed after 13 months
Summary by the program
The create-git NPM module was vulnerable against command injection
which was possible since some user supplied inputs were concatenated without
proper checks inside a exec() call, which made possible executing arbitrary commands besides the git one (which is used by the tool).
The PoC resulted in:
// poc.js const createGit = require('create-git')
createGit({ ignoreExisting: true, initialCommitMessage: 'test', remoteOrigin:
'http://evil.com || curl "http://localhost/RCE"',
ignoreTemplates: ['Node.gitignore'] })
The vulnerability has been fixed checking the inputted data and using safe functions to execute commands, which replaced exec() occurrences.
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 was concatenated into a string passed to exec(), so shell metacharacters could inject additional commands.
Impact
An attacker who can influence the remote origin value could execute arbitrary commands on the machine running the module, though the proof of concept only demonstrated a request to a local endpoint.
What the attacker needed
Control over remote origin input; module used with attacker-influenced value
The fix
The vulnerability was fixed by validating the input and replacing exec() with safer functions to execute commands.
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.
When a program builds a system command by gluing together text from a user, special characters in that text can break out of the intended command and start new ones. Here the module did that with a value like a remote repository address, so an attacker could make the computer run extra commands. The fix was to check the input and use safer ways to start processes.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.