CVE-2026-31221: High severity pypi/pytorch-lightning vulnerability
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. 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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Set the torch.load() weights_only parameter to True when loading checkpoints, including through LightningModule.load_from_checkpoint().
PyTorch-Lightning checkpoint loading weights_only = True
Event History
Frequently Asked Questions
What is the severity of CVE-2026-31221?
The severity of CVE-2026-31221 is rated high with a CVSS score of 8.8.
What vulnerability does CVE-2026-31221 expose?
CVE-2026-31221 exposes an insecure deserialization vulnerability in the checkpoint loading mechanism of PyTorch-Lightning.
How do I fix CVE-2026-31221?
To fix CVE-2026-31221, upgrade PyTorch-Lightning to version 2.6.1 or later.
Which versions are affected by CVE-2026-31221?
CVE-2026-31221 affects PyTorch-Lightning versions 2.6.0 and earlier.
What components are involved in CVE-2026-31221?
CVE-2026-31221 involves the LightningModule.load_from_checkpoint() method and the torch.load() function.