r/javascript • • Nov 27 '18

event-stream vulnerability explained

https://schneid.io/blog/event-stream-vulnerability-explained/
412 Upvotes

70 comments sorted by

View all comments

108

u/blood_bender Nov 27 '18

The one thing this article doesn't mention, which isn't as clever as the rest but really shows how well he planned this attack, is that after introducing flatmap-stream, he bumped event-stream to v3.3.6. All well and good. But a week later when he removed flatmap-stream, he bumped event-stream to v4.0.0.

So any investigation of event-stream wouldn't find flatmap-stream as a dependency at all, yet by bumping to 4.0.0, he ensured that any one of the millions of downloads would continue downloading the infected version, unless their package.json showed * or something similar. Since npm install by default would add ^3.3.whatever, it's super unlikely anyone would actually upgrade to 4.0 anytime soon, yet an audit of the package would look clean.

This attack was super clever for a variety of reasons, including this one.

As the article says, use a package-lock.json or yarn.lock, and set your package.json to strict semver.

20

u/liquidpele Nov 28 '18

As the article says, use a package-lock.json or yarn.lock, and set your package.json to strict semver.

This is like buying food from a bunch of random people, and then storing it all in your fridge and assuming that it's all healthy and fine because it's in your fridge and you don't go buy it every day.

18

u/ajacksified Nov 28 '18

This isn't the only thing you should do, it is a thing you should do. To use your analogy, it's the difference between putting it in the fridge and leaving it on the sidewalk.