# CVE-2021-37691: TensorFlow TFLite division by zero in LSH operation

Source: https://junglewise.ai/threats/cve-2021-37691-tensorflow-tflite-division-by-zero-in-lsh-operation  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-08-12. Updated: 2026-09-26  
License: CC BY 4.0 with a link back

CVE-2021-37691 · Severity: low · CVSS 3.1 · Published 2021-08-12

TensorFlow is a machine learning library that includes TFLite, a lightweight runtime for deploying neural networks. An attacker can craft a specially designed model that triggers a division-by-zero crash in the LSH (Locality Sensitive Hashing) implementation, causing the application to crash and become unavailable. This affects anyone running TensorFlow-based applications that load untrusted models.

Technologies: [Google TensorFlow](https://junglewise.ai/threats/technologies/tensorflow), [tensorflow (PyPI)](https://junglewise.ai/threats/technologies/pypi-tensorflow), [tensorflow-cpu (PyPI)](https://junglewise.ai/threats/technologies/tensorflow-cpu), [tensorflow-gpu (PyPI)](https://junglewise.ai/threats/technologies/tensorflow-gpu). Vendors: [Google](https://junglewise.ai/threats/vendors/google), [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2021-37691 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2021-37691 being exploited in the wild.

**How severe is CVE-2021-37691?** Low severity, with a CVSS score of 3.1, published 12 August 2021.

**Which products and versions are affected?** Google TensorFlow < 2.3.4, 2.4.0-2.4.2, 2.5.0; tensorflow (PyPI) GIT:introduced=0,fixed=0575b640091680cfb70f4dd93e70658de43b94f9|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-cpu (PyPI) GIT:introduced=0,fixed=0575b640091680cfb70f4dd93e70658de43b94f9|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-gpu (PyPI) GIT:introduced=0,fixed=0575b640091680cfb70f4dd93e70658de43b94f9|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3.

**Is there a fix for CVE-2021-37691?** Yes. tensorflow (PyPI): upgrade to 2.4.3 or later; tensorflow-cpu (PyPI): upgrade to 2.4.3 or later; tensorflow-gpu (PyPI): upgrade to 2.4.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2021-37691 attacked?** It is attacked with local access.

**Am I affected by CVE-2021-37691?** Check whether you run Google TensorFlow, tensorflow (PyPI), tensorflow-cpu (PyPI) or one of the others listed at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- tensorflow (PyPI): upgrade to 2.4.3 or later

  ```sh
  pip install "tensorflow>=2.4.3"
  ```

- tensorflow-cpu (PyPI): upgrade to 2.4.3 or later

  ```sh
  pip install "tensorflow-cpu>=2.4.3"
  ```

- tensorflow-gpu (PyPI): upgrade to 2.4.3 or later

  ```sh
  pip install "tensorflow-gpu>=2.4.3"
  ```


## Technical details

The vulnerability is a division-by-zero error (CWE-369) in the LSH operation within TFLite. The vulnerable code divides by the first dimension of the input tensor without checking that it is non-zero: `int input_item_bytes = input->bytes / SizeOfDimension(input, 0)`. An attacker can craft a malicious TFLite model with a zero-sized first dimension to trigger this crash. The attack requires only the ability to provide a model file to the application; no special privileges or user interaction are needed once the model is loaded. This results in a denial-of-service condition. Patches are available in TensorFlow 2.3.4, 2.4.3, 2.5.1, and 2.6.0.

## Affected products

- Google TensorFlow < 2.3.4, 2.4.0-2.4.2, 2.5.0
- Google TensorFlow CPU < 2.3.4, 2.4.0-2.4.2, 2.5.0
- Google TensorFlow GPU < 2.3.4, 2.4.0-2.4.2, 2.5.0

## Identifiers

- CVE-2021-37691
- GHSA-27qf-jwm8-g7f3
- PYSEC-2021-313
- PYSEC-2021-604
- PYSEC-2021-802

## Timeline

- 2021-08-11: disclosed: Advisory published
- 2021-08: patched: Patches released in TensorFlow 2.3.4, 2.4.3, 2.5.1, and 2.6.0

## References

- [https://github.com/tensorflow/tensorflow/security/advisories/GHSA-27qf-jwm8-g7f3](https://github.com/tensorflow/tensorflow/security/advisories/GHSA-27qf-jwm8-g7f3)

## Related threats

- [PYSEC-2026-3331 - TensorFlow has segfault in array_ops.upper_bound](https://junglewise.ai/threats/cve-2023-33976-tensorflow-has-segfault-in-array-ops-upper-bound)
- [PYSEC-2026-3182 - TensorFlow Denial of Service vulnerability](https://junglewise.ai/threats/cve-2023-25661-tensorflow-denial-of-service-vulnerability)
- [PYSEC-2026-3300 - TensorFlow vulnerable to Out-of-Bounds Read in DynamicStitch](https://junglewise.ai/threats/cve-2023-25659-tensorflow-vulnerable-to-out-of-bounds-read-in-dynamicstitch)
- [PYSEC-2026-3362 - TensorFlow vulnerable to seg fault in `tf.raw_ops.Print`](https://junglewise.ai/threats/cve-2023-25660-tensorflow-vulnerable-to-seg-fault-in-tf-raw-ops-print)
- [PYSEC-2026-3293 - TensorFlow vulnerable to integer overflow in EditDistance](https://junglewise.ai/threats/cve-2023-25662-tensorflow-vulnerable-to-integer-overflow-in-editdistance)
