CVE-2021-29558: TensorFlow Heap Buffer Overflow in tf.raw_ops.SparseSplit
Summary
CVE-2021-29558: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.
< 2.1.4
>= 2.2.0, < 2.3.0rc0
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< 8ba6fa29cd8bf9cef9b718dc31c78c73081f5b31
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-cpu · PyPI
The same CVE-2021-29558 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 building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. The package 'tensorflow-gpu' is a PyPI package that provides GPU support for TensorFlow, enabling faster computation on compatible hardware.
Vulnerability Detail
A heap buffer overflow vulnerability exists in the 'tf.raw_ops.SparseSplit' function of TensorFlow. This vulnerability arises due to the implementation accessing an array element based on a user-controlled offset. An attacker can exploit this vulnerability by providing a malicious input that triggers the overflow, potentially leading to arbitrary code execution or a denial of service condition. The vulnerability has been assigned the identifier CVE-2021-29558 and has been reported as GHSA-mqh2-9wrp-vx84.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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.1.42.1.4pip install --upgrade "tensorflow-gpu==2.1.4" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-gpu==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-gpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-gpu==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 temporary workaround, users can consider implementing input validation and sanitization mechanisms to ensure that user-controlled offsets are within the expected range. By validating and sanitizing inputs, the risk of triggering the heap buffer overflow can be reduced. However, applying this workaround does not eliminate the vulnerability entirely, and it is still crucial to update to the patched versions of TensorFlow as soon as possible.
Conclusion
In conclusion, the TensorFlow package 'tensorflow-gpu' is affected by a heap buffer overflow vulnerability in the 'tf.raw_ops.SparseSplit' function. This vulnerability can be exploited by an attacker to execute arbitrary code or cause a denial of service condition. It is highly recommended to update to the latest available versions of TensorFlow to mitigate this vulnerability. Implementing input validation and sanitization mechanisms can serve as a temporary workaround, but it is crucial to apply the official patches as soon as possible. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for building and deploying machine learning models.
This vulnerability can be exploited by an attacker to cause a heap buffer overflow, potentially leading to arbitrary code execution or a denial of service condition.
The vulnerability affects TensorFlow versions 2.1.4 and above, including TensorFlow 2.2.0, 2.3.0, and 2.4.0. The vulnerability has been fixed in TensorFlow 2.5.0, 2.4.2, 2.3.3, 2.2.3, and 2.1.4.
To fix this vulnerability, it is recommended to update to the latest available version of TensorFlow. Users can update their TensorFlow installation using the package manager or by following the official upgrade instructions provided by the TensorFlow project.
As a temporary workaround, users can implement input validation and sanitization mechanisms to reduce the risk of triggering the heap buffer overflow. However, applying this workaround does not eliminate the vulnerability entirely, and it is still crucial to update to the patched versions of TensorFlow.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.