How the CVE Works:
CVE-2025-1945 exploits a vulnerability in PickleScan (versions before 0.0.23) where it fails to detect malicious pickle files embedded in PyTorch model archives. Attackers manipulate specific ZIP file header flag bits to hide malicious pickle files, bypassing PickleScan’s detection. When the compromised model is loaded using PyTorch’s torch.load()
, the malicious pickle file executes arbitrary code, leading to potential system compromise. This vulnerability arises due to insufficient validation of ZIP file headers during the scanning process, allowing attackers to exploit the discrepancy between PickleScan’s detection and PyTorch’s loading mechanisms.
DailyCVE Form:
Platform: PyTorch
Version: PickleScan < 0.0.23
Vulnerability: Arbitrary Code Execution
Severity: Medium
Date: 03/10/2025
What Undercode Say:
Exploitation:
- Malicious ZIP Creation: Modify ZIP file headers using tools like `zipdetails` or `hexedit` to flip specific bits.
- Embed Malicious Pickle: Insert a malicious pickle file into the PyTorch model archive.
- Bypass Detection: Ensure the modified ZIP file bypasses PickleScan’s checks.
- Trigger Execution: Load the model using `torch.load()` to execute the embedded code.
Protection:
- Update PickleScan: Upgrade to version 0.0.23 or later.
- Validate ZIP Headers: Implement additional checks for ZIP file integrity.
- Sandboxing: Load models in a restricted environment to limit damage.
- Code Signing: Use signed model archives to ensure authenticity.
Commands:
- Check PickleScan Version:
pip show picklescan
- Upgrade PickleScan:
pip install --upgrade picklescan
- Inspect ZIP Headers:
zipdetails malicious_model.zip
Code:
- Detect Malicious Pickle:
import picklescan report = picklescan.scan_file("model.zip") print(report)
- Safe Model Loading:
import torch model = torch.load("model.pt", map_location="cpu")
Analytics:
- CVSS 4.0 Score: 5.3 (Medium)
- Attack Vector: Network (AV:N)
- Impact: Low confidentiality (VC:N), Low integrity (VI:L), Low availability (VA:L)
- Exploitability: High (AC:L, PR:N, UI:P)
References:
- bash
- bash
- bash
By following these steps, users can mitigate the risks associated with CVE-2025-1945 and ensure secure handling of PyTorch models.
References:
Reported By: https://nvd.nist.gov/vuln/detail/CVE-2025-1945
Extra Source Hub:
Undercode