CVE-2021-41224: TensorFlow SparseFillEmptyRows Heap Out-of-Bounds Access
Summary
CVE-2021-41224: TensorFlow is an open source platform for machine learning. Affects tensorflow-cpu 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 · PyPI
- tensorflow · 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 allows users to build and train neural networks, perform data preprocessing, and evaluate model performance. It is widely used in various industries for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that can lead to a heap out-of-bounds access when using the SparseFillEmptyRows function.
Vulnerability Detail
The vulnerability in TensorFlow's SparseFillEmptyRows function occurs when the size of the indices parameter does not match the size of the values parameter. This can trigger a heap out-of-bounds access, potentially leading to memory corruption or crashes. An attacker could potentially exploit this vulnerability to execute arbitrary code or cause denial-of-service attacks. The issue has been identified and fixed in TensorFlow versions 2.7.0, 2.6.1, 2.5.2, and 2.4.4.
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.4.42.4.4pip install --upgrade "tensorflow-cpu==2.4.4" -
>= 2.5.0, < 2.5.22.5.2pip install --upgrade "tensorflow-cpu==2.5.2" -
>= 2.6.0, < 2.6.12.6.1pip install --upgrade "tensorflow-cpu==2.6.1" -
>= 2.7.0rc0, < 2.7.02.7.0pip install --upgrade "tensorflow-cpu==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
If updating TensorFlow is not immediately feasible, a possible workaround is to ensure that the indices and values parameters have matching sizes before 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 workaround in Python:
import numpy as np
# Validate and resize indices and values
if len(indices) != len(values):
max_size = max(len(indices), len(values))
indices = np.resize(indices, max_size)
values = np.resize(values, max_size)
# Call SparseFillEmptyRows with the updated indices and values
SparseFillEmptyRows(indices, values)
Conclusion
The vulnerability in TensorFlow's SparseFillEmptyRows function can lead to a heap out-of-bounds access, potentially resulting in memory corruption or crashes. It is crucial to update TensorFlow to the latest patched version or apply the workaround to mitigate the risk. For further assistance and support in 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 tools and resources for developing and deploying neural networks.
SparseFillEmptyRows is a function in TensorFlow that fills empty rows in a sparse tensor with provided indices and values.
A heap out-of-bounds access occurs when a program tries to access memory outside of the allocated heap space, potentially leading to memory corruption or crashes.
This vulnerability could allow an attacker to execute arbitrary code or cause denial-of-service attacks by triggering a heap out-of-bounds access.
To fix this vulnerability, update TensorFlow to the latest patched version (2.7.0, 2.6.1, 2.5.2, or 2.4.4) or apply the provided workaround.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.