CVE-2021-29611: Incomplete validation in TensorFlow SparseReshape
Summary
CVE-2021-29611: Incomplete validation in SparseReshape. Affects tensorflow across 2 version ranges.
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
Fixed in 2.3.3 or 2.4.2, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29611 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 widely used for developing and training deep learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications. TensorFlow includes a module called SparseReshape, which is responsible for reshaping sparse tensors. Sparse tensors are a specialized data structure used in certain machine learning tasks to efficiently represent sparse data. However, a vulnerability has been discovered in the implementation of SparseReshape in TensorFlow versions 2.3.0 to 2.3.3 and 2.4.0 to 2.4.2.
Vulnerability Detail
The vulnerability, identified as CVE-2021-29611, stems from incomplete validation in the SparseReshape module. This flaw allows an attacker to trigger a denial of service (DoS) condition by exploiting a CHECK-failure. By providing invalid input arguments to the SparseReshape function, an attacker can cause the TensorFlow application to crash. The issue lies in the lack of validation for the input arguments, which should specify a valid sparse tensor. This vulnerability has a CVSS score of 3.6, indicating a low severity level.
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.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow==2.4.2"
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 temporary workaround, users can avoid using the SparseReshape function in their TensorFlow applications. By removing or replacing the usage of SparseReshape, the vulnerability can be mitigated. Here is an example of how to modify the code to avoid using SparseReshape:
import tensorflow as tf
input_indices = tf.constant(41, shape=[1, 1], dtype=tf.int64)
input_shape = tf.zeros([11], dtype=tf.int64)
new_shape = tf.zeros([1], dtype=tf.int64)
# Instead of using SparseReshape
# tf.raw_ops.SparseReshape(input_indices=input_indices,
# input_shape=input_shape,
# new_shape=new_shape)
# Use an alternative method
reshaped_tensor = tf.sparse.reshape(tf.sparse.SparseTensor(indices=input_indices, values=[], dense_shape=input_shape), new_shape)
Conclusion
In conclusion, the vulnerability CVE-2021-29611 in TensorFlow's SparseReshape module allows for a denial of service (DoS) attack by exploiting a CHECK-failure. Users are advised to update their TensorFlow installation to one of the patched versions or apply the provided workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework used for developing and training deep learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications.
SparseReshape is a module in TensorFlow that is used for reshaping sparse tensors. Sparse tensors are a specialized data structure used in certain machine learning tasks to efficiently represent sparse data.
The vulnerability in SparseReshape can be exploited to trigger a denial of service (DoS) condition by causing a CHECK-failure. This can lead to the TensorFlow application crashing, resulting in a disruption of service.
To fix this vulnerability, users should update their TensorFlow installation to one of the patched versions: TensorFlow 2.3.3, TensorFlow 2.4.2, or TensorFlow 2.5.0 (upcoming release). This can be done by running the appropriate package manager command or manually downloading and installing the updated version from the TensorFlow website.
Yes, as a temporary workaround, users can avoid using the SparseReshape function in their TensorFlow applications. By removing or replacing the usage of SparseReshape, the vulnerability can be mitigated.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.