CVE-2021-37680: Division by zero in TFLite

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
Moderate
5.5

CVE-2021-37680: Division by zero in TFLite. Affects tensorflow across 3 version ranges.

< 2.3.4 >= 2.4.0, < 2.4.3 >= 2.5.0, < 2.5.1

Fixed in 2.3.4, 2.4.3 or 2.5.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-37680 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

The TensorFlow Lite (TFLite) package is an open-source deep learning framework developed by TensorFlow. It is designed to run machine learning models on resource-constrained devices such as mobile phones, embedded systems, and microcontrollers. TFLite provides a lightweight and efficient solution for deploying neural networks in edge devices. However, a vulnerability has been discovered in TFLite that can lead to a division by zero error.

Vulnerability Detail

The vulnerability in TFLite arises from a division operation in the implementation of fully connected layers. Specifically, the vulnerable code can be found in the fully_connected.cc file. The division operation is performed to calculate the batch size as input_size / filter->dims->data[1]. An attacker can exploit this vulnerability by crafting a malicious model that sets filter->dims->data[1] to zero. As a result, a division by zero error occurs during the execution of the model. This vulnerability can potentially lead to a crash or undefined behavior of the TFLite runtime.

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.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"
  • >= 2.5.0, < 2.5.1 2.5.1
    pip install --upgrade "tensorflow==2.5.1"

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 check the value of filter->dims->data[1] before executing any TFLite models. If the value is zero, the model should not be executed to avoid the division by zero error. Here is an example code snippet that demonstrates the workaround:

import tensorflow as tf

# Load and preprocess the TFLite model
model = tf.lite.Interpreter('model.tflite')

# Check the value of filter->dims->data[1]
if model.get_tensor(0).shape[1] == 0:
    print('Error: Division by zero detected. Model execution aborted.')
else:
    # Execute the TFLite model
    model.invoke()

Please note that this workaround should only be used until the TensorFlow installation is updated to a patched version.

Conclusion

In conclusion, the vulnerability in TFLite that allows a division by zero error has been addressed by the TensorFlow team. Users are advised to update their TensorFlow installation to one of the patched versions to mitigate the risk. Until the update is applied, a temporary workaround is available to manually check the value of filter->dims->data[1] before executing TFLite models. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow Lite (TFLite) is an open-source deep learning framework developed by TensorFlow. It is designed for running machine learning models on resource-constrained devices such as mobile phones, embedded systems, and microcontrollers.

The vulnerability in TFLite can lead to a division by zero error, potentially causing a crash or undefined behavior of the TFLite runtime. This can impact the execution of machine learning models on resource-constrained devices.

To fix this vulnerability, users should update their TensorFlow installation to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4. The TensorFlow team has provided a GitHub commit that addresses the issue.

Yes, there is a temporary workaround. Users can manually check the value of filter->dims->data[1] before executing any TFLite models. If the value is zero, the model should not be executed to avoid the division by zero error. The provided code snippet demonstrates this workaround.

This vulnerability has been reported by members of the Aivul Team from Qihoo 360 and Yakun Zhang of Baidu Security.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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==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.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"
  • >= 2.5.0, < 2.5.1 2.5.1
    pip install --upgrade "tensorflow==2.5.1"

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