CVE-2021-29578: TensorFlow-GPU Heap Buffer Overflow in FractionalAvgPoolGrad
Summary
CVE-2021-29578: 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.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
< 12c727cee857fa19be717f336943d95fca4ffe4f
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-29578 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-GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. The tf.raw_ops.FractionalAvgPoolGrad function is responsible for computing the gradients of the fractional average pooling operation. This function is vulnerable to a heap buffer overflow, which can be exploited by providing insufficient elements in the pooling sequence arguments. This vulnerability affects multiple versions of TensorFlow-GPU, including 2.1.4, 2.2.3, 2.3.3, and 2.4.2.
Vulnerability Detail
The vulnerability arises from the lack of validation in the tf.raw_ops.FractionalAvgPoolGrad implementation. When the out_backprop tensor shape does not have enough elements as required by the pooling sequence arguments, a heap buffer overflow occurs. An attacker can potentially exploit this vulnerability to execute arbitrary code or cause a denial of service. The issue has been identified and fixed in TensorFlow 2.5.0, and the fix has been backported to TensorFlow 2.4.2, 2.3.3, 2.2.3, and 2.1.4.
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.2.32.2.3pip install --upgrade "tensorflow-gpu==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow-gpu==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow-gpu==2.4.2"
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 avoid using the tf.raw_ops.FractionalAvgPoolGrad function or ensure that the out_backprop tensor shape has enough elements to satisfy the pooling sequence arguments. This can be achieved by carefully validating the input tensors and adjusting their shapes if necessary. Here is an example of how to validate the tensor shape in Python:
import tensorflow as tf
out_backprop = ... # The `out_backprop` tensor
pooling_sequence = ... # The pooling sequence arguments
if out_backprop.shape[0] < pooling_sequence[0]:
raise ValueError('Invalid tensor shape: `out_backprop` does not have enough elements')
Conclusion
The vulnerability in TensorFlow-GPU's tf.raw_ops.FractionalAvgPoolGrad function can lead to a heap buffer overflow, potentially enabling arbitrary code execution or denial of service. Users are advised to upgrade to TensorFlow 2.5.0 or apply the provided patches for the affected versions. Implementing proper input validation and following security best practices can help prevent exploitation of this vulnerability. For further assistance or support in 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 ecosystem of tools and resources for developing and deploying machine learning models.
TensorFlow-GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is specifically designed to utilize the computational power of GPUs for training and inference of machine learning models.
tf.raw_ops.FractionalAvgPoolGrad is a TensorFlow operation that computes the gradients of the fractional average pooling operation. It is used in various machine learning models that involve fractional average pooling.
This vulnerability can be exploited by providing insufficient elements in the pooling sequence arguments of the tf.raw_ops.FractionalAvgPoolGrad function. By doing so, an attacker can trigger a heap buffer overflow, potentially leading to arbitrary code execution or denial of service.
To protect your TensorFlow-GPU installation, it is recommended to upgrade to the latest version (2.5.0) or apply the respective patches for the affected versions (2.4.2, 2.3.3, 2.2.3, and 2.1.4). Regularly checking for updates and following security best practices can help mitigate the risk of vulnerabilities.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.