Re:A Celery-like Python Task Queue in 55 Lines of Code
by jonesetc on Tuesday February 11, 2014 @11:49AM
(#7218515)
I understand the risk is basically because you're evaling when unpickling. What formats are safe then?
[ Parent
| on HN ]
Re:A Celery-like Python Task Queue in 55 Lines of Code
by michaelmior on Tuesday February 11, 2014 @12:11PM
(#7218703)
Pickle doesn't really use eval, but there is still the potential for users to execute arbitrary code[1]. JSON, YAML, MessagePack, etc are safe in this respect (assuming a well-implemented parsing library) because all the parser does is convert the data into simple data structures.
Re:A Celery-like Python Task Queue in 55 Lines of Code
by jonesetc on Tuesday February 11, 2014 @12:23PM
(#7218783)
I was just using eval loosely. The eval I particularly meant is that an __init__ is run for classes with a .__getinitargs__ method defined [1]. And I guess json et al. is the reasonable answer I should have expected. I was hoping for something that mimicked the functionality of pickle but maybe signed the information so that it would be safe to use across a network.
http://docs.python.org/2/library/pickle.html#object.__getini...
Re:A Celery-like Python Task Queue in 55 Lines of Code
by ForHackernews on Tuesday February 11, 2014 @02:18PM
(#7219706)
Python's YAML implementation isn't safe by default. You have to use yaml.safe_load() because the standard load() function can execute arbitrary code.
Re:A Celery-like Python Task Queue in 55 Lines of Code
by jknupp on Tuesday February 11, 2014 @12:00PM
(#7218596)
Pickle (or any use of eval) is a security risk only if you're using it in the context of untrusted code. Basically any distributed task queue is going to have that risk if it can execute arbitrary code.
Re:A Celery-like Python Task Queue in 55 Lines of Code
by bagels on Tuesday February 11, 2014 @12:03PM
(#7218634)
I thought the risk was if the data came from an untrusted source, as it might contain code?