r/node • u/lirantal • Oct 06 '19
Quickly check if a website is running vulnerable JS libs straight from the terminal
0
Oct 06 '19
[deleted]
7
u/lirantal Oct 06 '19
Snyk is indeed already integrated into Lighthouse right there in Chrome and actually in Edge as well: https://snyk.io/blog/snyk-and-lighthouse/
Good idea about the browser extension π
12
Oct 06 '19
[removed] β view removed comment
3
u/lirantal Oct 07 '19
Correct! I'll update the project's README.
You're welcome to send in a PR if there isn't one already to update this requirement.
4
u/UrTwiN Oct 07 '19
So it can only check front-end libraries, right?
6
u/lirantal Oct 07 '19
Correct. This module is only able to fetch a website's JS library and audit them by comparing publicly known security vulnerabilities in Snyk's database https://snyk.io/vuln?type=npm with those versions detected.
9
u/dominikwilkowski Oct 06 '19
If your site is running two different major versions of jQuery and Angular; you got some other issues going as well.
16
6
Oct 06 '19
Story of my (clients') life.
My favorite story is when we couldn't get the styling on the client's custom component library working in their app. The client's response: it works fine in the storybook, so it must be your problem. Turns out they had accidentally included the entire bootstrap CSS in their page without knowing it, which applied global styles that were needed for the component to look good. When we used their lib we didn't have the bootstrap and it looked like crap. How fun and contentious to have to explain that to their devs.
2
2
Oct 07 '19
Is there a version of this that can be run in the browser programmatically
1
u/lirantal Oct 07 '19
Yep. Lighthouse that is bundled in Chrome DevTools actually has Snyk's vulnerability scanning already integrated built-in. You can read more about it here: https://snyk.io/blog/snyk-and-lighthouse/
2
u/Doomwaffle Oct 07 '19
Oh god please nobody in my intranet run this on the ancient spaghetti code app me and my team inherited. Node modules haven't been updated since 2017
1
2
3
1
u/scinos Oct 07 '19
Does this work even if the libraries are not exposed as globals and/or tree-shaken ?
1
u/lirantal Oct 07 '19
It works if it's able to detect the JS lib and its version. If you're building something based on React for example, then regardless of your build process you surely need to have React available as a JS library in the browser to execute. This is no different.
1
u/scinos Oct 07 '19
But I'm most likely including other libraries as well and not exposing them as globals. I wonder if it detect those
I'll check went I'm in front of a computer.
1
1
u/vainstar23 Oct 07 '19
You could use npm audit too. It has the added advantage of attempting to resolve vulnerable packages without breaking code.
0
u/lirantal Oct 07 '19
It has nothing to do with npm audit, and while we're at it, you should *really* try out Snyk.io for a pleasant developer experience of fixing security issues in JS libs π
1
Oct 07 '19
How come it has nothing to do with npm audit? I watched the presentation video on snyk and it eg. fixed package.json (in a dumb way, instead of using package-lock it used package.json, with possible code breaks).
This seems more like a user-friendly interaction layer for npm audit fix that runs on pull request and github integration where npm audit fix is just a console command
2
u/lirantal Oct 07 '19
It has nothing to do with npm audit because:
- It is based on a Snyk integration embedded in Chrome's Lighthouse (https://snyk.io/blog/snyk-and-lighthouse/)
- The vulnerabilities it finds are based on Snyk's vulnerability database (https://snyk.io/vuln?type=npm) and not npm's
- It's not using npm audit.The video is out of date - we definitely update lockfiles and have been doing so for a long time actually. Appreciate the feedback and will pass to the team to update the video.
Why Snyk and not npm audit? my personal take in a nutshell:
Snyk's patching is actually quite smart if I may say so. For times where you don't have official upgrades (common with open source due to maintenance issues etc) the tooling will provide a security patch to remediate the problem. All the patches are tested that they apply across diff OSs and using the package's own testing suite. There's more on this here: https://snyk.io/blog/where-do-security-patches-come-from/ and I'd love to get your perspective of it if you read this through and want to share.
The tooling is more than "github interaction". The Pull Request will get opened with new vulns are discovered, so even if you didn't run 'npm audit' manually or in your own CI, Snyk will push them to your repo so you can actually fix the problem. It's also smart in terms of pulling only minimal semver upgrades required for the security issue and not pulling the latest which may bring in API breaking changes and such. This is just the PR tooling in a bit, there's so many more around it. Let along the database itself which is much more up to date with Snyk's own security research. As a recent example, Snyk discovered a vulnerability in Sequelize (https://snyk.io/blog/sequelize-orm-npm-library-found-vulnerable-to-sql-injection-attacks/) and worked with the maintainers to let them know and provided fixes too but 'npm audit' only found out about this from Snyk's database more than 30 days later, in which you've been vulnerable to this if you didn't scan with Snyk.
Happy to get the conversation going further. Love your feedback β€οΈ
1
u/vainstar23 Oct 07 '19 edited Oct 07 '19
Alright, I had a closer look at snyk and although I feel they are still similar to npm audit in the sense that they perform dependency vulnerability scanning, snyk does look to be a little more sophisticated and definitions more up to date although you need to create an account with them if you want to use their service. CI integration is pretty good and you are able to fix vulnerable packages by using the
snyk wizardcommand. My only problem is that is is really expensive for what it is. I think to sign up 10 devs costs around $700 for private projects after the first ten whereas using npm audit is free. Then again, I say this but Nessus costs about $2000 per license but it does a lot more than dependency scanning..I also found blackduck as an alternative, however could not find any documentation on it. Don't think it looks too modern though...
1
u/lirantal Oct 07 '19
Thanks for sharing your experience. So valuable to get this from fresh eyes! π€
Snyk is free for both open source and private repositories. If you link private repositories then there's some limit around the number of scans but it's set high enough for you to almost never incur it. If you do, ping me and let's work it out.
Snyk also does a lot more than dep scanning - docker image scanning (free too), license scanning, active remediation with pull requests, serverless lambda monitoring which is free too.
The whole point with Snyk is developer-first. Making it easy for devs to fix security issues in workflows that are most genuine to their day to day lives like the GH integration.
P.S. there's a blog post by NearForm that compares 'npm audit' and snyk, while somewhat outdated it's also a good starting point as a reference: https://www.nearform.com/blog/comparing-npm-audit-with-snyk/
2
u/vainstar23 Oct 07 '19
Thanks m8, will have a look at it :)
1
u/lirantal Oct 07 '19
Great! Please ping me on any question you have. I'm at https://twitter.com/liran_tal and my DMs are open and you're 100% welcome :)
53
u/lirantal Oct 06 '19
The repository is at: https://github.com/lirantal/is-website-vulnerable where I have some
pending #hacktoberfest tickets if you're into that and I'd love to help you out if you're new to open source π