News for hackers. Stuff that matters.
Re:20% of all Node.js modules found vulnerable to injection ... by bri3d on Monday March 12, 2018 @11:16AM (#16568670)
This headline is entirely false - 20% of Node modules use 'eval' or 'exec'. While these are certainly less secure and a strong secure coding standard would probably ban them or at least reduce their use, it's entirely possible to use both in safe ways.
Re:20% of all Node.js modules found vulnerable to injection ... by tonyarkles on Monday March 12, 2018 @11:18AM (#16568687)
Further on:

> 18,924 of all 51,627 call sites are found to be statically safe (36.66%)

> The templates for the vast majority of call sites have at most one hole, and very few templates contain more than five.

If you've got a dependency that calls eval or exec, those aren't great odds that they're doing it safely.

Re:20% of all Node.js modules found vulnerable to injection ... by acdha on Monday March 12, 2018 @12:02PM (#16569023)
That still requires you to know whether either is being called with user-provided values before you can say it's unsafe.

If, for example, someone had a utility which resized user-uploaded images you couldn't say simply calling exec to run something like ImageMagick was unsafe before checking whether it used the user's filename.

Re:20% of all Node.js modules found vulnerable to injection ... by tonyarkles on Monday March 12, 2018 @02:25PM (#16570224)
I think that's what they're saying in those quoted lines though. That 36% appeared to be statically-safe (i.e. the string sent to eval or exec was generated using only strings defined in the code) and the others were not.
Re:20% of all Node.js modules found vulnerable to injection ... by acdha on Monday March 12, 2018 @04:32PM (#16571310)
True — it wasn't clear to me whether e.g. a random temporary filename would be considered static or only actual fixed strings in the code. (Similar questions would arise if e.g. a web app saved things using a database primary key so it's technically not static but the attacker doesn't control it even if they control the file contents)
Re:20% of all Node.js modules found vulnerable to injection ... by tonyarkles on Tuesday March 13, 2018 @08:35AM (#16575595)
Ahhhhh nice, I hadn't considered the "random temporary filename" or "db primary key" aspect either. That's something that gives me a small chill, but it's not the end of the world compared to "arbitrary user input piped to exec()"

Who knows how elaborate their static analyzer actually is in practice? I wrote a Python analyzer in grad school, and the results were both pretty interesting (type inference tracing through function calls) and pretty mediocre. It was also fiddly-as-hell to get working. Plus... the first rule of statically-analyzing dynamic languages is that the results get weird after the first eval()--anything could happen!

Re:20% of all Node.js modules found vulnerable to injection ... by acdha on Tuesday March 13, 2018 @09:14AM (#16575814)
Yeah, as a developer I see plenty of appeals to dynamic languages but they’re certainly a nightmare for tool authors. I know OpenStack was working on a security scanner for Python – I wonder what percentage of the open issues start with “this is probably very hard but…”
Re:20% of all Node.js modules found vulnerable to injection ... by Yaggo on Monday March 12, 2018 @11:21AM (#16568713)
That 20% includes dependencies. I'm sure the majority of those are cli tools (webpack etc), i.e. they don't take unsanitized input from web forms etc.
Re:20% of all Node.js modules found vulnerable to injection ... by ScottBurson on Monday March 12, 2018 @07:10PM (#16572524)
As someone with almost 40 years of Lisp experience, I firmly believe that the only correct place to call 'eval' is in the implementation of a REPL. For any other purpose that you might be tempted to use it for, there is a better way, that is not only more correct but also faster. Usually, the better way is to pass a function to be called rather than an expression to be evaluated.

There are more legitimate uses of 'exec', of course, but one still needs to be very careful with it. If there really are Node modules that pass their input to 'exec', that strikes me as very poor design.

Re:20% of all Node.js modules found vulnerable to injection ... by kazinator on Tuesday March 13, 2018 @09:31PM (#16581519)
> the only correct place to call 'eval' is in the implementation of a REPL.

Don't forget also: if you're reading uncompiled code from a file, that's an occasion for eval.

Re:20% of all Node.js modules found vulnerable to injection ... by ScottBurson on Thursday March 15, 2018 @04:37PM (#16596326)
There are a handful of other valid uses, but there are many invalid ones. I recall, a couple of years ago, hearing about a Rails vulnerability caused by some API method calling 'eval' on one of its arguments if it happened to be a string, just as a convenience for some use case. The fact that it did so wasn't even documented. I was left with the impression that most programmers don't understand how to use 'eval', or rather, how and why not to use it.
Re:20% of all Node.js modules found vulnerable to injection ... by Ajedi32 on Monday March 12, 2018 @11:36AM (#16568829)
It's not even that. It's more like "20% of Node modules use _or include a module somewhere in their dependency chain which uses_ 'eval' or 'exec'".

So if my backup utility happens to depend on a wrapper library for node's Child Process module (which probably doesn't sanitize its inputs, as that would break quite a bit of functionality), it's considered "vulnerable".

Re:20% of all Node.js modules found vulnerable to injection ... by inetknght on Monday March 12, 2018 @11:40AM (#16568860)
And why shouldn't it be?
Re:20% of all Node.js modules found vulnerable to injection ... by Ajedi32 on Monday March 12, 2018 @11:43AM (#16568881)
Maybe because it's not sending user input into the "vulnerable" API? Or because it's not even calling the "vulnerable" API in the first place? Or because it's a system utility which will never be exposed to untrusted user input?
Re:20% of all Node.js modules found vulnerable to injection ... by ynniv on Monday March 12, 2018 @11:19AM (#16568692)
Possible, but unlikely. eval is particularly difficult to use correctly, and can almost always be replaced with something better.
Re:20% of all Node.js modules found vulnerable to injection ... by weej on Monday March 12, 2018 @11:23AM (#16568729)
Key word is vulnerable. There is a gap in protection and they are at risk to being potentially exploited.
Re:20% of all Node.js modules found vulnerable to injection ... by weej on Monday March 12, 2018 @11:24AM (#16568736)
Doesn't mean it isn't click bait. ;-)