Backdooring JavaScript using minifier bugs
zyan.scripts.mit.edu
zyan.scripts.mit.edu
Is there any benefit to it?
Well, in theory yes. When determining whether a specific function can be inlined into its call site, V8 looks at the length of the function source code to try and guess whether it's worth it. Functions longer than 600 characters (including comments) cannot be inlined and therefore they will typically be slower.
Whether that makes any meaningful difference to your application performance really depends on the application. In most cases it won't.
You certainly don't need server-side minification.
This is probably one of those heuristics that works well enough on enough real world code, even though everyone knows it's suboptimal. I've heard that the turbofan compiler will remove this limitation but that's still very much work in progress.
There is a potential benefit if the minifier can apply some performance optimisations, but one would hope V8 et al are already doing most of these and more.
Even for client-side applications, HTTP2 + Web Assembly will eradicate concatenating and minifying JS files soon.
Not convinced that HTTP2 will eradicate minifiers; it makes bundling files less useful, but minifying still gets rid of bytes. Then again, I'm not a web performance expert. :)
The reason is that V8 uses heuristics to decide which functions get inlined, and the raw source code length is one of the heuristics. Making the source for a function shorter may cause V8 to inline it more aggressively.
Could somebody please confirm or invalidate my understanding, that this backdoor is just exploitable in addition with other (severe) issues?
An attacker would have to have the ability to tailor/manipulate JS scripts which should be under control of the victim?
Or am i mistaken?
The attack scenario described in the post is (1) attacker writes some plausible-looking patches to an existing library like jQuery, (2) attacker convinces library maintainer to merge the patches, (3) someone builds the library with a buggy minifier, which creates the actual backdoor.
Reading this makes it seem hardly worth saving a few bytes over.