Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snyk Vulnerability: Command Injection through shelljs #29460

Closed
halhelal opened this issue Mar 22, 2019 · 11 comments
Closed

Snyk Vulnerability: Command Injection through shelljs #29460

halhelal opened this issue Mar 22, 2019 · 11 comments
Milestone

Comments

@halhelal
Copy link

🐞 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

@gkalpak
Copy link
Member

gkalpak commented Mar 22, 2019

Thx for reporting this. We are currently not using shelljs.exec() in compiler-cli. We are only using cp, mkdir and mv (here and there).
Closing this, since we are not affected by the vulnerability afaict.

@gkalpak gkalpak closed this as completed Mar 22, 2019
@adamcoard-maximus
Copy link

adamcoard-maximus commented May 22, 2019

I agree that from what I can tell Angular is not affected by this vulnerability, but nonetheless the inclusion of shelljs does set off false-positives in many scanners. We use Angular for government applications, and the presence of this false-positive has caused quite a bit of consternation. We've had people suggest downgrading our version of Angular because then the threat-level of the vulnerability goes from High to Medium, but we've decided against it because a false-positive is always better than an actual vuln.

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

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 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.

Thanks!

@clydin
Copy link
Member

clydin commented Jun 30, 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).

@xxyyzz2050
Copy link

I'm using the last version of Angular, and I'm facing the same alert.

@gkalpak
Copy link
Member

gkalpak commented Jul 5, 2019

I am re-opening the issue, so we can use it for tracking the resolution of this.

FWIW, I still believe that this is a false positive (from what I understand) and the correct resolution would be for the vulnerability reporting tools to stop reporting this.

For context:
Similar false positives in the past have been resolved in the same way.
The ShellJS maintainers seem to be working with Snyk on resolving this and they "have come to the mutual conclusion that it probably doesn't make sense to mark ShellJS as vulnerable".

@gkalpak gkalpak reopened this Jul 5, 2019
@SanderElias
Copy link
Contributor

I contacted Snyk about this, and got the following response:

After a chat with our security team we are already communicating with the repo maintainer, once it will be sort and will be confirmed with them we will take it off and we will send a blog post

So I'm hopeful this will be sorted out the correct way pretty soon.

@nfischer
Copy link

nfischer commented 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.

@adamcoard-maximus
Copy link

Hey @nfischer

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).

Agree completely with this. For the record this has always been my prefered resolution; I suggested Angular remove the dependency due to i) the relatively limited use of shelljs ii) my desire for a quick resolution. I've always understood and represented this issue as a false positive.

gkalpak added a commit to gkalpak/angular that referenced this issue Jul 9, 2019
Since, 7186f9c `compiler-cli` is no longer depending on `shelljs` for
production code. (We still use it in tests and infrastructure/tooling.)

Incidentally, this should also help with angular#29460.
@gkalpak
Copy link
Member

gkalpak commented Jul 9, 2019

It turns out that we no longer use ShellJS in compiler-cli code (we still use it in tests and tooling), so #31468 removes it from package.json > dependencies.

But, again, I believe the correct resolution is for the vulnerability alert to be taken down ✌️

@ngbot ngbot bot added this to the needsTriage milestone Jul 10, 2019
matsko pushed a commit that referenced this issue Jul 11, 2019
Since, 7186f9c `compiler-cli` is no longer depending on `shelljs` for
production code. (We still use it in tests and infrastructure/tooling.)

Incidentally, this should also help with #29460.

PR Close #31468
matsko pushed a commit that referenced this issue Jul 11, 2019
Since, 7186f9c `compiler-cli` is no longer depending on `shelljs` for
production code. (We still use it in tests and infrastructure/tooling.)

Incidentally, this should also help with #29460.

PR Close #31468
@gkalpak
Copy link
Member

gkalpak commented Jul 17, 2019

Seems like we have a resolution 🎉 shelljs/shelljs#945 (comment)

after a careful examination of this vulnerability, we've decided to remove it from our database.

@gkalpak gkalpak closed this as completed Jul 17, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants