Skip to content
RCE Advisory Beginner CVE-2021-21412

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.

Alvaro Muñoz Follow

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.

pwntester, on GitHub Security Lab

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

  1. Install the @thi.ng/egf package.
  2. Create a script that calls the gpg method with a crafted argument.
  3. Run the script with Node.js.
  4. 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.

More by Alvaro Muñoz

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.