VAITP Dataset

← Back to the dataset

CVE-2005-2875

Remote code execution via unpickled objects in Py2Play

  • CVSS 7.5
  • CWE-412: Untrusted Data Deserialization
  • Input Validation and Sanitization
  • Remote

Py2Play allows remote attackers to execute arbitrary Python code via pickled objects, which Py2Play unpickles and executes.

CVSS base score
7.5
Published
2005-09-13
OWASP
A03 Injection
Orthogonal defect classification
Timing/Serialization
Code defect classification
Serialization Issues
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Py2Play
Fixed by upgrading
Yes

Solution

Update Py2Play to a version that fixes the pickling vulnerability.

Vulnerable code sample

import pickle

# Vulnerable unpickling function that allows arbitrary code execution
def vulnerable_load(data):
    return pickle.loads(data)

# Example usage
data = b'...'  # Pickled data that could execute arbitrary code
obj = vulnerable_load(data)

Patched code sample

import pickle

# Safe unpickling function that only allows specific classes to be unpickled
class SafeUnpickler:
    ALLOWED_CLASSES = (YourAllowedClass1, YourAllowedClass2)

    @classmethod
    def safe_load(cls, data):
        # Use a custom Unpickler that restricts the allowed classes
        class RestrictedUnpickler(pickle.Unpickler):
            def find_class(self, module, name):
                # Check if the class is in the allowed list
                if (module, name) not in cls.ALLOWED_CLASSES:
                    raise pickle.UnpicklingError("Class not allowed: {}.{}".format(module, name))
                return super().find_class(module, name)

        return RestrictedUnpickler(io.BytesIO(data)).load()

# Example usage
data = b'...'  # Pickled data
try:
    obj = SafeUnpickler.safe_load(data)
except pickle.UnpicklingError as e:
    print("Unpickling failed:", e)

Cite this entry

@misc{vaitp:cve20052875,
  title        = {{Remote code execution via unpickled objects in Py2Play}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2005},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2005-2875},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2005-2875/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.