Skip to content
RCE Advisory Intermediate CVE-2021-32830

GHSL-2021-061: Command injection in @diez/generation - CVE-2021-32830

The locateFont method in @diez/generation is vulnerable to command injection because it passes unsanitised input to a shell command. An attacker who can control the input to this method could execute arbitrary commands on the host, potentially leading to remote code execution.

Alvaro Muñoz Follow

Originally disclosed on GitHub Security Lab

The locateFont method has a command injection vulnerability. Clients of the @diez/generation 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

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 locateFont with untrusted input; runs on MacOS or patched Unix

How it was found

  1. Install the @diez/generation package.
  2. Create a JavaScript file that calls generation.locateFont with a crafted string containing shell metacharacters.
  3. Run the file with Node.js.
  4. Observe that a file named 'exploit' is created, demonstrating command execution.

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. When a program builds a system command using input from an untrusted source without cleaning it, an attacker can sneak in extra commands. Here, the locateFont function in a JavaScript library does that, so if a developer passes user input to it, an attacker 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.

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.