CVE-2021-37644: TensorFlow - `std::abort` raised from `TensorListReserve`
Summary
CVE-2021-37644: std::abort raised from TensorListReserve. 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
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-37644 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 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 allows users to define and execute computational graphs, making it suitable for a wide range of applications in artificial intelligence and deep learning. However, a vulnerability has been discovered in TensorFlow that affects the TensorListReserve function.
Vulnerability Detail
The vulnerability (CVE-2021-37644) in TensorFlow arises when a negative value is provided as the num_elements argument to the TensorListReserve function. This triggers a process abort due to reallocating a std::vector with a negative number of elements. The issue occurs because the implementation of TensorListReserve does not validate the user input before resizing the vector. As a result, an attacker could exploit this vulnerability to cause a denial-of-service (DoS) attack by intentionally providing a negative value, leading to the termination of the TensorFlow process.
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.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3" -
>= 2.5.0, < 2.5.12.5.1pip 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 value of num_elements before calling the TensorListReserve function. By ensuring that the value is not negative, the vulnerability can be mitigated. Here is an example of how to perform the validation in Python:
import tensorflow as tf
def reserve_tensor_list(num_elements):
if num_elements < 0:
raise ValueError('num_elements must be a non-negative value')
tf.raw_ops.TensorListReserve(
element_shape=tf.constant([1]),
num_elements=tf.constant([num_elements]),
element_dtype=tf.int32)
Conclusion
The vulnerability (CVE-2021-37644) in TensorFlow's TensorListReserve function can be mitigated by updating to the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4. Additionally, users can validate the input value of num_elements to prevent the vulnerability from being exploited. Regularly updating TensorFlow and following best practices for secure coding can help protect against potential attacks. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
The vulnerability allows an attacker to trigger a process abort in TensorFlow by providing a negative value as the num_elements argument to TensorListReserve. This can lead to a denial-of-service (DoS) attack, causing the TensorFlow process to terminate.
To protect your TensorFlow installation, it is recommended to update to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4. Regularly updating TensorFlow ensures that the latest security fixes are applied.
Yes, a workaround is to validate the input value of num_elements before calling the TensorListReserve function. By ensuring that the value is not negative, the vulnerability can be mitigated.
No, this vulnerability requires the attacker to have the ability to execute code on the targeted TensorFlow installation. It cannot be exploited remotely without prior access.
There is no evidence of this vulnerability being actively exploited in the wild. However, it is still important to apply the necessary patches and updates to protect against potential attacks.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.