{"id":515,"cve":"CVE-2005-2875","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2005-2875","cwe":"CWE-412: Untrusted Data Deserialization","cwe_number":412,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/412","cvss_score":7.5,"published":"2005-09-13","owasp":"A03 Injection","odc":"Timing\/Serialization","cdc":"Serialization Issues","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Remote code execution via unpickled objects in Py2Play","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2005-2875\/","description":"Py2Play allows remote attackers to execute arbitrary Python code via pickled objects, which Py2Play unpickles and executes.","solution":"Update Py2Play to a version that fixes the pickling vulnerability.","affected_component":"Py2Play","fixed_by_upgrading":true,"vulnerable_code":"import pickle\n\n# Vulnerable unpickling function that allows arbitrary code execution\ndef vulnerable_load(data):\n    return pickle.loads(data)\n\n# Example usage\ndata = b'...'  # Pickled data that could execute arbitrary code\nobj = vulnerable_load(data)","patched_code":"import pickle\n\n# Safe unpickling function that only allows specific classes to be unpickled\nclass SafeUnpickler:\n    ALLOWED_CLASSES = (YourAllowedClass1, YourAllowedClass2)\n\n    @classmethod\n    def safe_load(cls, data):\n        # Use a custom Unpickler that restricts the allowed classes\n        class RestrictedUnpickler(pickle.Unpickler):\n            def find_class(self, module, name):\n                # Check if the class is in the allowed list\n                if (module, name) not in cls.ALLOWED_CLASSES:\n                    raise pickle.UnpicklingError(\"Class not allowed: {}.{}\".format(module, name))\n                return super().find_class(module, name)\n\n        return RestrictedUnpickler(io.BytesIO(data)).load()\n\n# Example usage\ndata = b'...'  # Pickled data\ntry:\n    obj = SafeUnpickler.safe_load(data)\nexcept pickle.UnpicklingError as e:\n    print(\"Unpickling failed:\", e)","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}