CVE-2021-29585: TensorFlow CPU - Padding Computation Vulnerability
Summary
CVE-2021-29585: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu 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
< 49847ae69a4e1a97ae7f2db5e217c77721e37948
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-gpu · PyPI
The same CVE-2021-29585 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 CPU is a specific package within TensorFlow that focuses on running TensorFlow computations on CPUs. This package is widely used in various machine learning applications and frameworks.
Vulnerability Detail
The vulnerability (CVE-2021-29585) exists in the TFLite computation for size of output after padding in TensorFlow CPU. The ComputeOutSize function, responsible for calculating the output size after padding, does not validate the stride argument before performing division. This oversight allows users to create malicious models that trigger a call to ComputeOutSize with a stride value of 0. As a result, a division by zero error occurs, leading to potential crashes, unexpected behavior, or even remote code execution. The vulnerability affects versions of TensorFlow CPU up to and including 2.4.3.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-cpu==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-cpu==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-cpu==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-cpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-cpu==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, users can manually validate the stride argument before calling the ComputeOutSize function. By ensuring that the stride value is not 0, the vulnerability can be mitigated. Here's an example of how to perform the validation in Python:
stride = ... # The stride value
if stride != 0:
output_size = ComputeOutSize(...)
else:
# Handle the case when stride is 0
...
Conclusion
The padding computation vulnerability in TensorFlow CPU (CVE-2021-29585) poses a risk of crashes, unexpected behavior, or remote code execution. It is crucial for users to update their TensorFlow CPU installations to the latest patched version or apply the backported fixes to mitigate the vulnerability. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools, libraries, and resources for developing and deploying machine learning models.
TensorFlow CPU is a specific package within TensorFlow that focuses on running TensorFlow computations on CPUs. It is widely used in various machine learning applications and frameworks.
The vulnerability (CVE-2021-29585) is related to the TFLite computation for size of output after padding. It allows users to craft models that trigger a division by zero error, potentially leading to crashes, unexpected behavior, or remote code execution.
The vulnerability affects versions of TensorFlow CPU up to and including 2.4.3.
To fix the vulnerability, update your TensorFlow CPU installation to the latest patched version (TensorFlow 2.5.0 or the backported fixes for older versions).
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.