CVE-2021-37641: Heap OOB in tensorflow

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
Moderate
7.1

CVE-2021-37641: Heap OOB in RaggedGather. 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-37641 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

TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow supports various operations and functions for manipulating tensors, including the RaggedGather function. This vulnerability affects versions of TensorFlow prior to 2.3.4, 2.4.3, and 2.5.1. The vulnerability allows an attacker to trigger a read from outside the bounds of heap allocated buffers, potentially leading to information disclosure or denial of service.

Vulnerability Detail

The vulnerability arises in the RaggedGather function of TensorFlow. If the arguments provided to this function do not determine a valid ragged tensor, an out-of-bounds read can occur. This can be exploited by an attacker to access sensitive information or crash the application. The issue is caused by a lack of proper input validation and boundary checks in the implementation of the function. The vulnerability has a CVSS score of 7.1, indicating a high severity.

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 avoid using the RaggedGather function or ensure that the arguments provided always result in a valid ragged tensor. This can be achieved by validating the input data and ensuring that the indices used for gathering are within the bounds of the tensors. Here is an example of how to validate the input and avoid triggering the vulnerability:

import tensorflow as tf

params_nested_splits = [0, 0, 0]
params_dense_values = [1, 1]
indices = [0, 0, 9, 0, 0]

if all(split >= 0 for split in params_nested_splits) and all(index < len(params_dense_values) for index in indices):
    tf.raw_ops.RaggedGather(
        params_nested_splits=params_nested_splits,
        params_dense_values=params_dense_values,
        indices=indices,
        OUTPUT_RAGGED_RANK=0
    )
else:
    print('Invalid input for RaggedGather')

By performing these checks, the vulnerability can be mitigated.

Conclusion

The vulnerability in TensorFlow's RaggedGather function can be mitigated by updating to the patched versions of TensorFlow. Users should ensure that their TensorFlow installation is up to date to prevent potential information disclosure or denial of service. For further support and assistance with 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 tools and resources for building and deploying machine learning models.

RaggedGather is a function in TensorFlow that allows gathering values from a ragged tensor based on specified indices.

An attacker can exploit this vulnerability by providing malicious input to the RaggedGather function, causing it to read from outside the bounds of allocated buffers.

The vulnerability can lead to information disclosure or denial of service, depending on how it is exploited.

The vulnerability can be fixed by updating TensorFlow to versions 2.3.4, 2.4.3, or 2.5.1, which include patches for the issue.

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