CVE-2021-29585: TensorFlow - TFLite Computation Size of Output After Padding Vulnerability

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Low
2.5

CVE-2021-29585: 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 < 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow is widely used in various domains, including computer vision, natural language processing, and reinforcement learning. The TFLite module in TensorFlow is specifically designed for deploying machine learning models on mobile and embedded devices. It allows developers to optimize and run TensorFlow models on resource-constrained platforms. However, a vulnerability has been discovered in the TFLite computation for the size of output after padding, which can be exploited by malicious actors to cause unexpected behavior or crashes in applications that use TensorFlow.

Vulnerability Detail

The vulnerability in TensorFlow's TFLite module arises from a lack of validation in the ComputeOutSize function, which calculates the size of the output tensor after padding. This function does not check whether the stride argument is set to 0 before performing division operations. As a result, an attacker can create specially crafted models that trigger the ComputeOutSize function with a stride value of 0, leading to potential division by zero errors or incorrect output size calculations. This vulnerability affects TensorFlow versions 2.1.4 and earlier, 2.2.3 and earlier, 2.3.3 and earlier, and 2.4.2 and earlier.

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.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 temporary workaround, users can avoid the vulnerability by ensuring that they do not use a stride value of 0 when calling the ComputeOutSize function. It is recommended to review the codebase and identify any instances where the ComputeOutSize function is used and verify that the stride argument is always set to a non-zero value.

Conclusion

The vulnerability in TensorFlow's TFLite module can be mitigated by updating to the patched versions of TensorFlow. It is crucial for users to promptly apply the necessary updates to ensure the security and stability of their machine learning applications. For further assistance or support in addressing this vulnerability, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem of tools and libraries for building and deploying machine learning models.

TFLite is a module in TensorFlow that is specifically designed for deploying machine learning models on mobile and embedded devices.

The ComputeOutSize function in TensorFlow's TFLite module is responsible for calculating the size of the output tensor after padding.

The vulnerability can be exploited by crafting malicious models that trigger the ComputeOutSize function with a stride value of 0, leading to potential division by zero errors or incorrect output size calculations.

The vulnerability affects TensorFlow versions 2.1.4 and earlier, 2.2.3 and earlier, 2.3.3 and earlier, and 2.4.2 and earlier.

Related vulnerabilities

Recent vulnerabilities recorded for 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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

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