Exploit for a security hole in the pickle module for Python versions <= 2.1.x
Jeff Epler
jepler at unpythonic.net
Thu Jul 18 16:45:30 EDT 2002
On Thu, Jul 18, 2002 at 09:07:53PM +0200, Dieter Maurer wrote:
> Jeff Epler <jepler at unpythonic.net> writes on Wed, 17 Jul 2002 07:47:14 -0500:
> > Exploit for a security hole in the pickle module for Python versions <= 2.1.x
> Thank you for the precise problem statement!
> > ...
> > Because a "class constructor" is
> > simply a callable object,
> > a pickle can be written that names any function
> > and gives it arbitrary arguments.
> But this need not be the case!
>
> A "class constructor" is quite a special "function".
> Its "type" is "ClassType" (at least until Python 2.2).
This test would "work" against the exploit I posted. However, this test
is not implemented in any version of Python. Furthermore, there are
classes which are unsafe to instantiate. For instance, popen2.Popen3
is as dangerous a constructor as os.system is a function.
>>> type(popen2.Popen3)
<type 'class'>
That's the reason the "safe for unpickling" requirement was added.
Jeff
More information about the Python-list
mailing list