Skip to content

Comment on A Celery-like Python Task Queue in 55 Lines of Codeparent

Comments

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.

[1] http://lincolnloop.com/blog/playing-pickle-security/

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...

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.