CVE-2021-37641: TensorFlow CPU - Out-of-bounds Read in RaggedGather

tensorflow-cpu Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Unrated
Not published

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

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

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-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 Penetration testing for web, API and mobile 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 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 allows users to build and train neural networks, perform data preprocessing and augmentation, and deploy models in various environments. The TensorFlow CPU package, available on PyPI, is a CPU-only version of TensorFlow that can be used on systems without GPU support.

Vulnerability Detail

The vulnerability identified as CVE-2021-37641 affects the TensorFlow CPU package. It arises from a flaw in the implementation of the tf.raw_ops.RaggedGather function. When the arguments provided to this function do not determine a valid ragged tensor, it can trigger a read from outside the bounds of heap allocated buffers. The implementation fails to check that the tensor has a rank of at least 1 (i.e., it is not a scalar) before reading the first dimension of its shape. Additionally, the implementation does not verify that the list of tensors given by params_nested_splits is not empty. This vulnerability can potentially lead to information disclosure or a crash of the TensorFlow application.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==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.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-cpu==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.RaggedGather function with arguments that may result in an invalid ragged tensor. It is recommended to carefully validate the inputs and ensure that the tensor has a rank of at least 1 and the list of tensors provided is not empty. Here is an example of how to perform the necessary checks:

import tensorflow as tf

def safe_ragged_gather(params, indices, params_nested_splits):
    if tf.rank(params) < 1:
        raise ValueError('Invalid params tensor: rank must be at least 1')
    if not params_nested_splits:
        raise ValueError('Invalid params_nested_splits: list must not be empty')
    return tf.raw_ops.RaggedGather(params=params, indices=indices, params_nested_splits=params_nested_splits)

Conclusion

In conclusion, the TensorFlow CPU package is affected by a vulnerability (CVE-2021-37641) that can result in an out-of-bounds read when using the tf.raw_ops.RaggedGather function with certain inputs. This vulnerability has been addressed in TensorFlow 2.6.0 and will also be patched in earlier versions. Users are advised to update to the patched versions or apply the provided workaround to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and libraries for developing and deploying machine learning models.

The TensorFlow CPU package is a version of TensorFlow that is optimized for running on systems without GPU support. It allows users to utilize TensorFlow's capabilities on CPU-only machines.

This vulnerability can potentially lead to information disclosure or a crash of the TensorFlow application. An attacker may be able to exploit the out-of-bounds read to access sensitive data or cause the application to behave unexpectedly.

To fix this vulnerability, it is recommended to update the TensorFlow CPU package to version 2.6.0 or later. Alternatively, you can apply the provided workaround to avoid using the vulnerable function with problematic inputs.

The recommended mitigation is to update to the patched versions of TensorFlow CPU. Applying the provided workaround can also help mitigate the risk of exploitation.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

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