CVE-2021-29611: TensorFlow Incomplete Validation in SparseReshape
Summary
CVE-2021-29611: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow across 5 version ranges.
< 1d04d7d93f4ed3854abf75d6b712d72c3f70d6b6
< 2.1.4
>= 2.2.0, < 2.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
Fixed in 4 releases; the minimum fixed version depends 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 end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. It offers support for both deep learning and traditional machine learning algorithms, making it a popular choice among developers and data scientists.
Vulnerability Detail
The vulnerability identified as CVE-2021-29611 affects TensorFlow versions 2.3.0 and above. It arises from incomplete validation in the SparseReshape function, which is used to reshape sparse tensors. The implementation of this function lacks proper validation of the input arguments, allowing for the possibility of specifying invalid sparse tensors. As a result, a denial of service (DoS) vulnerability can be exploited through a CHECK-failure. An attacker could potentially craft malicious inputs that trigger this vulnerability, leading to a crash or unexpected behavior in TensorFlow applications. The impact of this vulnerability can range from service disruption to potential security risks if the affected TensorFlow instance is part of a larger system.
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.1.42.1.4pip install --upgrade "tensorflow==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow==2.2.3" -
>= 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 workaround, users can consider implementing input validation checks in their own code when using the SparseReshape function. By ensuring that the input arguments specify valid sparse tensors, the risk of triggering the vulnerability can be reduced. Here is an example of how input validation can be performed in Python:
import tensorflow as tf
def validate_sparse_reshape(input_tensor, new_shape):
if not isinstance(input_tensor, tf.SparseTensor):
raise ValueError('Input tensor must be a SparseTensor.')
if not isinstance(new_shape, tf.TensorShape):
raise ValueError('New shape must be a TensorShape.')
# Perform the SparseReshape operation
reshaped_tensor = tf.sparse.reshape(input_tensor, new_shape)
return reshaped_tensor
Conclusion
The vulnerability identified as CVE-2021-29611 in TensorFlow's SparseReshape function can lead to a denial of service condition and potential security risks. It is crucial for users to update their TensorFlow installations to the fixed versions (2.4.2, 2.3.3, or 2.5.0) to mitigate the risk. Implementing input validation checks when using the SparseReshape function can serve as a temporary 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 platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models.
The vulnerability can result in a denial of service (DoS) condition in TensorFlow applications. It can lead to crashes or unexpected behavior, potentially disrupting services or creating security risks.
The vulnerability affects TensorFlow versions 2.3.0 and above. Specifically, versions 2.3.0, 2.3.3, 2.4.0, 2.4.2, and 2.5.0 are impacted.
To fix this vulnerability, it is recommended to upgrade to the latest available version of TensorFlow (2.4.2, 2.3.3, or 2.5.0). Follow the official upgrade instructions provided by the TensorFlow project.
Yes, a workaround is to implement input validation checks in your code when using the SparseReshape function. By ensuring that the input arguments specify valid sparse tensors, the risk of triggering the vulnerability can be reduced.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.