CVE-2024-5980 Overview
A path traversal vulnerability exists in the /v1/runs API endpoint of lightning-ai/pytorch-lightning v2.2.4 that allows attackers to exploit arbitrary file write capabilities 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.
Critical Impact
Attackers can achieve remote code execution by writing malicious files to arbitrary locations on the target system through crafted tar.gz plugin archives, compromising the entire host machine.
Affected Products
- lightningai pytorch_lightning v2.2.4 and earlier versions
- LightningApp deployments running with plugin_server enabled
- Python environments with vulnerable pytorch-lightning packages installed
Discovery Timeline
- 2024-06-27 - CVE CVE-2024-5980 published to NVD
- 2025-10-15 - Last updated in NVD database
Technical Details for CVE-2024-5980
Vulnerability Analysis
This vulnerability stems from improper handling of file paths during tar.gz archive extraction in the /v1/runs API endpoint. The plugin server functionality in PyTorch Lightning allows users to deploy plugins packaged as tar.gz archives. However, the extraction routine fails to properly sanitize file paths within the archive, allowing specially crafted archives to include files with directory traversal sequences (e.g., ../../../etc/cron.d/malicious).
When such a malicious archive is processed, the extraction operation follows the embedded path traversal sequences literally, writing files outside the intended plugin directory. This allows an attacker to place executable files, configuration overrides, or malicious scripts in sensitive system locations. The vulnerability is classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory).
Root Cause
The root cause is insufficient validation and sanitization of file paths contained within tar.gz archives before extraction. The vulnerable code does not verify that extracted file destinations remain within the designated plugin directory, allowing relative path components like ../ to escape the intended extraction boundary.
Attack Vector
The attack can be executed remotely over the network without authentication. An attacker crafts a malicious tar.gz archive containing files with path traversal sequences in their filenames. When this archive is submitted to the /v1/runs API endpoint of a LightningApp instance running with the plugin_server enabled, the extraction process writes the embedded files to attacker-controlled locations on the filesystem.
The vulnerability mechanism involves embedding files within a tar.gz archive with specially crafted paths containing directory traversal sequences. When the archive is extracted by the vulnerable plugin server, files escape the intended extraction directory and can be written to arbitrary filesystem locations. Attackers typically target locations such as cron directories, SSH authorized_keys files, or web application directories to achieve code execution. For detailed technical information, see the Huntr Security Bounty Report.
Detection Methods for CVE-2024-5980
Indicators of Compromise
- Unexpected files appearing in system directories such as /etc/cron.d/, /root/.ssh/, or web server directories
- Suspicious tar.gz uploads to the /v1/runs API endpoint containing path traversal sequences
- Log entries showing file extraction operations writing to paths outside the expected plugin directory
- New scheduled tasks or SSH authorized keys not created by administrators
Detection Strategies
- Monitor API access logs for requests to /v1/runs endpoint with unusual payload sizes or frequencies
- Implement file integrity monitoring (FIM) on critical system directories to detect unauthorized modifications
- Deploy network intrusion detection rules to identify tar.gz uploads containing path traversal patterns
- Audit plugin server logs for extraction operations targeting unexpected filesystem paths
Monitoring Recommendations
- Enable verbose logging for the LightningApp plugin_server component
- Set up alerts for file creation events in sensitive directories like /etc/, /root/, and application binary paths
- Monitor system resource usage for signs of unauthorized code execution following plugin deployments
- Implement behavioral analysis to detect anomalous file write patterns from the PyTorch Lightning process
How to Mitigate CVE-2024-5980
Immediate Actions Required
- Upgrade pytorch-lightning to a patched version that includes commit 330af381de88cff17515418a341cbc1f9f127f9a
- Disable the plugin_server functionality if not required for your deployment
- Implement network-level access controls to restrict access to the /v1/runs API endpoint
- Review filesystem permissions to ensure the LightningApp process runs with minimal privileges
Patch Information
Lightning AI has released a fix for this vulnerability. The patch is available in the GitHub commit 330af381de88cff17515418a341cbc1f9f127f9a. Users should update their pytorch-lightning installation to include this security fix. Additional details about the vulnerability and patch can be found in the Huntr Security Bounty Report.
Workarounds
- Disable the plugin_server component by not starting LightningApp with plugin server functionality enabled
- Deploy the application behind a reverse proxy or firewall that validates and sanitizes incoming archive uploads
- Use containerization with read-only filesystem mounts to limit the impact of arbitrary file writes
- Implement application-level access controls requiring authentication for the /v1/runs endpoint
# Example: Restrict plugin_server access via firewall rules
# Block external access to the vulnerable API endpoint
iptables -A INPUT -p tcp --dport 8080 -s ! 127.0.0.1 -j DROP
# Alternative: Run with minimal filesystem permissions
# Create dedicated user with restricted write access
useradd -r -s /bin/false lightning-app
chown -R lightning-app:lightning-app /opt/lightning-app
chmod 755 /opt/lightning-app
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

