CVE-2021-37641: TensorFlow CPU - Out-of-bounds Read in RaggedGather
Summary
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
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
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.
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.
No signup required · Results in about 60 seconds
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.42.3.4pip install --upgrade "tensorflow-cpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip 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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.