CVE-2022-23591

7.5 HIGH

📋 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

Products:
  • TensorFlow
Versions: TensorFlow 2.5.0 through 2.7.0, and potentially earlier versions
Operating Systems: All operating systems running TensorFlow
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability is present in default configurations when loading SavedModel files containing self-recursive functions.

📦 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.

🌐 Internet-Facing: MEDIUM - Exploitation requires loading malicious models, which typically requires some level of user interaction or API access.
🏢 Internal Only: MEDIUM - Internal users could still trigger the vulnerability by loading malicious models, but attack surface is more limited.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: LOW - Creating malicious models with self-recursive functions is straightforward for attackers with TensorFlow knowledge.

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

all

Implement validation checks to ensure models don't contain self-recursive functions before loading them into TensorFlow.

Sandbox model execution

all

Run 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

📤 Share & Export