CVE-2026-31221: PyTorch Lightning load_from_checkpoint has an insecure checkpoint deserialization
PyTorch-Lightning versions 2.6.0 and earlier contain an insecure deserialization vulnerability (CWE-502) in the checkpoint loading mechanism. The LightningModule.loadfromcheckpoint() method, which is commonly used to load saved model states, internally calls torch.load() without setting the security-restrictive weightsonly=True parameter.
Published May 12, 2026 · Updated May 18, 2026
Affected packages
pytorch-lightning
- Ecosystem
- PyPI
- Affected
- <= 2.6.0
- Fixed in
- No patched version yet
- Check
pip show pytorch-lightning
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
PyTorch-Lightning versions 2.6.0 and earlier contain an insecure deserialization vulnerability (CWE-502) in the checkpoint loading mechanism. The LightningModule.load_from_checkpoint() method, which is commonly used to load saved model states, internally calls torch.load() without setting the security-restrictive weights_only=True parameter. This default behavior 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 on the victim's system when the file is loaded.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-44484
Compromise of PyTorch Lightning PyPi Package Versions
critical9.8No fixMay 7, 2026CVE-2024-8019
PyTorch Lightning path traversal vulnerability
critical9.1Mar 20, 2025CVE-2024-8020
PyTorch Lightning denial of service vulnerability
high7.5No fixMar 20, 2025CVE-2024-5980
pytorch-lightning vulnerable to Arbitrary File Write via /v1/runs API endpoint
critical9.1Jun 27, 2024CVE-2024-5452
Remote code execution in pytorch lightning
critical9.8Jun 6, 2024
