CVE-2022-21736: TensorFlow - Undefined behavior in SparseTensorSliceDataset
Summary
CVE-2022-21736: Undefined behavior in SparseTensorSliceDataset. Affects tensorflow across 3 version ranges.
< 2.5.3
>= 2.6.0, < 2.6.3
>= 2.7.0, < 2.7.1
Fixed in 2.5.3, 2.6.3 or 2.7.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-gpu · PyPI
- tensorflow-cpu · PyPI
The same CVE-2022-21736 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow supports various data types and operations, including sparse tensors. SparseTensorSliceDataset is a component in TensorFlow that allows users to create a dataset from a sparse tensor. However, a vulnerability has been identified in the implementation of SparseTensorSliceDataset, which can lead to undefined behavior and potential security risks.
Vulnerability Detail
The vulnerability in SparseTensorSliceDataset arises from the lack of validation for certain input arguments. When creating a dataset using SparseTensorSliceDataset, the implementation does not properly check the preconditions for the indices, values, and dense_shape arguments. This can result in the dereferencing of a null pointer, leading to undefined behavior. An attacker could potentially exploit this vulnerability to cause a denial of service or execute arbitrary code.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.0"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 2.5.32.5.3pip install --upgrade "tensorflow==2.5.3" -
>= 2.6.0, < 2.6.32.6.3pip install --upgrade "tensorflow==2.6.3" -
>= 2.7.0, < 2.7.12.7.1pip install --upgrade "tensorflow==2.7.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a workaround, users can validate the input arguments manually before calling SparseTensorSliceDataset. This involves ensuring that the indices, values, and dense_shape satisfy the required preconditions. Here's an example of how to perform the validation in Python:
import tensorflow as tf
import numpy as np
indices = [[]]
values = []
dense_shape = [1, 1]
if len(indices) != 0 and len(values) != 0 and len(dense_shape) == 2:
tf.raw_ops.SparseTensorSliceDataset(indices=indices, values=values, dense_shape=dense_shape)
else:
print('Invalid input arguments')
By manually validating the input arguments, users can mitigate the risk of triggering the undefined behavior.
Conclusion
The vulnerability in TensorFlow's SparseTensorSliceDataset can result in undefined behavior and potential security risks. It is crucial to update TensorFlow to the patched versions (2.5.3, 2.6.3, 2.7.1, or 2.8.0) to mitigate this vulnerability. Users can also manually validate the input arguments as a workaround. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models.
SparseTensorSliceDataset is a component in TensorFlow that allows users to create a dataset from a sparse tensor. It is used to handle sparse data efficiently in machine learning tasks.
The vulnerability in SparseTensorSliceDataset can lead to undefined behavior, which can be exploited by an attacker to cause a denial of service or execute arbitrary code. It is important to update TensorFlow to the patched versions to mitigate this risk.
To fix this vulnerability, users should update their TensorFlow installation to one of the patched versions: TensorFlow 2.5.3, TensorFlow 2.6.3, TensorFlow 2.7.1, or TensorFlow 2.8.0 (upcoming release). This can be done by upgrading the TensorFlow package using the package manager or following the installation instructions provided by TensorFlow.
Yes, users can manually validate the input arguments before calling SparseTensorSliceDataset to mitigate the risk of triggering the undefined behavior. The provided workaround code demonstrates how to perform the validation in Python.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.