CVE-2021-37654: TensorFlow GPU - Out-of-Bounds Read Vulnerability

tensorflow-gpu Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Unrated
Not published

CVE-2021-37654: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 3 version ranges.

>= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < bc9c546ce7015c57c2f15c168b3d9201de679a1d

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

Also tracked for

The same CVE-2021-37654 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 end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is widely used in various industries and research domains for training and inference of deep learning models.

Vulnerability Detail

The vulnerability (CVE-2021-37654) in TensorFlow GPU allows an attacker to trigger a crash or read data from outside the bounds of heap allocated data. The issue arises from a lack of validation in the tf.raw_ops.ResourceGather API, specifically in the batch_dims parameter. By supplying a batch_dims value greater than or equal to the rank of the input tensor, an attacker can cause the program to read data beyond the allocated buffer, leading to potential information disclosure or a crash. This vulnerability affects debug builds of TensorFlow GPU and release builds with the tf.raw_ops.ResourceGather API.

How To Fix

Latest published version: 2.12.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-gpu==2.12.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.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-gpu==2.4.3"

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 avoid using the tf.raw_ops.ResourceGather API with a batch_dims value greater than or equal to the rank of the input tensor. It is recommended to review the codebase and ensure that the batch_dims parameter is properly validated before invoking the API. Here is an example of how to validate the batch_dims parameter:

import tensorflow as tf

def resource_gather_with_validation(tensor, indices, batch_dims):
    if batch_dims >= tf.rank(tensor):
        raise ValueError('Invalid batch_dims value')
    return tf.raw_ops.ResourceGather(tensor=tensor, indices=indices, batch_dims=batch_dims)

By implementing this validation check, the vulnerability can be mitigated.

Conclusion

The vulnerability (CVE-2021-37654) in TensorFlow GPU exposes a potential risk of crashing the program or reading data from outside the bounds of heap allocated data. The TensorFlow development team has addressed this issue and will release patched versions to mitigate the vulnerability. Users are advised to update their TensorFlow GPU installations to the patched versions once they are available. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow GPU is a variant of TensorFlow that utilizes GPU acceleration for faster computation of machine learning models. It is commonly used in scenarios where large-scale deep learning models require significant computational power.

This vulnerability allows an attacker to trigger a crash or read data from outside the bounds of heap allocated data. Depending on the specific scenario, this could lead to potential information disclosure or denial of service.

The vulnerability affects TensorFlow GPU versions 2.3.0 and above. Specifically, TensorFlow GPU versions 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and 2.5.1 are affected. The upcoming TensorFlow GPU version 2.6.0 will include the fix for this vulnerability.

To fix this vulnerability, it is recommended to update your TensorFlow GPU installation to the patched versions once they are released. The fix will be included in TensorFlow GPU versions 2.6.0, 2.5.1, 2.4.3, and 2.3.4.

Yes, as a workaround, users can avoid using the tf.raw_ops.ResourceGather API with a batch_dims value greater than or equal to the rank of the input tensor. It is also recommended to validate the batch_dims parameter before invoking the API to mitigate the vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

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.12.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-gpu==2.12.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.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-gpu==2.4.3"

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