CVE-2026-58659: PyTorch Lightning Remote Code Execution Vulnerability
Summary
CVE-2026-58659: PyTorch Lightning through 2.6.5, fixed in commit d710d68, contains a remote code execution vulnerability in the _load_state function that imports and executes attacker-controlled module names from checkpoint _instantiato... Affects pytorch-lightning versions < 2.6.6. Fixed in 2.6.6. How to fix ↓
Also tracked for
- lightning · PyPI
The same CVE-2026-58659 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
PyTorch Lightning is a lightweight wrapper for PyTorch that helps researchers and developers to scale their models and organize their code. It provides a high-level interface for training models, managing experiments, and handling distributed training. However, versions up to 2.6.5 are vulnerable to a remote code execution issue that arises from improper handling of checkpoint files.
Vulnerability Detail
The vulnerability exists in the _load_state function of PyTorch Lightning, which allows an attacker to import and execute arbitrary code by manipulating checkpoint files. Specifically, the function imports module names from attacker-controlled hyperparameters, bypassing the weights_only=True protection. This can lead to severe consequences, including unauthorized access to system resources and execution of malicious code when the LightningModule.load_from_checkpoint method is called.
How To Fix
Latest published version: 2.6.6 as of 23 Oct 2026
pip install --upgrade "pytorch-lightning==2.6.6"
The newest release already contains this fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, avoid loading checkpoint files from untrusted sources. Ensure that any checkpoint files you use are from verified and secure origins to mitigate the risk of executing malicious code.
Conclusion
The CVE-2026-58659 vulnerability in PyTorch Lightning poses a significant risk due to its potential for remote code execution. Users are strongly advised to update to version 2.6.6 or later to mitigate this risk and to exercise caution when handling checkpoint files.
See every vulnerability recorded for pytorch-lightning →
FAQ
The vulnerability allows remote code execution through manipulated checkpoint files, which can lead to arbitrary code execution.
Versions of PyTorch Lightning up to and including 2.6.5 are affected by this vulnerability.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected without any signup.
If an immediate update is not possible, avoid using checkpoint files from untrusted sources as a temporary measure.
Exploitation of this vulnerability can lead to unauthorized access, data breaches, and execution of malicious code on the affected system.
References
Related vulnerabilities
Recent vulnerabilities recorded for pytorch-lightning.