CVE-2021-29586: TensorFlow Pooling Implementation Division by Zero

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29586: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu 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 < 5f7975d09eac0f10ed8a17dbb6f5964977725adc

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-29586 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 allows users to build and train neural networks, perform data preprocessing and augmentation, and deploy models on various platforms. It is widely used in both research and production environments.

Vulnerability Detail

The vulnerability (CVE-2021-29586) exists in the optimized pooling implementations in TFLite, a TensorFlow library for running machine learning models on mobile and embedded devices. The issue arises due to a failure to check the stride arguments before calling the ComputePaddingHeightWidth function. This allows users to create models with zero stride values, resulting in a division by zero error. An attacker can exploit this vulnerability by crafting a malicious model, leading to a denial of service (DoS) condition or potential code execution.

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==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 workaround, users can manually check and ensure that the stride arguments in their models are not set to zero. This can be done by validating the input parameters and adjusting the stride values if necessary. Here is an example code snippet that demonstrates the workaround:

import tensorflow as tf

# Check and adjust stride values
if stride_height == 0:
    stride_height = 1
if stride_width == 0:
    stride_width = 1

# Continue with pooling operation
# ...

Conclusion

The vulnerability (CVE-2021-29586) in TensorFlow's optimized pooling implementations can be exploited by crafting malicious models with zero stride values, resulting in a division by zero error. This can lead to a denial of service condition or potential code execution. It is recommended to update TensorFlow to the latest patched version (2.5.0 or above) or manually check and adjust the stride arguments in models to mitigate the vulnerability. For further support on 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 and resources for building and deploying machine learning models.

TFLite is a TensorFlow library specifically designed for running machine learning models on mobile and embedded devices.

This vulnerability allows an attacker to craft malicious models that can trigger a division by zero error, leading to a denial of service condition or potential code execution.

To fix this vulnerability, update your TensorFlow installation to the latest patched version (2.5.0 or above). Alternatively, you can manually check and adjust the stride arguments in your models to ensure they are not set to zero.

No, only TensorFlow versions 2.1.4 and above are affected. Versions 2.5.0 and later include the fix for this vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==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 →

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