CVE-2022-0845: pytorch-lightning: code injection enables full RCE
GHSA-r5qj-cvf9-p85h CRITICAL PoC AVAILABLEAny ML training pipeline running pytorch-lightning below 1.6.0 is exposed to unauthenticated remote code execution — no privileges, no user interaction required. Upgrade to 1.6.0+ immediately; treat any training host that ran the vulnerable version as potentially compromised and rotate credentials. This is especially urgent for teams that expose Jupyter notebooks, training APIs, or Lightning-based serving endpoints to internal networks.
What is the risk?
Despite CVSS 9.8, EPSS sits at 0.27%, indicating limited observed exploitation in the wild as of enrichment date. However, the attack profile (network-accessible, zero complexity, zero privileges) makes any exposed training infrastructure a high-priority target. ML environments are notoriously under-patched and often run with elevated cloud credentials attached, dramatically amplifying blast radius beyond the compromised host.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| PyTorch Lightning | pip | < 1.6.0 | 1.6.0 |
| PyTorch | pip | — | No patch |
How severe is it?
What is the attack surface?
What should I do?
6 steps-
Patch
Upgrade pytorch-lightning to >= 1.6.0 immediately. Pin the version in requirements.txt and lock files.
-
Audit exposure
Identify any pytorch-lightning processes or APIs reachable over the network — training orchestrators, REST wrappers, Jupyter kernels with Lightning installed.
-
Assume breach if unpatched
Rotate all credentials (cloud IAM, API keys, database passwords) accessible from affected training hosts.
-
Network controls
Training infrastructure should not be directly internet-accessible; enforce egress filtering and segment training environments from production.
-
Detection
Review logs for unexpected subprocess spawns, outbound connections, or new user accounts created from training processes.
-
Dependency scanning
Integrate pip-audit or Safety into CI/CD to catch vulnerable ML library versions before deployment.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2022-0845?
Any ML training pipeline running pytorch-lightning below 1.6.0 is exposed to unauthenticated remote code execution — no privileges, no user interaction required. Upgrade to 1.6.0+ immediately; treat any training host that ran the vulnerable version as potentially compromised and rotate credentials. This is especially urgent for teams that expose Jupyter notebooks, training APIs, or Lightning-based serving endpoints to internal networks.
Is CVE-2022-0845 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2022-0845, increasing the risk of exploitation.
How to fix CVE-2022-0845?
1. **Patch**: Upgrade pytorch-lightning to >= 1.6.0 immediately. Pin the version in requirements.txt and lock files. 2. **Audit exposure**: Identify any pytorch-lightning processes or APIs reachable over the network — training orchestrators, REST wrappers, Jupyter kernels with Lightning installed. 3. **Assume breach if unpatched**: Rotate all credentials (cloud IAM, API keys, database passwords) accessible from affected training hosts. 4. **Network controls**: Training infrastructure should not be directly internet-accessible; enforce egress filtering and segment training environments from production. 5. **Detection**: Review logs for unexpected subprocess spawns, outbound connections, or new user accounts created from training processes. 6. **Dependency scanning**: Integrate pip-audit or Safety into CI/CD to catch vulnerable ML library versions before deployment.
What systems are affected by CVE-2022-0845?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, MLOps pipelines, model serving, experiment tracking integrations.
What is the CVSS score for CVE-2022-0845?
CVE-2022-0845 has a CVSS v3.1 base score of 9.8 (CRITICAL). The EPSS exploitation probability is 0.96%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0049 Exploit Public-Facing Application AML.T0050 Command and Scripting Interpreter Compliance Controls Affected
What are the technical details?
Original Advisory
Code Injection in GitHub repository pytorchlightning/pytorch-lightning prior to 1.6.0.
Exploitation Scenario
An adversary identifies an organization's ML training API or exposed Jupyter notebook running pytorch-lightning < 1.6.0. By crafting a malicious payload — for example, embedding injected Python code in a model checkpoint path or trainer configuration parameter — the attacker triggers code execution within the Lightning training process. Since training environments typically run with broad IAM permissions to access S3 buckets, GPU clusters, or secrets managers, the attacker immediately pivots to exfiltrate model weights, training data, and cloud credentials. In a distributed training scenario, lateral movement to other training nodes is trivial. The entire ML supply chain — from data to model — is compromised without any phishing or social engineering.
Weaknesses (CWE)
CWE-94 Improper Control of Generation of Code ('Code Injection')
Primary
CWE-94 Improper Control of Generation of Code ('Code Injection')
Primary
CWE-94 Improper Control of Generation of Code ('Code Injection') CWE-94 — Improper Control of Generation of Code ('Code Injection'): The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
- [Architecture and Design] Refactor your program so that you do not have to dynamically generate code.
- [Architecture and Design] Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H References
- github.com/PyTorchLightning/pytorch-lightning/pull/12212
- github.com/advisories/GHSA-r5qj-cvf9-p85h
- github.com/pypa/advisory-database/tree/main/vulns/pytorch-lightning/PYSEC-2022-181.yaml
- nvd.nist.gov/vuln/detail/CVE-2022-0845
- github.com/pytorchlightning/pytorch-lightning/commit/8b7a12c52e52a06408e9231647839ddb4665e8ae Patch 3rd Party
- huntr.dev/bounties/a795bf93-c91e-4c79-aae8-f7d8bda92e2a Exploit Issue Patch 3rd Party
Timeline
Related Vulnerabilities
CVE-2024-5452 9.8 pytorch-lightning: RCE via deepdiff Delta deserialization
Same package: torch CVE-2024-35198 9.8 TorchServe: URL bypass enables arbitrary model loading
Same package: torch CVE-2023-43654 9.8 TorchServe: SSRF + RCE via unrestricted model URL loading
Same package: torch CVE-2022-45907 9.8 PyTorch: RCE via unsafe eval in JIT annotations
Same package: torch CVE-2024-48063 9.8 PyTorch: RCE via RemoteModule deserialization
Same package: torch