CVE-2021-41224: TensorFlow Heap Out-of-Bounds Access
Summary
CVE-2021-41224: TensorFlow is an open source platform for machine learning. Affects tensorflow across 5 version ranges.
< 2.4.4
>= 2.5.0, < 2.5.2
>= 2.6.0, < 2.6.1
>= 2.7.0rc0, < 2.7.0
< 67bfd9feeecfb3c61d80f0e46d89c170fbee682b
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-41224 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 platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow supports various operations and algorithms for efficient computation on both CPUs and GPUs. However, a vulnerability has been identified in TensorFlow that can lead to a heap out-of-bounds access.
Vulnerability Detail
The vulnerability exists in the implementation of the SparseFillEmptyRows function in TensorFlow. When the size of the indices parameter does not match the size of the values parameter, a heap out-of-bounds access can occur. This can be exploited by an attacker to read or modify memory beyond the allocated boundaries, potentially leading to information disclosure or arbitrary code execution. The vulnerability affects multiple versions of TensorFlow, including 2.4.4, 2.5.2, 2.6.1, and 2.7.0rc0.
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.4.42.4.4pip install --upgrade "tensorflow==2.4.4" -
>= 2.5.0, < 2.5.22.5.2pip install --upgrade "tensorflow==2.5.2" -
>= 2.6.0, < 2.6.12.6.1pip install --upgrade "tensorflow==2.6.1" -
>= 2.7.0rc0, < 2.7.02.7.0pip install --upgrade "tensorflow==2.7.0"
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 ensure that the size of the indices parameter matches the size of the values parameter when calling the SparseFillEmptyRows function. This can be done by validating the input data and resizing the arrays if necessary. Here is an example of how to perform this validation and resizing in Python:
import tensorflow as tf
# Validate and resize indices and values
if len(indices) != len(values):
indices = indices[:len(values)]
# Call SparseFillEmptyRows with validated data
result = tf.sparse.SparseFillEmptyRows(indices, values)
Conclusion
In conclusion, the identified vulnerability in TensorFlow can lead to a heap out-of-bounds access, potentially resulting in information disclosure or arbitrary code execution. Users are advised to update their TensorFlow installation to the latest version or apply the provided workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source platform for machine learning that provides tools and libraries for developing and deploying machine learning models.
SparseFillEmptyRows is a function in TensorFlow that fills empty rows in a sparse tensor with provided values.
The vulnerability occurs when the size of the indices parameter does not match the size of the values parameter in the SparseFillEmptyRows function.
The vulnerability can lead to a heap out-of-bounds access, which may result in information disclosure or arbitrary code execution.
The vulnerability affects TensorFlow versions 2.4.4, 2.5.2, 2.6.1, and 2.7.0rc0.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.