CVE-2021-29531: Denial of Service Vulnerability in TensorFlow-GPU
Summary
CVE-2021-29531: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.
< 2.1.4
>= 2.2.0, < 2.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
< 26eb323554ffccd173e8a79a8c05c15b685ae4d1
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
The same CVE-2021-29531 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-GPU is an open-source platform for machine learning that provides an end-to-end solution for developing and deploying machine learning models. It is widely used in various industries and research fields. TensorFlow-GPU allows users to leverage the power of GPUs for accelerated training and inference of machine learning models. However, a vulnerability has been discovered in TensorFlow-GPU that can be exploited to mount a denial of service attack.
Vulnerability Detail
The vulnerability in TensorFlow-GPU arises from a flaw in the PNG encoding functionality. When encoding a PNG image, the implementation fails to validate the input tensor properly. An attacker can trigger a CHECK fail by providing an empty input tensor as the pixel data. This allows the attacker to send an empty matrix for encoding, resulting in a null pointer dereference and triggering an abort call. By exploiting this vulnerability, an attacker can cause the TensorFlow-GPU application to crash, leading to a denial of service condition. The impact of this vulnerability can be significant, as it can disrupt the availability of TensorFlow-GPU applications and potentially affect the overall system stability.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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-gpu==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow-gpu==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow-gpu==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow-gpu==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 validate the input tensor before passing it to the PNG encoding function. By checking if the tensor is empty, users can avoid triggering the vulnerability. Here is an example of how to perform this validation in Python:
import tensorflow as tf
# Check if the tensor is empty
if tf.size(image_tensor) == 0:
print('Error: Empty input tensor')
# Handle the error or skip the encoding process
else:
# Perform PNG encoding
encoded_image = tf.image.encode_png(image_tensor)
By implementing this workaround, users can prevent the vulnerability from being exploited until they can update to a patched version of TensorFlow-GPU.
Conclusion
The vulnerability in TensorFlow-GPU can be exploited to mount a denial of service attack. Users are advised to update their installations to the latest version once the fix is available. In the meantime, a temporary workaround is provided to mitigate the risk. For further support and assistance with vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow-GPU is an open-source platform for machine learning that provides GPU-accelerated training and inference capabilities.
This vulnerability allows an attacker to mount a denial of service attack by causing the TensorFlow-GPU application to crash.
The vulnerability will be fixed in TensorFlow 2.5.0. Users should update their installations once the new version is available.
Yes, earlier versions including TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4 are also affected. The fix will be backported to these versions.
Yes, users can validate the input tensor before encoding to avoid triggering the vulnerability. See the 'workaround' section for more details.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.