CVE-2022-0845: Pytorch lightning Code Injection Vulnerability
CRITICALCVE-2022-0845 is a CRITICAL (CVSS 9.8) code injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Pytorch lightning libraries in the PyPI ecosystem. The issue involves code injection in pytorch lightning. Remediation is available by upgrading affected packages to version 1.6.0.
CVE-2022-0845 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-0845
To remediate this vulnerability, upgrade all affected Pytorch lightning dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install pytorch-lightning>=1.6.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pytorch-lightning
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2022-0845, inspect your installed packages using pip:
pip show pytorch-lightning
Analyze the terminal output to locate any version of Pytorch lightning in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.6.0), your application is affected.
Note: The pip show pytorch-lightning command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where 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. In Pytorch lightning, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-0845 Affected Pytorch lightning Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pytorch-lightning
|
PyPI |
< 1.6.0
|
1.6.0
|
References
Frequently Asked Questions
What is CVE-2022-0845?
Which Pytorch lightning versions are affected?
What version fixes CVE-2022-0845?
Is pytorch-lightning affected?
What is the CVSS score of CVE-2022-0845?
What CWE is associated with CVE-2022-0845?
How can I check PyPI dependencies for CVE-2022-0845?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-r5qj-cvf9-p85h",
"modified" : "2024-10-25T20:49:59Z",
"published" : "2022-03-06T00:00:16Z",
"aliases" : [ "CVE-2022-0845" ],
"summary" : "Code Injection in PyTorch Lightning",
"details" : "PyTorch Lightning version 1.5.10 and prior is vulnerable to code injection. An attacker could execute commands on the target OS running the operating system by setting the `PL_TRAINER_GPUS` when using the `Trainer` module. A [patch](https://github.com/pytorchlightning/pytorch-lightning/commit/8b7a12c52e52a06408e9231647839ddb4665e8ae) is included in the `1.6.0` release.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pytorch-lightning"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.6.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-0845"
}, {
"type" : "WEB",
"url" : "https://github.com/PyTorchLightning/pytorch-lightning/pull/12212"
}, {
"type" : "WEB",
"url" : "https://github.com/pytorchlightning/pytorch-lightning/commit/8b7a12c52e52a06408e9231647839ddb4665e8ae"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-r5qj-cvf9-p85h"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pytorch-lightning/PYSEC-2022-181.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/pytorchlightning/pytorch-lightning"
}, {
"type" : "WEB",
"url" : "https://huntr.dev/bounties/a795bf93-c91e-4c79-aae8-f7d8bda92e2a"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2022-03-07T19:58:34Z",
"nvd_published_at" : "2022-03-05T22:15:00Z"
}
}