CVE-2021-29565: Null pointer dereference in tensorflow
Summary
CVE-2021-29565: Null pointer dereference in SparseFillEmptyRows. Affects tensorflow across 4 version ranges.
< 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-29565 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 community resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in TensorFlow that could lead to a null pointer dereference.
Vulnerability Detail
The vulnerability, identified as CVE-2021-29565, exists in the SparseFillEmptyRows function of TensorFlow. An attacker can exploit this vulnerability by providing an empty dense_shape tensor as input. Due to missing validation, the implementation of the function fails to handle this scenario, resulting in a null pointer dereference. This vulnerability has a CVSS score of 2.5, indicating a low severity level. However, it is still important to address this issue to ensure the stability and security of TensorFlow applications.
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, you can manually validate the dense_shape tensor before passing it to the SparseFillEmptyRows function. Here is an example of how to perform this validation in Python:
import tensorflow as tf
def sparse_fill_empty_rows_workaround(indices, values, dense_shape, default_value):
if dense_shape.size == 0:
# Handle the empty dense_shape tensor
return
tf.raw_ops.SparseFillEmptyRows(
indices=indices, values=values, dense_shape=dense_shape,
default_value=default_value)
Conclusion
In conclusion, the CVE-2021-29565 vulnerability in TensorFlow can be mitigated by upgrading to version 2.5.0 or later. It is important to keep your TensorFlow installation up to date to ensure the security and stability of your machine learning applications. If you have any further questions or need assistance with 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 tools and libraries for building and deploying machine learning models.
The vulnerability allows an attacker to trigger a null pointer dereference in TensorFlow, potentially leading to application crashes or other unexpected behavior.
To fix this vulnerability, you should upgrade to TensorFlow version 2.5.0 or later. Use the command pip install --upgrade tensorflow to update your installation.
Yes, you can manually validate the dense_shape tensor before calling the SparseFillEmptyRows function. Refer to the provided workaround code for more details.
For more information about TensorFlow security, you can consult the TensorFlow security guide available at https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.