Fix a bypass for CVE-2020-16881

Fixes #107951

Uses child_process.execFile() rather than child_process.exec() to more
effectively resolve the command injection vulnerability.
This commit is contained in:
Justin Steven 2020-10-02 17:21:51 +10:00
parent 9d9afaacfb
commit e8ceafb07a
No known key found for this signature in database
GPG key ID: 681459ADF322CF09

View file

@ -282,8 +282,8 @@ export class PackageJSONContribution implements IJSONContribution {
private npmView(pack: string): Promise<ViewPackageInfo | undefined> {
return new Promise((resolve, _reject) => {
const command = 'npm view --json ' + pack + ' description dist-tags.latest homepage version';
cp.exec(command, (error, stdout) => {
const args = ['view', '--json', pack, 'description', 'dist-tags.latest', 'homepage', 'version'];
cp.execFile('npm', args, (error, stdout) => {
if (!error) {
try {
const content = JSON.parse(stdout);