CVE-2022-23591
📋 TL;DR
This CVE describes a stack overflow vulnerability in TensorFlow's GraphDef format that occurs when loading a SavedModel containing self-recursive functions. The vulnerability affects TensorFlow users who load untrusted models, potentially causing denial of service through stack exhaustion. All TensorFlow users loading external models are at risk.
💻 Affected Systems
- TensorFlow
📦 What is this software?
⚠️ Risk & Real-World Impact
Worst Case
Complete service disruption through stack overflow crash when loading a malicious model, potentially leading to denial of service in production ML systems.
Likely Case
Denial of service when processing specially crafted models, causing TensorFlow processes to crash with stack overflow errors.
If Mitigated
No impact if models are validated before loading or if patched versions are used.
🎯 Exploit Status
Exploitation requires the ability to load a malicious SavedModel file into a vulnerable TensorFlow instance.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: TensorFlow 2.8.0, 2.7.1, 2.6.3, and 2.5.3
Vendor Advisory: https://github.com/tensorflow/tensorflow/security/advisories/GHSA-247x-2f9f-5wp7
Restart Required: Yes
Instructions:
1. Identify current TensorFlow version. 2. Upgrade to patched version: pip install tensorflow==2.8.0 (or appropriate version). 3. Restart all TensorFlow services and applications.
🔧 Temporary Workarounds
Model validation before loading
allImplement validation checks to ensure models don't contain self-recursive functions before loading them into TensorFlow.
Sandbox model execution
allRun TensorFlow in isolated environments with resource limits to contain potential stack overflow crashes.
🧯 If You Can't Patch
- Implement strict model validation and sanitization before loading any SavedModel files
- Isolate TensorFlow processes with resource limits and monitoring for stack overflow crashes
🔍 How to Verify
Check if Vulnerable:
Check TensorFlow version: python -c 'import tensorflow as tf; print(tf.__version__)' and compare against affected versions.
Check Version:
python -c 'import tensorflow as tf; print(tf.__version__)'
Verify Fix Applied:
After patching, verify version is 2.8.0, 2.7.1, 2.6.3, or 2.5.3, and test loading models that previously caused issues.
📡 Detection & Monitoring
Log Indicators:
- Stack overflow errors in TensorFlow logs
- Process crashes when loading models
- Abnormal termination of TensorFlow services
Network Indicators:
- Unusual model uploads to TensorFlow-serving endpoints
- Multiple failed model loading attempts
SIEM Query:
source="tensorflow" AND ("stack overflow" OR "segmentation fault" OR "crash")
🔗 References
- https://github.com/tensorflow/tensorflow/commit/448a16182065bd08a202d9057dd8ca541e67996c
- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-247x-2f9f-5wp7
- https://github.com/tensorflow/tensorflow/commit/448a16182065bd08a202d9057dd8ca541e67996c
- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-247x-2f9f-5wp7