CVE-2021-37650

7.8 HIGH

📋 TL;DR

This vulnerability in TensorFlow allows attackers to trigger heap buffer overflows and segmentation faults by passing non-string data types to dataset-to-record conversion functions. It affects TensorFlow users who process datasets with numeric types using tf.raw_ops.ExperimentalDatasetToTFRecord or tf.raw_ops.DatasetToTFRecord operations. The vulnerability stems from improper input validation that assumes all dataset records are strings.

💻 Affected Systems

Products:
  • TensorFlow
Versions: TensorFlow 2.3.0 to 2.3.3, 2.4.0 to 2.4.2, 2.5.0, and potentially earlier versions using experimental features
Operating Systems: All platforms running TensorFlow
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects users of tf.raw_ops.ExperimentalDatasetToTFRecord or tf.raw_ops.DatasetToTFRecord operations with non-string datasets.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data corruption, or denial of service through application crashes.

🟠

Likely Case

Application crashes (segmentation faults) causing denial of service and potential data loss in affected TensorFlow pipelines.

🟢

If Mitigated

Limited impact with proper input validation and sandboxing, potentially just application instability.

🌐 Internet-Facing: MEDIUM - Exploitation requires specific TensorFlow operations but could be triggered via API endpoints processing untrusted datasets.
🏢 Internal Only: MEDIUM - Data processing pipelines using affected operations remain vulnerable to internal threats or accidental triggers.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: LOW - Requires crafting datasets with numeric types to trigger the vulnerable code path.

Exploitation requires access to TensorFlow operations that process datasets, typically through application code or APIs.

🛠️ 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-f8h4-7rgh-q2gm

Restart Required: Yes

Instructions:

1. Identify TensorFlow version. 2. Upgrade to patched version: pip install tensorflow==2.6.0 (or appropriate version). 3. Restart all TensorFlow services and applications. 4. Verify fix with version check.

🔧 Temporary Workarounds

Input Validation Workaround

all

Add explicit type checking before calling vulnerable operations to ensure all dataset elements are strings.

# Python example: Ensure dataset contains only strings
import tensorflow as tf
# Add validation layer before vulnerable ops
def validate_string_dataset(dataset):
    return dataset.map(lambda x: tf.ensure_shape(x, [])).filter(lambda x: x.dtype == tf.string)

🧯 If You Can't Patch

  • Disable or remove usage of tf.raw_ops.ExperimentalDatasetToTFRecord and tf.raw_ops.DatasetToTFRecord operations
  • Implement strict input validation and sanitization for all dataset processing pipelines

🔍 How to Verify

Check if Vulnerable:

Check if code uses tf.raw_ops.ExperimentalDatasetToTFRecord or tf.raw_ops.DatasetToTFRecord with potentially non-string datasets.

Check Version:

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

Verify Fix Applied:

Verify TensorFlow version is 2.6.0+, 2.5.1+, 2.4.3+, or 2.3.4+ using version check command.

📡 Detection & Monitoring

Log Indicators:

  • Segmentation fault errors
  • TensorFlow core dumps
  • Unexpected process termination in dataset processing

Network Indicators:

  • Unusual dataset processing requests to TensorFlow-serving APIs

SIEM Query:

source="tensorflow" AND ("segmentation fault" OR "core dumped" OR "DatasetToTFRecord")

🔗 References

📤 Share & Export