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

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
High
Not published

CVE-2021-29587: Division by zero in TFLite's implementation of SpaceToDepth. Affects tensorflow across 4 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2

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

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 for building and deploying machine learning models. The SpaceToDepth TFLite operator is used to rearrange data by spatially partitioning it into blocks and then concatenating them. This operator is vulnerable to a division by zero issue in the Prepare step, which can be exploited by an attacker.

Vulnerability Detail

The Prepare step of the SpaceToDepth TFLite operator in TensorFlow does not check for a zero value before performing division. This can be exploited by an attacker by crafting a malicious model where the params->block_size parameter is set to zero. As a result, a division by zero error occurs during the execution of the operator. This vulnerability can lead to various consequences, including denial of service (DoS) attacks, data corruption, and potential code execution.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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

There is no specific workaround mentioned for this vulnerability. Users are advised to follow the recommended fix and upgrade to the patched versions of TensorFlow.

Conclusion

The SpaceToDepth TFLite operator in TensorFlow is vulnerable to a division by zero issue, which can be exploited by an attacker. To mitigate this vulnerability, users should upgrade their TensorFlow installations to the patched versions or follow the recommended fix. For further support on vulnerability remediation, 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 for building and deploying machine learning models.

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

This vulnerability can lead to denial of service (DoS) attacks, data corruption, and potential code execution.

To fix this vulnerability, upgrade your TensorFlow installation to version 2.5.0 or later. Alternatively, you can upgrade to the patched versions for earlier supported versions.

There is no specific workaround mentioned for this vulnerability. It is recommended to follow the fix and upgrade to the patched versions.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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