question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snyk Vulnerability: Command Injection through `shelljs`

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package shelljs which is a dependency for @angular/compiler-cli

Severity

CVSS SCORE 7.0 High Severity

Description

Shelljs is vulnerable to Command Injection. It is possible to invoke commands from shell.exec() from external sources, allowing an attacker to inject arbitrary commands.

🌍 Your Environment

Angular Version:




Angular CLI: 7.3.6
Node: 10.13.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.6
@angular-devkit/core         7.3.6
@angular-devkit/schematics   7.3.6
@schematics/angular          7.3.6
@schematics/update           0.13.6
rxjs                         6.3.3
typescript                   3.2.4

Anything else relevant?

GitHub Issue 1 GitHub Issue 2 Snyk Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
clydincommented, Jul 3, 2019

This really doesn’t seem like a vulnerability in shelljs either. The functionality provided by the β€œexec” call is intended to allow an application using the library to execute an arbitrary command. If an application doesn’t sanitize input before calling then the application itself has the security vulnerability not the library. If this were not the case then Nodejs itself would have the same security vulnerability report since it also provides the same functionality (which this library actually uses to implement its functionality).

5reactions
nfischercommented, Jul 8, 2019

Hi all, I work on ShellJS.

Shelljs are not able to provide a timeline on this fix. shelljs/shelljs#495

I think you misunderstood. This is not a fix, it’s my project to implement a feature request. Landing that PR will not β€œfix” the β€œvulnerability.” I acknowledge I haven’t provided a timeline for the feature: my time for ShellJS is very limited and must balance feature work with other work for the module. As such, I have no clue when I can finish that feature, or if a satisfactory solution is even technically feasible.

I completely understand it’s not your responsibility per se, but I ask you to consider removing shelljs as a dependency. Having a High threat vulnerability, even a false positive, for an indefinite future could hurt or hinder adoption.

I agree with what the Angular team has expressed on this thread. The resolution should be for Snyk and similar services to remove this false positive and flag modules which misuse shell.exec()/child_process.exec(), rather than flagging ShellJS itself (we can’t β€œfix” exec(), we just hope to eventually deprecate it).

I don’t know how much work it’d be, but considering you only use cp, mkdir, and mv, it hopefully wouldn’t take a ton of time.

We’ve spent years working to get the semantics right for these bash commands, and are still working hard to get proper coverage/behavior. Rewriting from scratch would probably introduce a lot of deviations from the POSIX behavior (and copy-paste might create license issues). So, while I can’t stop folks from doing this, I would strongly advise against adding error-prone implementations to replace existing solutions.

I contacted Snyk about this, and got the following response

Thanks for reaching out @SanderElias! Reading the quoted response, it might be misinterpreted as Snyk is waiting on action from me. My last communication with them was prior to your comment, but they said they need no action from ShellJS or me and they’re not currently ready to take down this vulnerability report. But I’m happy to help out within reason if they need further action from ShellJS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Injection in shelljs - Snyk
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quickΒ ......
Read more >
Error message: Shelljs 0.8.3 and before are vulnerable to ...
3 and before are vulnerable to Command Injection. Commands can be invoked from shell.exec(), those commands will include input from externalΒ ...
Read more >
Mining Node.js Vulnerabilities via Object Dependence Graph ...
js vulnerabilities, such as command injection and prototype pollution, but they are spe- cific to individual vulnerability and do not generalizeΒ ...
Read more >
1425807 – nodejs-shelljs: Command injection via shell.exec() call
shelljs is a portable Unix shell commands for Node.js. It is possible to invoke commands from shell.exec() from external sources, allowing an attacker...
Read more >
shelljs @ 0.8.0 .. 0.8.1 - Package Diff
+- Snyk vulnerability DB reporting command injection vulnerability in ShellJS [\#810](https://github.com/shelljs/shelljs/issues/810).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found