GHSL-2020-110: Command Injection in mversion
The mversion.update function passes the commitMessage option to a shell command without sanitisation, allowing an attacker who controls that input to execute arbitrary commands. The proof of concept shows that a crafted commit message creates a file named 'exploit'.
Originally disclosed on GitHub Security Lab
The mversion.update function has a command injection vulnerability. Clients of the mversion library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability.
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
Likely the library uses child_process.exec with a string that includes the commitMessage, allowing shell metacharacters to be interpreted.
Impact
This issue may lead to remote code execution if a client of the library calls the vulnerable method with untrusted input.
What the attacker needed
Client uses mversion.update with untrusted commitMessage
How it was found
- Install mversion and create an empty git repository.
- Create a JavaScript file that writes a package.json and calls mversion.update with a commitMessage containing a shell command.
- Run the JavaScript file with node.
- Observe that a file named 'exploit' has been created.
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.
This is a command injection bug. The library takes a commit message and runs it as part of a shell command, so if the message contains special characters, the shell runs extra commands. An attacker who can control the commit message could run their own commands on the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.