CVE-2021-29531: Denial of Service Vulnerability in TensorFlow
Summary
CVE-2021-29531: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow 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-cpu · PyPI
- tensorflow-gpu · 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 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 supports various data formats and operations, including image encoding and decoding. However, a vulnerability has been discovered in the PNG encoding functionality of TensorFlow.
Vulnerability Detail
The vulnerability (CVE-2021-29531) in TensorFlow's PNG encoding functionality allows an attacker to trigger a CHECK fail by providing an empty input tensor as the pixel data. The implementation of the encoding process does not properly validate the input tensor, leading to a null pointer dereference. This can be exploited by an attacker to mount a denial of service attack against systems using TensorFlow. The issue affects versions 0 to 2.4.2 of TensorFlow.
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
There is no specific workaround available for this vulnerability. However, users can consider implementing additional input validation checks in their own code to prevent empty input tensors from being passed to the PNG encoding functionality.
Conclusion
The vulnerability in TensorFlow's PNG encoding functionality can be exploited by an attacker to mount a denial of service attack. It is crucial for users to update their TensorFlow installations to the latest version once the fix is released. Regularly checking for updates and applying them promptly is recommended to ensure the security and stability of TensorFlow deployments. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides tools and libraries for developing and deploying machine learning models.
The vulnerability allows an attacker to trigger a denial of service attack by providing an empty input tensor to the PNG encoding functionality in TensorFlow.
The vulnerability affects versions 0 to 2.4.2 of TensorFlow.
Yes, the fix will be included in TensorFlow 2.5.0. Users are advised to update to the latest version once it becomes available.
There is no specific workaround available. However, users can implement additional input validation checks in their code to mitigate the risk.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.