CVE-2021-29593: Division by zero in TFLite's implementation of BatchToSpaceNd in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
Low
2.5

CVE-2021-29593: Division by zero in TFLite's implementation of BatchToSpaceNd. 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-29593 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

TensorFlow is an open-source machine learning framework that provides a comprehensive ecosystem of tools, libraries, and community resources. It is widely used for developing and deploying machine learning models in various applications. The BatchToSpaceNd operator in TensorFlow Lite is responsible for rearranging data in a tensor by splitting and shuffling the batch dimension. This operator is used in many TensorFlow models and can be vulnerable to a division by zero error.

Vulnerability Detail

The implementation of the BatchToSpaceNd operator in TensorFlow Lite contains a division by zero error. Specifically, the vulnerable code can be found in the batch_to_space_nd.cc file. The code attempts to divide the output batch size by the block shape dimension, but fails to check if the block shape dimension is zero. An attacker can exploit this vulnerability by crafting a model with a block input dimension set to zero, resulting in a division by zero error during execution. This vulnerability can lead to crashes, unexpected behavior, or denial of service.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow==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==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow==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 known workaround for this vulnerability. It is recommended to apply the patch or update TensorFlow to the latest version as soon as possible.

Conclusion

The division by zero vulnerability in TensorFlow's implementation of the BatchToSpaceNd operator can have serious consequences, including crashes and denial of service. It is crucial to update TensorFlow to the latest version or apply the provided patch to mitigate the vulnerability. For further support and assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open-source machine learning framework used for developing and deploying machine learning models.

The BatchToSpaceNd operator in TensorFlow Lite is responsible for rearranging data in a tensor by splitting and shuffling the batch dimension.

An attacker can exploit this vulnerability by crafting a model with a block input dimension set to zero, resulting in a division by zero error during execution.

This vulnerability can lead to crashes, unexpected behavior, or denial of service.

To fix this vulnerability, update TensorFlow to the latest version once the patch is available, or manually apply the patch by cherry-picking the commit onto affected TensorFlow versions.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

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