CVE-2021-29595: TensorFlow GPU - Division by Zero Error in DepthToSpace TFLite Operator

tensorflow-gpu 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-gpu 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 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 resources for building and deploying machine learning models. TensorFlow GPU is a variant of TensorFlow that leverages the power of GPUs for accelerated computation. The DepthToSpace TFLite operator is responsible for rearranging data in a tensor from depth into blocks of spatial data. This operator is used in various machine learning models and applications.

Vulnerability Detail

The implementation of the DepthToSpace TFLite operator in TensorFlow GPU is vulnerable to a division by zero error. The vulnerability exists in the code responsible for calculating the block size parameter (params->block_size). An attacker can craft a malicious model in such a way that the block size is set to zero, triggering a division by zero error during execution. This vulnerability can lead to a crash or unexpected behavior of the TensorFlow GPU runtime. The issue has been identified and fixed in TensorFlow 2.5.0. To mitigate the risk, it is recommended to update to the latest version of TensorFlow GPU.

How To Fix

Latest published version: 2.12.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-gpu==2.12.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-gpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-gpu==2.2.3"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-gpu==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 modify the affected code in the TensorFlow GPU source files to handle the division by zero error. One possible approach is to add a check for a zero block size before performing the division operation. Here is an example of how the code can be modified:

// Original code
if (params->block_size == 0) {
  // Division by zero error
}

// Modified code
if (params->block_size == 0) {
  // Handle the division by zero error
} else {
  // Perform the division operation
}

Conclusion

The division by zero error in the DepthToSpace TFLite operator of TensorFlow GPU can be exploited by an attacker to cause a crash or unexpected behavior of the TensorFlow GPU runtime. To mitigate this vulnerability, it is recommended to update TensorFlow GPU to version 2.5.0 or later. Alternatively, a temporary workaround can be applied by modifying the affected code to handle the division by zero error. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow GPU is a variant of TensorFlow that utilizes the power of GPUs for accelerated computation. It is specifically designed to leverage the parallel processing capabilities of GPUs to speed up machine learning tasks.

The DepthToSpace TFLite operator is responsible for rearranging data in a tensor from depth into blocks of spatial data. It is commonly used in machine learning models and applications that involve image processing and convolutional neural networks.

An attacker can craft a malicious machine learning model in such a way that the block size parameter (params->block_size) of the DepthToSpace TFLite operator is set to zero. When this model is executed using TensorFlow GPU, it triggers a division by zero error, leading to a crash or unexpected behavior of the TensorFlow GPU runtime.

The division by zero error in the DepthToSpace TFLite operator can cause the TensorFlow GPU runtime to crash or exhibit unexpected behavior. This can disrupt the execution of machine learning models and potentially lead to incorrect results or system instability.

You can use Vulert, a vulnerability monitoring tool, to check if your application is affected by this vulnerability. Vulert analyzes your Pipfile.lock file and provides real-time alerts for open-source vulnerabilities. Visit the Vulert playground at Vulert Scanner to check if your application is affected without any signup or installation.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

How To Fix

Latest published version: 2.12.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-gpu==2.12.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-gpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-gpu==2.2.3"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-gpu==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