CVE-2021-29595: TensorFlow-CPU DepthToSpace Operator Division by Zero Vulnerability

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29595: 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.4 >= 2.4.0, < 2.4.3 < 106d8f4fb89335a2c52d7c895b7a7485465ca8d9

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-29595 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-CPU is a specific package that focuses on providing CPU support for TensorFlow. It allows users to run TensorFlow models on CPUs without the need for GPU acceleration. The DepthToSpace operator in TensorFlow-CPU is responsible for rearranging data in a tensor, and it is used in various machine learning tasks such as image processing and computer vision.

Vulnerability Detail

The DepthToSpace operator in TensorFlow-CPU is vulnerable to a division by zero error. This vulnerability occurs due to a lack of proper input validation, specifically when the params->block_size parameter is set to 0. An attacker can exploit this vulnerability by crafting a malicious model that triggers the division by zero error. The consequences of this vulnerability can range from program crashes to potential code execution, depending on how the error is handled by the application. This vulnerability affects multiple versions of TensorFlow-CPU, including 2.1.4, 2.2.3, 2.3.3, and 2.4.2.

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.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 temporary workaround, users can manually validate the params->block_size parameter before passing it to the DepthToSpace operator. By ensuring that the block size is not set to 0, the division by zero error can be avoided. Here is an example code snippet that demonstrates the workaround:

block_size = get_block_size()
if block_size != 0:
    depth_to_space(block_size)

Conclusion

The TensorFlow-CPU DepthToSpace operator division by zero vulnerability poses a risk to applications utilizing TensorFlow-CPU for machine learning tasks. It is crucial for users to update their TensorFlow-CPU installations to the patched versions provided by the TensorFlow team. Following the recommended fix and applying the workaround, if necessary, will help mitigate the risk of exploitation. 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 ecosystem of tools, libraries, and resources for developing and deploying machine learning models.

TensorFlow-CPU is a specific package that focuses on providing CPU support for TensorFlow. It allows users to run TensorFlow models on CPUs without the need for GPU acceleration.

The DepthToSpace operator is a functionality in TensorFlow that rearranges data in a tensor. It is commonly used in tasks such as image processing and computer vision.

The division by zero vulnerability in the DepthToSpace operator occurs due to a lack of proper input validation. When the params->block_size parameter is set to 0, a division by zero error is triggered.

The consequences of this vulnerability can range from program crashes to potential code execution, depending on how the error is handled by the application.

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