PyTorch Lightning through 2.6.5, fixed in commit d710d68, contains a remote code execution vulnerability in the loadstate function that imports and executes attacker-controlled module names from checkpoint instantiator hyperparameters. Attackers can craft malicious checkpoint files that bypass weightsonly=True protections to execute arbitrary code when LightningModule.loadfromcheckpoint is called.
Security Advisory: Compromise of PyTorch Lightning PyPI Package Versions
Published: 2026-04-30 Last Updated: 2026-04-30
Lightning AI has identified a security incident affecting certain versions of a PyPI package.
What happened
Lightning AI has determined that one or more released versions of this package have been compromised and include malicious code.
The current investigation indicates that the affected versions have introduced functionality consistent with a credential harvesting mechanism. There is a continuing analysis the scope and behaviour of the code.
At this stage, the root cause of the compromise is still under investigation.
What versions are affected
Lightning AI is currently working to confirm the exact set of impacted versions.
The following versions are determined as affected, and developers should delete them from their systems:
- 2.6.2 - 2.6.3
Lightning AI will update this advisory if the versions impacted by this vulnerability change.
What you should do immediately
If developers have installed or are running any potentially affected versions on their application:
- Assume the environment may be compromised - Immediately rotate all credentials and secrets that may have been exposed, including: - API keys - Access tokens - SSH keys - Service account credentials - Rebuild affected systems from a known clean state - Pin PyTorch Lightning to version 2.6.1 - Review logs for any suspicious or unauthorised activity
Actions Lightning AI has taken
- Quarantined malicious versions from PyPI - Recommended using version 2.6.1: https://github.com/Lightning-AI/pytorch-lightning/releases/tag/2.6.1 - Revoked and rotated all internal credentials associated with our release process - Initiated a full investigation into the compromise
Ongoing investigation
Lightning AI is actively working to:
- Identify the exact mechanism of compromise - Confirm the full set of affected versions - Determine the behaviour and impact of the malicious code - Assess any downstream impact to users
Lightning AI will provide updates as soon as more information becomes available.
Commitment to transparency
Lightning AI takes the security of users and the integrity of the software supply chain extremely seriously.
Lightning AI will continue to share timely and accurate updates as the investigation progresses.
Contact
If there are any questions or if there are concerns that a consuming project may be impacted, please send an email to:
security@lightning.ai
A vulnerability in the /v1/runs API endpoint of lightning-ai/pytorch-lightning v2.2.4 allows attackers to exploit path traversal when extracting tar.gz files. When the LightningApp is running with the pluginserver, attackers can deploy malicious tar.gz plugins that embed arbitrary files with path traversal vulnerabilities. This can result in arbitrary files being written to any directory in the victim's local file system, potentially leading to remote code execution.
A remote code execution (RCE) vulnerability exists in the lightning-ai/pytorch-lightning library version 2.2.1 due to improper handling of deserialized user input and mismanagement of dunder attributes by the deepdiff library. The library uses deepdiff.Delta objects to modify application state based on frontend actions. However, it is possible to bypass the intended restrictions on modifying dunder attributes, allowing an attacker to construct a serialized delta that passes the deserializer whitelist and contains dunder attributes. When processed, this can be exploited to access other modules, classes, and instances, leading to arbitrary attribute write and total RCE on any self-hosted pytorch-lightning application in its default configuration, as the delta endpoint is enabled by default.
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.
Code Injection in GitHub repository pytorchlightning/pytorch-lightning prior to 1.6.0.