Remote code execution in pytorch lightning
The library deserialises user-supplied Delta objects to modify application state, but the whitelist can be bypassed to include dunder attributes. An attacker can craft a serialised delta that leads to arbitrary attribute write and remote code execution on any self-hosted instance with default configuration.
lightning-ai/pytorch-lightning
Originally disclosed on huntr
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.
From the GitHub Advisory Database (GHSA-cgwc-qvrx-rf7f, CC BY 4.0).
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 deserialiser whitelist for deepdiff.Delta objects does not adequately restrict dunder attributes, so a crafted serialised delta can reference them and achieve arbitrary attribute write.
Impact
An attacker could achieve arbitrary attribute write and total remote code execution on any self-hosted pytorch-lightning application in its default configuration, because the delta endpoint is enabled by default.
What the attacker needed
Self-hosted pytorch-lightning; default configuration; delta endpoint enabled
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.
The application accepts data from users and turns it back into live objects, a process called deserialisation. It tries to block dangerous object attributes (dunder attributes, names with double underscores) but the block can be bypassed. That lets an attacker make the server run their own code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.