Skip to content

Commit e8ceafb

Browse files
committed
Fix a bypass for CVE-2020-16881
Fixes microsoft#107951 Uses child_process.execFile() rather than child_process.exec() to more effectively resolve the command injection vulnerability.
1 parent 9d9afaa commit e8ceafb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

extensions/npm/src/features/packageJSONContribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ export class PackageJSONContribution implements IJSONContribution {
282282

283283
private npmView(pack: string): Promise<ViewPackageInfo | undefined> {
284284
return new Promise((resolve, _reject) => {
285-
const command = 'npm view --json ' + pack + ' description dist-tags.latest homepage version';
286-
cp.exec(command, (error, stdout) => {
285+
const args = ['view', '--json', pack, 'description', 'dist-tags.latest', 'homepage', 'version'];
286+
cp.execFile('npm', args, (error, stdout) => {
287287
if (!error) {
288288
try {
289289
const content = JSON.parse(stdout);

0 commit comments

Comments
 (0)