CVE-2021-37666

7.8 HIGH

📋 TL;DR

This vulnerability in TensorFlow allows an attacker to cause undefined behavior by triggering a null pointer dereference in the RaggedTensorToVariant operation. Attackers could potentially crash the application or execute arbitrary code. All systems running affected TensorFlow versions are vulnerable.

💻 Affected Systems

Products:
  • TensorFlow
Versions: TensorFlow 2.3.0-2.3.3, 2.4.0-2.4.2, 2.5.0
Operating Systems: All platforms running TensorFlow
Default Config Vulnerable: ⚠️ Yes
Notes: Any system using tf.raw_ops.RaggedTensorToVariant operation is vulnerable

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, or service disruption

🟠

Likely Case

Application crash causing denial of service and potential data corruption

🟢

If Mitigated

Limited impact with proper input validation and sandboxing in place

🌐 Internet-Facing: HIGH - TensorFlow models often serve internet-facing APIs
🏢 Internal Only: MEDIUM - Internal ML pipelines could be disrupted

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires crafting specific input to trigger the null pointer dereference

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: TensorFlow 2.6.0, 2.5.1, 2.4.3, 2.3.4

Vendor Advisory: https://github.com/tensorflow/tensorflow/security/advisories/GHSA-w4xf-2pqw-5mq7

Restart Required: Yes

Instructions:

1. Update TensorFlow to patched version: pip install --upgrade tensorflow==2.6.0
2. Restart all TensorFlow services and applications
3. Verify the fix by checking version and testing RaggedTensorToVariant operations

🔧 Temporary Workarounds

Input validation wrapper

all

Add custom validation to check for empty splits before calling RaggedTensorToVariant

# Python code to wrap vulnerable function
import tensorflow as tf

def safe_ragged_tensor_to_variant(rt_nested_splits, rt_dense_values):
    for splits in rt_nested_splits:
        if splits.shape[0] == 0:
            raise ValueError('Empty splits not allowed')
    return tf.raw_ops.RaggedTensorToVariant(rt_nested_splits, rt_dense_values)

🧯 If You Can't Patch

  • Disable or restrict access to RaggedTensorToVariant operations
  • Implement strict input validation and sanitization for all TensorFlow inputs

🔍 How to Verify

Check if Vulnerable:

Check TensorFlow version: python -c 'import tensorflow as tf; print(tf.__version__)'

Check Version:

python -c 'import tensorflow as tf; print(tf.__version__)'

Verify Fix Applied:

Test RaggedTensorToVariant with empty splits input - should raise proper error instead of crashing

📡 Detection & Monitoring

Log Indicators:

  • Segmentation faults in TensorFlow processes
  • Unexpected process termination
  • Error logs mentioning RaggedTensorToVariant

Network Indicators:

  • Unusual patterns of requests to TensorFlow serving endpoints
  • Sudden service unavailability

SIEM Query:

process_name:tensorflow AND (event_type:crash OR exit_code:139)

🔗 References

📤 Share & Export