News for hackers. Stuff that matters.
Re:Lave: eval in reverse by njohnson41 on Thursday March 10, 2016 @01:39AM (#11257659)
Sounds a lot like python's "pickle" module (which is super-useful for prototyping), but with the same achilles' heel: all of your serialized objects can now run arbitrary code when you deserialize them!
Re:Lave: eval in reverse by boucher on Thursday March 10, 2016 @10:39AM (#11259792)
I think the main thing Jed was going for, which is different from Pickle and most people aren't picking up on, is that the output is simply JavaScript. It doesn't output a storage format that must be turned back into live objects by some form of parser, and so it doesn't require any additional scripts to be used.

(edited to add that, of course, pickle is part of the python standard library, which makes this specific feature less interesting)

Re:Lave: eval in reverse by jedschmidt on Thursday March 10, 2016 @01:48AM (#11257689)
Not _quite_ arbitrary; the only code run is that generated by lave. Arbitrary code present in functions is parsed, but not run.
Re:Lave: eval in reverse by conradev on Thursday March 10, 2016 @02:06AM (#11257728)
But if there is a persistence or network layer involved, when compromised, it could function as an injection vector into the application, right?
Re:Lave: eval in reverse by jedschmidt on Thursday March 10, 2016 @02:21AM (#11257759)
Sure, as it could with any part of your app, including wherever your JSON.parse code lives.
Re:Lave: eval in reverse by conradev on Thursday March 10, 2016 @02:26AM (#11257774)
But could JSON.parse() fed with malicious data fire off an XMLHttpRequest or delete all of your data?
Re:Lave: eval in reverse by curveship on Thursday March 10, 2016 @08:39AM (#11259081)
No. That's the whole point of using JSON.parse() instead of eval(). JSON is defined as a non-executing subset of JavaScipt syntax, one that contains only literal expressions. JSON.parse() will only parse valid JSON.

This is why, for instance, there's no native Date format in JSON. Dates in JavaScript require running a constructor -- new Date() -- so they aren't in JSON.

Re:Lave: eval in reverse by dspillett on Thursday March 10, 2016 @06:47AM (#11258628)
That would concern me too potentially, though if there isn't one already it should be easy to implement a switch that would turn this part of the behaviour off.

It looks very interesting to me from the point of view of dealing with certain data types better (at all, in fact), and handling circular references.

Re:Lave: eval in reverse by Klathmon on Thursday March 10, 2016 @08:48AM (#11259133)
> it should be easy to implement a switch that would turn this part of the behaviour off

I think it's one of those "easy on the surface, but surprisingly complex" problems.

When you start allowing arbitrary code execution, it's a lot of work to prevent certain "functions" (i mean that in the non-programming way).

Re:Lave: eval in reverse by dspillett on Friday March 11, 2016 @05:12AM (#11265728)
I was thinking more along the lines of turning it off at the generation side: only including anything in the persisted state that is safe.

Trying to detect the unsafe parts so they could be turned off after that point would be impossible as you suspect (the task would be constrained by the halting problem, https://en.wikipedia.org/wiki/Halting_problem).

Re:Lave: eval in reverse by mwhite on Thursday March 10, 2016 @02:40AM (#11257803)
It seems like it theoretically shouldn't be too hard to add the ability to validate that the data is a valid lave output if you're concerned about that. That more or less leaves only the issue of anonymous functions in the data being replaced with malicious functions, but frankly the only reason to be serializing functions is if they're user input, otherwise you should instead be serializing function name/key strings or some other well-defined form of function references and/or arguments.
Re:Lave: eval in reverse by ubernostrum on Thursday March 10, 2016 @03:46AM (#11258006)
Any type of code-serialization tool will be vulnerable to injection. This is why use of pickle is often discouraged in Python, in favor of serialization formats which don't deserialize to code. Anything that marks "valid output of the tool" could just as easily be produced by an attacker who uses the tool to serialize their malicious code, and even signing/secret-token systems aren't a guarantee since it's so incredibly easy to build or use them the wrong way.
Re:Lave: eval in reverse by mwhite on Thursday March 10, 2016 @05:23AM (#11258310)
I meant that your code could parse the supposed lave code before running it to verify that it is limited to the known lave constructs (which does not include arbitrary code execution). It would quite slow but enough to make it somewhat safe against an attacker providing malicious lave code.
Re:Lave: eval in reverse by mbrock on Thursday March 10, 2016 @08:02AM (#11258896)
If lave generates a well defined sublanguage, I don't think parsing would need to be much slower than parsing JSON. It would just be an extended JSON parser that happens to parse executable JavaScript.
Re:Lave: eval in reverse by CiPHPerCoder on Thursday March 10, 2016 @09:44AM (#11259432)
OK, so put a ring on it.

And by ring, I of course mean HMAC.