GHSL-2021-062: Command injection in @thi.ng/egf - CVE-2021-21412
The gpg method in the @thi.ng/egf library passes user input to a shell command without sanitisation, allowing command injection. An attacker who controls input to this method could execute arbitrary commands on the host.
Originally disclosed on GitHub Security Lab
The gpg method has a command injection vulnerability. Clients of the @thi.ng/egf 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 gpg method constructs a shell command by concatenating user-supplied arguments without proper escaping or validation.
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 gpg method with untrusted input
The fix
The issue was fixed and an advisory was published.
How it was found
- Install the @thi.ng/egf package.
- Create a script that calls the gpg method with a crafted argument.
- Run the script with Node.js.
- Observe that a file named exploit is 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 library has a function that runs the gpg encryption tool. It builds a command line by inserting whatever text you give it, without checking for special characters. If an attacker can control that text, they can add their own commands, which then run on the computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.