Skip to content
RCE Advisory Intermediate

GHSL-2020-109: Command injection in codecov

The upload method in the codecov-node library passes user-supplied options to a shell command without proper sanitisation, allowing command injection. An attacker could execute arbitrary commands if a client calls the vulnerable method with untrusted input.

ghsecuritylab Follow

Originally disclosed on GitHub Security Lab

The upload method has a command injection vulnerability. Clients of the codecov-node library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability.

ghsecuritylab, 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 library uses a shell command execution function (like child_process.exec) with unsanitised user input, and the previous fix only blocked one character (&) but not others like backticks.

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 codecov-node library; client passes untrusted input to upload

The fix

The vulnerability was fixed in version 3.7.1; the report recommends using child_process.execFile instead of child_process.exec.

How it was found

  1. Install the codecov package using npm.
  2. Create a JavaScript file that requires codecov and calls handleInput.upload with options containing a backtick-wrapped command.
  3. Run the file with node.
  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 is a command injection bug. The library takes some input from the user and puts it into a system command without cleaning it properly. An attacker who can control that input could make the system run their own commands, like creating files or running programs.

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 ghsecuritylab

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.