Skip to content
RCE Disclosed report Intermediate CVE-2022-0845

Code Injection in PyTorch Lightning

PyTorch Lightning versions up to 1.5.10 allowed code injection through the PL_TRAINER_GPUS environment variable when using the Trainer module. An attacker could execute arbitrary commands on the operating system.

PyTorchLightning/pytorch-lightning

Originally disclosed on huntr

Critical View original

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 is included in the 1.6.0 release.

From the GitHub Advisory Database (GHSA-r5qj-cvf9-p85h, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the value of the PL_TRAINER_GPUS environment variable was passed to a shell or eval-like function without proper sanitisation, allowing command injection.

Impact

An attacker could execute arbitrary commands on the target operating system, potentially leading to full system compromise.

What the attacker needed

Attacker can set PL_TRAINER_GPUS; victim uses Trainer module

The fix

The vulnerability was fixed in version 1.6.0 via a patch.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a code injection bug in a machine learning library. The library reads a setting from an environment variable (a value stored in the operating system that programs can read) and uses it in a way that lets an attacker run their own commands on the computer. If an attacker can control that setting, they can take over the machine.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.