CVE-2021-37636: Floating point exception in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
Moderate
5.5

CVE-2021-37636: Floating point exception in SparseDenseCwiseDiv. 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-37636 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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

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

TensorFlow is an open-source machine learning framework that provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. It is widely used in various domains, including research, industry, and academia. TensorFlow allows users to build and train neural networks, perform numerical computations, and process large datasets efficiently. However, a vulnerability has been identified in TensorFlow that can lead to a floating point exception.

Vulnerability Detail

The vulnerability, identified as CVE-2021-37636, exists in the implementation of tf.raw_ops.SparseDenseCwiseDiv in TensorFlow. This function is used for element-wise division between a sparse tensor and a dense tensor. The implementation fails to handle the division by zero case, resulting in a floating point exception. An attacker could exploit this vulnerability by providing malicious input data, leading to a division by zero error and potentially causing the application to crash or behave unexpectedly. The impact of this vulnerability is considered moderate, with a CVSS score of 5.5.

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 validate the input data before invoking the tf.raw_ops.SparseDenseCwiseDiv function to ensure that no division by zero occurs. This can be done by checking the values of the input tensors and ensuring that the divisor is not zero. Here is an example of how to perform the validation in Python:

import tensorflow as tf
import numpy as np

sp_indices = np.array([[4]])
sp_values = np.array([-400])
sp_shape = np.array([647.])
dense = np.array([0])

if np.any(dense == 0):
    raise ValueError('Division by zero is not allowed.')

# Proceed with the division operation
result = tf.raw_ops.SparseDenseCwiseDiv(sp_indices, sp_values, sp_shape, dense)

By performing this validation, the risk of encountering a division by zero error can be mitigated.

Conclusion

In conclusion, the vulnerability identified as CVE-2021-37636 in TensorFlow can lead to a floating point exception when performing element-wise division between a sparse tensor and a dense tensor. The TensorFlow team has released patches to address this vulnerability, and users are advised to update their installations to the latest patched version. A workaround is also available by validating the input data to prevent division by zero. 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 that provides tools and resources for developing and deploying machine learning models.

The impact of this vulnerability is considered moderate, with a CVSS score of 5.5. It can potentially lead to application crashes or unexpected behavior.

To fix this vulnerability, it is recommended to update TensorFlow to the latest patched version (2.6.0 or later). The fix has also been backported to earlier versions (2.5.1, 2.4.3, and 2.3.4).

Yes, a workaround is available. Users can validate the input data before invoking the vulnerable function to ensure that no division by zero occurs.

For more information, please refer to the TensorFlow security guide and the GitHub advisory for this vulnerability.

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