CVE-2021-4118 Deserialization of Untrusted Data in pytorchlightning/pytorch-lightning
Attackers can execute arbitrary code by exploiting unsafe deserialization in the PyTorch Lightning library.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2021-4118?
CVE-2021-4118 is a high-severity unsafe deserialization vulnerability in pytorchlightning/pytorch-lightning, published on 23 Dec 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Official description
pytorch-lightning is vulnerable to Deserialization of Untrusted Data
Weakness: CWE-502
Which versions are affected by CVE-2021-4118?
4 open source packages ship an affected version, including pytorch-lightning and lightning. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
pytorch-lightning PyPI | All versions | 1.6.0 |
pytorch-lightning PyPI | All versions | 1.6.0 |
pytorch-lightning PyPI | All versions | 1.6.0 |
lightning PyPI | All versions | 1.6.0 |
Products include Lightningai Pytorch Lightning.
How do I fix CVE-2021-4118?
Upgrade pytorch-lightning to 1.6.0 or later.
Upgrade, and only deserialise data from trusted sources or with an allow-list of types. More about Unsafe deserialization.
Is CVE-2021-4118 being exploited?
There is no known exploitation of CVE-2021-4118 in the wild and no public exploit code.
Other vulnerabilities in pytorchlightning/pytorch-lightning
- CVE-2024-5452 RCE via Property/Class Pollution in lightning-ai/pytorch-lightning
- CVE-2026-44484 Compromise of PyTorch Lightning PyPi Package Versions
- CVE-2024-8019 Arbitrary File Write/Overwrite in lightning-ai/pytorch-lightning
- CVE-2024-5980 Arbitrary File Write via /v1/runs API endpoint in lightning-ai/pytorch-lightning
- CVE-2026-31221 PyTorch Lightning load_from_checkpoint has an insecure checkpoint deserialization
Sources
Also known as GHSA-2vj5-px25-gjrp, PYSEC-2021-874, PYSEC-2026-3968.