CVE-2021-29578: TensorFlow Heap Buffer Overflow in tf.raw_ops.FractionalAvgPoolGrad
Summary
CVE-2021-29578: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu 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-gpu · 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 building and deploying machine learning models. TensorFlow includes various operations for pooling and gradient calculations, including the tf.raw_ops.FractionalAvgPoolGrad operation. This operation is used to compute the gradients of the fractional average pooling function. However, a vulnerability has been discovered in the implementation of this operation, which can lead to a heap buffer overflow.
Vulnerability Detail
The vulnerability in tf.raw_ops.FractionalAvgPoolGrad arises from a failure to validate the pooling sequence arguments against the out_backprop tensor shape. This can result in a heap buffer overflow, potentially leading to arbitrary code execution or a denial of service condition. The issue affects versions of TensorFlow from 0 to 2.1.4, 2.2.0 to 2.2.3, 2.3.0 to 2.3.3, and 2.4.0 to 2.4.2. The TensorFlow team has addressed the vulnerability in TensorFlow 2.5.0 and has also backported the fix to versions 2.4.2, 2.3.3, 2.2.3, and 2.1.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.1.42.1.4pip install --upgrade "tensorflow-cpu==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow-cpu==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow-cpu==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow-cpu==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 workaround, if immediate update or patching is not feasible, it is recommended to avoid using the tf.raw_ops.FractionalAvgPoolGrad operation in production environments until the vulnerability is addressed. Alternatively, developers can consider implementing their own custom gradient calculation for fractional average pooling to mitigate the risk.
Conclusion
The vulnerability in tf.raw_ops.FractionalAvgPoolGrad can lead to a heap buffer overflow in TensorFlow, potentially resulting in arbitrary code execution or a denial of service condition. It is crucial to update to TensorFlow 2.5.0 or apply the relevant patches to mitigate this vulnerability. If immediate update or patching is not possible, it is recommended to avoid using the affected operation in production environments. For further support on 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 a comprehensive set of tools and resources for building and deploying machine learning models.
tf.raw_ops.FractionalAvgPoolGrad is an operation in TensorFlow used to compute the gradients of the fractional average pooling function.
A heap buffer overflow is a type of software vulnerability where a program writes data beyond the bounds of a buffer allocated in the heap, potentially overwriting adjacent memory and leading to various security issues.
The vulnerability in tf.raw_ops.FractionalAvgPoolGrad could potentially allow an attacker to execute arbitrary code or cause a denial of service condition.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock and the playground will analyze it for any open-source vulnerabilities, including this one.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.