CVE-2021-29587: TensorFlow GPU - SpaceToDepth TFLite Operator Division by Zero Vulnerability

tensorflow-gpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29587: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.

< 0d45ea1ca641b21b73bcf9c00e0179cda284e7e7 >= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile 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 developing and deploying machine learning models. TensorFlow GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. The SpaceToDepth TFLite operator is used for rearranging data in a tensor by spatially partitioning it into blocks and then concatenating them. This operator is susceptible to a division by zero vulnerability.

Vulnerability Detail

The vulnerability (CVE-2021-29587) arises from the lack of a check for zero before division in the Prepare step of the SpaceToDepth TFLite operator in TensorFlow. An attacker can exploit this vulnerability by crafting a malicious model that sets the params->block_size parameter to zero. When the model is executed, the division by zero occurs, leading to potential crashes, unexpected behavior, or even remote code execution. The vulnerability affects TensorFlow versions 2.1.4 to 2.4.3, as well as TensorFlow GPU versions 0 to 2.4.3.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-gpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-gpu==2.3.0rc0"
  • >= 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 source files. Specifically, the space_to_depth.cc file located at tensorflow/lite/kernels/space_to_depth.cc needs to be edited. The Prepare function should be modified to include a check for zero before performing the division operation. Here is an example of the modified code:

double block_size = params->block_size;
if (block_size == 0) {
  // Handle the division by zero case
  // Perform necessary actions
} else {
  // Perform the division operation
  // Continue with the normal execution
}

Conclusion

The division by zero vulnerability in the SpaceToDepth TFLite operator of TensorFlow GPU can be exploited by an attacker to cause crashes, unexpected behavior, or even remote code execution. Users are advised to update their TensorFlow installations to the latest patched version and follow the official documentation for guidance. For further support on vulnerability remediation, contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models.

The SpaceToDepth TFLite operator is used in TensorFlow to rearrange data in a tensor by spatially partitioning it into blocks and then concatenating them.

The vulnerability occurs because the Prepare step of the SpaceToDepth TFLite operator in TensorFlow does not check for zero before performing the division operation. An attacker can exploit this by setting the params->block_size parameter to zero in a crafted model.

The division by zero vulnerability in the SpaceToDepth TFLite operator can lead to crashes, unexpected behavior, or even remote code execution when a maliciously crafted model is executed.

To fix this vulnerability, it is recommended to update your TensorFlow installation to the latest patched version. Follow the official TensorFlow documentation for instructions on updating the library.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-gpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-gpu==2.3.0rc0"
  • >= 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