CVE-2022-21736

7.6 HIGH

📋 TL;DR

This vulnerability in TensorFlow's SparseTensorSliceDataset allows attackers to cause a null pointer dereference by providing invalid input arguments that bypass validation checks. This affects all systems using vulnerable TensorFlow versions for machine learning workloads, potentially leading to crashes or arbitrary code execution.

💻 Affected Systems

Products:
  • TensorFlow
Versions: TensorFlow 2.5.0 to 2.7.0, and earlier versions if using SparseTensorSliceDataset
Operating Systems: All operating systems running TensorFlow
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems using SparseTensorSliceDataset functionality. The vulnerability exists in the core implementation regardless of configuration.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise if combined with other vulnerabilities or memory corruption techniques.

🟠

Likely Case

Application crash (denial of service) when processing malicious sparse tensor data.

🟢

If Mitigated

No impact if proper input validation is implemented or vulnerable code is not used.

🌐 Internet-Facing: MEDIUM - Requires specific TensorFlow functionality to be exposed via APIs or services.
🏢 Internal Only: MEDIUM - Internal ML pipelines using SparseTensorSliceDataset remain vulnerable.

🎯 Exploit Status

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

Exploitation requires crafting specific sparse tensor inputs to trigger the null pointer dereference. No public exploit code has been released.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: TensorFlow 2.8.0, 2.7.1, 2.6.3, 2.5.3

Vendor Advisory: https://github.com/tensorflow/tensorflow/security/advisories/GHSA-pfjj-m3jj-9jc9

Restart Required: No

Instructions:

1. Update TensorFlow to patched version: pip install --upgrade tensorflow==2.8.0 (or appropriate version). 2. Verify update with: python -c 'import tensorflow as tf; print(tf.__version__)'. 3. Test SparseTensorSliceDataset functionality.

🔧 Temporary Workarounds

Input validation wrapper

all

Implement custom validation for SparseTensorSliceDataset inputs before passing to TensorFlow

# Python example: Validate indices, values, dense_shape before calling SparseTensorSliceDataset
# Ensure all inputs are non-null and satisfy sparse tensor constraints

Disable vulnerable functionality

all

Avoid using SparseTensorSliceDataset in production code until patched

# Replace SparseTensorSliceDataset with alternative sparse tensor processing methods
# Comment out or remove calls to vulnerable function

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all sparse tensor data
  • Isolate TensorFlow workloads in containers with minimal privileges

🔍 How to Verify

Check if Vulnerable:

Check TensorFlow version: python -c 'import tensorflow as tf; print(tf.__version__)'. Versions 2.5.0-2.7.0 are vulnerable.

Check Version:

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

Verify Fix Applied:

Verify version is 2.8.0, 2.7.1, 2.6.3, or 2.5.3. Test SparseTensorSliceDataset with edge case inputs.

📡 Detection & Monitoring

Log Indicators:

  • Segmentation fault logs
  • TensorFlow crash reports
  • Null pointer exception in application logs

Network Indicators:

  • Unusual spikes in ML API failures
  • Increased error rates in TensorFlow services

SIEM Query:

source="tensorflow" AND ("segmentation fault" OR "null pointer" OR "SparseTensorSliceDataset")

🔗 References

📤 Share & Export