CVE-2021-29574: TensorFlow - Null Pointer Dereference in MaxPool3DGradGrad
Summary
CVE-2021-29574: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow 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
< a3d9f9be9ac2296615644061b40cefcee341dcc4
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-29574 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 and functions for performing mathematical computations and data manipulation. One of these operations is tf.raw_ops.MaxPool3DGradGrad, which is responsible for computing the gradient of the gradient of a 3D max pooling operation. This operation is used in many machine learning models and applications.
Vulnerability Detail
The implementation of tf.raw_ops.MaxPool3DGradGrad in TensorFlow exhibits a null pointer dereference vulnerability. The vulnerability arises when the operation is supplied with empty tensors as inputs. The implementation fails to validate the emptiness of the input tensors, resulting in a null pointer dereference when accessing the elements of the tensors. An attacker can exploit this vulnerability by providing empty tensors as inputs to the MaxPool3DGradGrad operation, leading to undefined behavior and potential crashes or arbitrary code execution. This vulnerability 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 tensors provided to the MaxPool3DGradGrad operation are not empty. This can be done by validating the shape and size of the tensors before passing them to the operation. Here is an example of how to check if a tensor is empty in TensorFlow:
import tensorflow as tf
def is_tensor_empty(tensor):
return tf.reduce_all(tf.equal(tf.shape(tensor), tf.constant([0])))
Conclusion
In conclusion, the MaxPool3DGradGrad operation in TensorFlow is vulnerable to a null pointer dereference when supplied with empty tensors as inputs. This vulnerability has been addressed in TensorFlow 2.5.0 and patches have been provided for earlier affected versions. Users are advised to upgrade or apply the patches to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
This vulnerability allows an attacker to trigger a null pointer dereference in TensorFlow, potentially leading to crashes or arbitrary code execution. It can be exploited by providing empty tensors as inputs to the vulnerable MaxPool3DGradGrad operation.
No, only versions up to 2.4.2 are affected by this vulnerability. The TensorFlow team has released patches for the affected versions to address the issue.
Yes, users can validate the input tensors to ensure they are not empty before passing them to the vulnerable operation. This can help mitigate the risk of null pointer dereference.
To fix this vulnerability, it is recommended to upgrade to TensorFlow 2.5.0 or later. Alternatively, users on affected versions can apply the respective patches provided by the TensorFlow team.
You can find more information about this vulnerability in the TensorFlow advisory database: https://github.com/pypa/advisory-database/blob/main/vulns/tensorflow/PYSEC-2021-211.yaml
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.