CVE-2024-5452
📋 TL;DR
This vulnerability allows remote attackers to execute arbitrary code on self-hosted PyTorch Lightning applications by exploiting improper deserialization in the deepdiff library. Attackers can bypass attribute modification restrictions to write arbitrary attributes and achieve full remote code execution. All self-hosted PyTorch Lightning applications with the default configuration are affected.
💻 Affected Systems
- lightning-ai/pytorch-lightning
📦 What is this software?
Pytorch Lightning by Lightningai
⚠️ Risk & Real-World Impact
Worst Case
Complete system compromise with attacker gaining full control over the application server, allowing data theft, lateral movement, and persistent access.
Likely Case
Remote code execution leading to data exfiltration, cryptocurrency mining, or ransomware deployment on vulnerable servers.
If Mitigated
Limited impact with proper network segmentation and access controls, potentially only affecting the application container.
🎯 Exploit Status
Exploit details are publicly available through the huntr.com bounty disclosure. The vulnerability requires sending a specially crafted serialized delta payload to the vulnerable endpoint.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Fixed in commit 330af381de88cff17515418a341cbc1f9f127f9a and subsequent releases
Vendor Advisory: https://github.com/lightning-ai/pytorch-lightning/commit/330af381de88cff17515418a341cbc1f9f127f9a
Restart Required: Yes
Instructions:
1. Update PyTorch Lightning to the latest version. 2. Verify the deepdiff library is updated or properly restricted. 3. Restart the application service. 4. Test that the delta endpoint no longer accepts malicious payloads.
🔧 Temporary Workarounds
Disable Delta Endpoint
allDisable the vulnerable delta endpoint if not required for functionality
Configure application to disable the delta processing feature or restrict access to the endpoint
Network Access Control
allRestrict network access to the PyTorch Lightning application
Use firewall rules to limit access to trusted IPs only
🧯 If You Can't Patch
- Implement strict input validation and sanitization for all deserialization operations
- Deploy network segmentation and application-level firewalls to monitor and block suspicious delta payloads
🔍 How to Verify
Check if Vulnerable:
Check if your PyTorch Lightning version is 2.2.1 or has the vulnerable deepdiff integration. Test by attempting to send a crafted delta payload to the endpoint.
Check Version:
pip show pytorch-lightning | grep Version
Verify Fix Applied:
Verify the application is using a patched version and test that malicious delta payloads are rejected or properly sanitized.
📡 Detection & Monitoring
Log Indicators:
- Unusual delta processing requests
- Errors related to deepdiff deserialization
- Unexpected attribute modification attempts
Network Indicators:
- Suspicious serialized data payloads to the delta endpoint
- Unusual outbound connections from the application server
SIEM Query:
source="application.logs" AND ("deepdiff.Delta" OR "dunder" OR "attribute write")