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

16

u/samjmckenzie Nov 27 '18

Why are minified libraries published onto npm? Is this standard practice?

1

u/[deleted] Nov 28 '18

I agree with this question. If I were to check the source code of every dependency in my node_modules and use a lock file, it would be great if I could feel confidant that this is the code I'm executing.

Having to read minified code to review dependencies is, well, stupid. This feel like a flaw in npm. I would prefer if npm never used minified code, but the source code instead. If that's not possible because of backwards compatibility, adding a flag like --no-minified could probably solve it.

8

u/schneidmaster Nov 28 '18

That would be pretty hard for npm to enforce -- minified javascript is just javascript with short variable names, no extraneous whitespace, etc. Who's npm to say whether e.g. a function with a 1-letter name is there because the code is minified, or just there because that's what someone happened to write?

2

u/NutsEverywhere Nov 28 '18

There's a difference between minification and variable mangling. Generally they are done together, but you can minify javascript without mangling, or mangle without minifying.