Alternatives for pickle?

Michael Foord fuzzyman at gmail.com
Tue Oct 12 17:25:10 CEST 2004


Antoon Pardon <apardon at forel.vub.ac.be> wrote in message news:<slrncmkgq0.54i.apardon at rcpc42.vub.ac.be>...
> I'm writing a little game, a gridler application, where you
> can turn pixmaps into puzzle's and try to solve them. I already
> have the data structure for such a puzzle worked out, one of
> the problems is writing it to a file and reading it back in.
> 
> I first went to the pickle module but there I read this.
> 
> | Warning: The pickle module is not intended to be secure against
> | erroneous or maliciously constructed data. Never unpickle data
> | received from an untrusted or unauthenticated source.
> 

Hmmm..... I wonder how easy it is to craft a malicious pickle that
will automatically run code objects just because they are unpickled.
My guess is that it's quite difficult - I've never heard of it *ever*
being done. Someone would have to be *very* malicious to work out how
to do it on the off chance of planting a back door into someone's
machine through a program like yours. No offence intended, but if they
were going to go to all that effort I expect they might aim for
something with a wider audience.

I would expect it to be 'safe enough', but that might not be safe
enough for you !

Creating your own data format is probably the way forward - and
probably not that difficult either.

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html

> But since this is for a game and people should be able to
> exchange puzzles, it seems a heavy requirement to ask of
> the users to check a puzzle file for security hazards.
> 
> 
> I also thought about writing out a string that, when read
> back in and fed to eval would recreate the structure. But
> that seems to be just as insecure if not more so.
> 
> So how do you serialize data in python, when you want
> a somewhat secure mechanisme. Preferably where a user
> can make a puzzle file by hand in a text editor.



More information about the Python-list mailing list