CVE-2024-8019

9.1 CRITICAL

📋 TL;DR

This vulnerability in PyTorch Lightning's LightningApp allows attackers to write arbitrary files via a crafted filename at the /api/v1/upload_file/ endpoint on Windows hosts. This can lead to remote code execution by overwriting critical files or placing malicious executables. Users running PyTorch Lightning 2.3.2 on Windows with LightningApp exposed are affected.

💻 Affected Systems

Products:
  • lightning-ai/pytorch-lightning
Versions: 2.3.2 specifically
Operating Systems: Windows
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects LightningApp component when running on Windows. Linux/macOS systems are not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, and lateral movement within the network.

🟠

Likely Case

File system corruption, service disruption, or limited code execution depending on attacker's file placement.

🟢

If Mitigated

Denial of service through file overwrites if critical files are protected but writable locations exist.

🌐 Internet-Facing: HIGH - The vulnerable endpoint is accessible via HTTP API and requires no authentication.
🏢 Internal Only: MEDIUM - Still significant risk if internal attackers exist, but reduced exposure surface.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Simple HTTP POST request with crafted filename parameter. No authentication required.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.3.3 or later

Vendor Advisory: https://github.com/lightning-ai/pytorch-lightning/commit/330af381de88cff17515418a341cbc1f9f127f9a

Restart Required: Yes

Instructions:

1. Update PyTorch Lightning: pip install --upgrade pytorch-lightning>=2.3.3
2. Restart any running LightningApp instances
3. Verify version with: python -c "import pytorch_lightning; print(pytorch_lightning.__version__)"

🔧 Temporary Workarounds

Disable vulnerable endpoint

all

Remove or block access to /api/v1/upload_file/ endpoint

# Configure web server (nginx example)
location /api/v1/upload_file/ { return 403; }
# Application-level disable if configurable

Migrate to Linux/macOS

all

Deploy LightningApp on non-Windows operating systems

🧯 If You Can't Patch

  • Implement strict network segmentation and firewall rules to limit access to LightningApp API endpoints
  • Deploy web application firewall (WAF) with file upload protection and path traversal detection rules

🔍 How to Verify

Check if Vulnerable:

Check if running PyTorch Lightning 2.3.2 on Windows with LightningApp accessible

Check Version:

python -c "import pytorch_lightning; print(pytorch_lightning.__version__)"

Verify Fix Applied:

Confirm version is 2.3.3+ and test file upload endpoint with path traversal attempts

📡 Detection & Monitoring

Log Indicators:

  • HTTP POST requests to /api/v1/upload_file/ with suspicious filenames containing ../ or absolute paths
  • File creation/modification in unexpected system locations

Network Indicators:

  • Unusual file upload patterns to the API endpoint
  • Multiple failed upload attempts with path traversal patterns

SIEM Query:

source="web_logs" AND uri_path="/api/v1/upload_file/" AND (filename="*../*" OR filename="*:*" OR filename="*\\*" OR filename="*/*")

🔗 References

📤 Share & Export