CVE-2021-29568: TensorFlow - ParameterizedTruncatedNormal Null Pointer Dereference
Summary
CVE-2021-29568: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow across 5 version ranges.
>= 2.2.0, < 2.3.0rc0
< 2.2.0rc0
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< 5e52ef5a461570cfb68f3bdbbebfe972cb4e0fd8
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-29568 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 CPU and GPU computations, making it suitable for a wide range of applications. However, a vulnerability has been discovered in TensorFlow that can lead to undefined behavior and potential security risks.
Vulnerability Detail
The vulnerability (CVE-2021-29568) exists in the tf.raw_ops.ParameterizedTruncatedNormal function of TensorFlow. An attacker can trigger undefined behavior by binding to a null pointer. The issue arises due to the lack of input argument validation in the implementation of the function. Specifically, the shape argument is not checked for emptiness before accessing its first element. If the shape argument is empty, the shape_tensor.flat<T>() array will also be empty, leading to undefined behavior. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) condition or potentially 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.2.0rc02.2.0rc0pip install --upgrade "tensorflow==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3"
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 shape argument before calling the tf.raw_ops.ParameterizedTruncatedNormal function. Ensure that the shape argument is not empty before passing it to the function. Here is an example of how to perform the validation in Python:
import tensorflow as tf
def parameterized_truncated_normal(shape, dtype=tf.float32, seed=None):
if not shape:
raise ValueError('Shape argument cannot be empty.')
return tf.raw_ops.ParameterizedTruncatedNormal(shape=shape, dtype=dtype, seed=seed)
Conclusion
The vulnerability (CVE-2021-29568) in TensorFlow's tf.raw_ops.ParameterizedTruncatedNormal function can lead to undefined behavior and potential security risks. It is crucial to upgrade to TensorFlow 2.5.0 or apply the backported fixes to ensure the security and stability of your machine learning applications. 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 ecosystem of tools, libraries, and resources.
This vulnerability can lead to undefined behavior, potentially causing a denial-of-service (DoS) condition or arbitrary code execution.
The vulnerability affects TensorFlow versions 2.1.4 and later, including 2.5.0. Versions 2.2.0 to 2.4.3 are also affected.
Yes, the vulnerability has been fixed in TensorFlow 2.5.0. Backported fixes are also available for versions 2.4.2, 2.3.3, 2.2.3, and 2.1.4.
To protect your application, it is recommended to upgrade to the fixed version of TensorFlow or apply the backported fixes if you are using an older version.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.