pytorch-lightning vulnerable to Arbitrary File Write via /v1/runs API endpoint
The /v1/runs API endpoint in pytorch-lightning v2.2.4 extracts tar.gz files without properly validating paths, allowing path traversal. An attacker can deploy a malicious plugin that writes arbitrary files to any directory on the victim's local file system, potentially leading to remote code execution.
lightning-ai/pytorch-lightning
Originally disclosed on huntr
A vulnerability in the /v1/runs API endpoint of lightning-ai/pytorch-lightning v2.2.4 allows attackers to exploit path traversal when extracting tar.gz files. When the LightningApp is running with the plugin_server, attackers can deploy malicious tar.gz plugins that embed arbitrary files with path traversal vulnerabilities. This can result in arbitrary files being written to any directory in the victim's local file system, potentially leading to remote code execution.
From the GitHub Advisory Database (GHSA-mr7h-w2qc-ffc2, 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 tar.gz extraction routine did not sanitise file paths, allowing entries with '../' to escape the intended extraction directory.
Impact
An attacker could write arbitrary files to any directory on the victim's local file system, potentially leading to remote code execution.
What the attacker needed
LightningApp running with plugin_server; attacker can deploy a plugin
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.
When a program unpacks a compressed file (like a .tar.gz), it should only write files inside the intended folder. Here, it did not check the file paths inside the archive, so a malicious archive could contain paths like '../../somefile' that escape the folder and overwrite any file on the computer. This is called path traversal, and it can let an attacker run their own code.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.