CVE-2021-29578: TensorFlow-GPU Heap Buffer Overflow in FractionalAvgPoolGrad

tensorflow-gpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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.4 2.1.4
    pip install --upgrade "tensorflow-gpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-gpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-gpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

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.4 2.1.4
    pip install --upgrade "tensorflow-gpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-gpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-gpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback