CVE-2021-29580: Undefined behavior and CHECK-fail in FractionalMaxPoolGrad
Summary
CVE-2021-29580: Undefined behavior and CHECK-fail in FractionalMaxPoolGrad. Affects tensorflow across 4 version ranges.
< 2.1.4
>= 2.2.0, < 2.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29580 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
The TensorFlow package is an open-source machine learning framework developed by Google. It provides a comprehensive set of tools and libraries for building and deploying machine learning models. TensorFlow includes various operations and functions for data manipulation, model training, and inference. One of these operations is tf.raw_ops.FractionalMaxPoolGrad, which is used for fractional max pooling in neural networks. Fractional max pooling is a technique that allows for non-integer pooling sizes, providing more flexibility in pooling operations. However, a vulnerability has been discovered in the implementation of FractionalMaxPoolGrad that can lead to undefined behavior and denial of service attacks.
Vulnerability Detail
The vulnerability in tf.raw_ops.FractionalMaxPoolGrad arises from the lack of validation for empty input and output tensors. If one of the input tensors is empty, the implementation triggers undefined behavior. This can result in unexpected program behavior and potential security risks. Additionally, a CHECK condition in the code becomes false when the input and output tensors are empty, leading to a process abort and denial of service. The vulnerability has a CVSS score of 2.5, indicating a low severity level. It affects versions of TensorFlow up to 2.4.2.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==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==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow==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, users can ensure that the input and output tensors provided to tf.raw_ops.FractionalMaxPoolGrad are not empty and have the same rank. This can be achieved by validating the tensors before passing them to the function. Here is an example of how to perform the validation:
import tensorflow as tf
orig_input = tf.constant([2, 3], shape=[1, 1, 1, 2], dtype=tf.int64)
orig_output = tf.constant([], dtype=tf.int64)
out_backprop = tf.zeros([2, 3, 6, 6], dtype=tf.int64)
row_pooling_sequence = tf.constant([0], shape=[1], dtype=tf.int64)
col_pooling_sequence = tf.constant([0], shape=[1], dtype=tf.int64)
if orig_input.size > 0 and orig_output.size > 0 and orig_input.ndim == orig_output.ndim:
tf.raw_ops.FractionalMaxPoolGrad(
orig_input=orig_input, orig_output=orig_output, out_backprop=out_backprop,
row_pooling_sequence=row_pooling_sequence,
col_pooling_sequence=col_pooling_sequence, overlapping=False)
else:
print('Invalid input or output tensors')
By performing this validation, the undefined behavior and denial of service issues can be avoided.
Conclusion
The vulnerability in tf.raw_ops.FractionalMaxPoolGrad can lead to undefined behavior and denial of service attacks. It has been patched in TensorFlow 2.5.0, and users are advised to update their installations. Backported fixes are also available for TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4. For further support and information on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides tools and libraries for building and deploying machine learning models.
tf.raw_ops.FractionalMaxPoolGrad is an operation in TensorFlow that performs fractional max pooling in neural networks. It allows for non-integer pooling sizes, providing more flexibility in pooling operations.
The vulnerability can lead to undefined behavior and denial of service attacks. It can result in unexpected program behavior and potential security risks.
The vulnerability has been patched in TensorFlow 2.5.0. Users should update their TensorFlow installations to the latest version to mitigate the risk.
Yes, users can validate the input and output tensors before passing them to tf.raw_ops.FractionalMaxPoolGrad to avoid the vulnerability. The provided code example demonstrates how to perform the validation.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.