CVE-2021-29585: TensorFlow CPU - Padding Computation Vulnerability

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-cpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-cpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

Share this vulnerability

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).

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

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.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-cpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-cpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback