Re:NPM Package Hijacking From the Hijacker's Perspective
by jtuchsen on Friday March 25, 2016 @04:40PM
(#11362531)
I've not tried this, but a similar but easier exploit would be to register packages with names that are close to existing popular package names, and then have a post install script inject a modified version of the actual package into the node_modules directory that also does something malicious. So you register the "lodasj" package instead of "lodash" and than create a post install script to inject the malicious "lodash" package that re-exports all of the lodash API + does something nasty. If someone has a typo with "npm i lodasj" and doesn't notice the mistake, the machine that installs it and anyone that depends on the package is infected. I wonder how well policed NPM is against these kinds of malware attacks.
[ Parent
| on HN ]
Re:NPM Package Hijacking From the Hijacker's Perspective
by tyingq on Saturday March 26, 2016 @09:41AM
(#11365615)
This one isn't doing anything scary at the moment, but shows the potential:
https://www.npmjs.com/package/uglifyjs
It's getting 30k+ downloads a month.
The actual package people are looking for is here: https://www.npmjs.com/package/uglify-js
Re:NPM Package Hijacking From the Hijacker's Perspective
by troygoode on Friday March 25, 2016 @04:45PM
(#11362560)
they'd notice as soon as they tried to run their program as "import * from 'lodash'" would fail (unless they were consistent with their typos...)
Re:NPM Package Hijacking From the Hijacker's Perspective
by jtuchsen on Friday March 25, 2016 @04:53PM
(#11362604)
You can inject a version of whatever you want into the node_modules folder in the post install script though can't you? So you just copy your own malicious lodash into node_modules. I haven't tried it but I think it'd work.