CVE-2021-37639

8.4 HIGH

📋 TL;DR

This vulnerability in TensorFlow allows attackers to cause a null pointer dereference or read memory outside heap bounds when restoring tensors via raw APIs. Attackers can trigger undefined behavior or memory disclosure by manipulating tensor names and restoration indices. All TensorFlow users who restore tensors via raw APIs are affected.

💻 Affected Systems

Products:
  • TensorFlow
Versions: TensorFlow 2.3.0 to 2.3.3, 2.4.0 to 2.4.2, 2.5.0, and 2.6.0-rc versions
Operating Systems: All operating systems running affected TensorFlow versions
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects users who restore tensors via raw APIs (tf.raw_ops.RestoreV2). Standard model loading/saving may not be affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution via memory corruption leading to complete system compromise, though this would require additional exploitation techniques beyond the OOB read.

🟠

Likely Case

Application crash (DoS) or memory disclosure that could leak sensitive information like model weights or training data.

🟢

If Mitigated

No impact if proper input validation is implemented or if raw tensor restoration APIs are not used.

🌐 Internet-Facing: MEDIUM - Requires specific API usage patterns and attacker control over tensor restoration parameters.
🏢 Internal Only: MEDIUM - Same technical risk but limited to internal users who can access the vulnerable functionality.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires control over tensor restoration parameters and knowledge of the raw API usage. No public exploits known at advisory publication.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: TensorFlow 2.6.0, 2.5.1, 2.4.3, and 2.3.4

Vendor Advisory: https://github.com/tensorflow/tensorflow/security/advisories/GHSA-gh6x-4whr-2qv4

Restart Required: No

Instructions:

1. Update TensorFlow to patched version: pip install --upgrade tensorflow==2.6.0 (or appropriate version). 2. Verify the fix by checking version: python -c 'import tensorflow as tf; print(tf.__version__)'. 3. Test tensor restoration functionality.

🔧 Temporary Workarounds

Input validation wrapper

all

Add validation checks before calling raw tensor restoration APIs to ensure tensor lists are non-empty and indices are within bounds.

# Python example wrapper function
import tensorflow as tf

def safe_restore_tensor(file_pattern, tensor_name, shape, dtype, preferred_shard=-1):
    # Validate inputs before calling raw API
    if not tensor_name or len(tensor_name) == 0:
        raise ValueError('Tensor name cannot be empty')
    # Additional validation logic here
    return tf.raw_ops.RestoreV2(...)

🧯 If You Can't Patch

  • Disable or restrict access to raw tensor restoration APIs in production environments
  • Implement strict input validation and bounds checking for all tensor restoration operations

🔍 How to Verify

Check if Vulnerable:

Check TensorFlow version: python -c 'import tensorflow as tf; print(tf.__version__)'. If version is between 2.3.0-2.3.3, 2.4.0-2.4.2, 2.5.0, or 2.6.0-rc, you are vulnerable.

Check Version:

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

Verify Fix Applied:

After updating, verify version is 2.6.0, 2.5.1, 2.4.3, or 2.3.4. Test tensor restoration with edge cases (empty tensor names, out-of-bounds indices) to ensure no crashes.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with segmentation faults or access violations
  • Unusual tensor restoration patterns with empty or malformed tensor names
  • Memory access errors in TensorFlow logs

Network Indicators:

  • Unusual API calls to tensor restoration endpoints if exposed via network

SIEM Query:

source='tensorflow' AND (event_type='crash' OR error_message LIKE '%segmentation fault%' OR error_message LIKE '%access violation%')

🔗 References

📤 Share & Export