pickle security

Paul Rubin phr-n2002a at nightsong.com
Fri Feb 1 16:33:12 EST 2002


Geoffrey Talvola <gtalvola at nameconnector.com> writes:
> I'm trying to understand how to safely unpickle untrusted strings.  I'll
> summarize what I think I've learned from Google searches, and someone tell
> me if I'm wrong.

This subject is treated somewhat better in the current version of the
pickle docs than in earlier versions.

> Did I get it right?  Are there any other security issues I need to be aware
> of, or does this cover them?

I continue to feel uncomfortable using unpickle on untrusted data.
For example, it calls eval to handle quoted strings.  While that looks
safe on the surface, there are an awful lot of code paths you have to
examine to make sure it can't nail you.

You may be better off using something like xml-rpc or even marshal.



More information about the Python-list mailing list