CVE-2021-37691: FPE in LSH in TFLite

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
Moderate
5.5

CVE-2021-37691: FPE in LSH 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-37691 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

The TensorFlow package is an open-source machine learning framework developed by Google. It provides a comprehensive set of tools and libraries for building and deploying machine learning models. TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. It allows developers to run machine learning models on resource-constrained platforms. However, a vulnerability has been discovered in the LSH (Locality Sensitive Hashing) implementation of TFLite.

Vulnerability Detail

The vulnerability (CVE-2021-37691) in the LSH implementation of TFLite allows an attacker to craft a malicious TFLite model that triggers a division by zero error. The issue arises due to a lack of validation for the first dimension of the input tensor, which can be zero. This vulnerability can be exploited to cause a denial-of-service (DoS) condition by crashing the application or potentially executing arbitrary code.

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 workaround, users can add a check in their code to ensure that the first dimension of the input tensor is non-zero before passing it to the LSH implementation. Here is an example of how to add the check:

import tensorflow as tf

def lsh_projection(input_tensor, weight_tensor, seed):
    if input_tensor.shape[0] == 0:
        raise ValueError('Input tensor dimension cannot be zero.')
    # Rest of the LSH projection implementation
    ...

By adding this check, the vulnerability can be mitigated by preventing the execution of the vulnerable code path when the input tensor has a zero dimension.

Conclusion

The vulnerability (CVE-2021-37691) in the LSH implementation of TensorFlow Lite can be exploited to trigger a division by zero error, leading to a denial-of-service (DoS) condition or potential execution of arbitrary code. It is crucial to update to the patched versions of TensorFlow or apply the provided patches to mitigate this vulnerability. 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 machine learning framework developed by Google. It provides a comprehensive set of tools and libraries for building and deploying machine learning models.

TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. It allows developers to run machine learning models on resource-constrained platforms.

LSH (Locality Sensitive Hashing) is a technique used in machine learning for approximate nearest neighbor search. It is used in the LSH projection implementation of TFLite.

The vulnerability allows an attacker to craft a malicious TFLite model that triggers a division by zero error in the LSH implementation. This can lead to a denial-of-service (DoS) condition or potential execution of arbitrary code.

The vulnerability has been patched in the TensorFlow repository. It is recommended to update to TensorFlow version 2.6.0 or apply the respective patches for TensorFlow versions 2.5.1, 2.4.3, and 2.3.4.

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