CVE-2021-41196: TensorFlow GPU - Keras Pooling Layers Segfault
Summary
CVE-2021-41196: TensorFlow is an open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.
< 2.4.4
>= 2.5.0, < 2.5.2
>= 2.6.0, < 2.6.1
>= 2.7.0rc0, < 2.7.0
< 12b1ff82b3f26ff8de17e58703231d5a02ef1b8b
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-41196 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 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 the power of GPUs for accelerated computation. It allows users to train and run machine learning models on GPU hardware, resulting in faster performance and improved efficiency. However, TensorFlow GPU is susceptible to a vulnerability in the Keras pooling layers.
Vulnerability Detail
The vulnerability in TensorFlow GPU arises from the implementation of pooling operations in the Keras pooling layers. When the size of the pool is set to 0 or when a dimension is negative, it can trigger a segmentation fault (segfault). This occurs because TensorFlow does not check the values in the sliding window to ensure they are strictly positive. As a result, an attacker could potentially exploit this vulnerability to cause a denial of service (DoS) or execute arbitrary code on a system running TensorFlow GPU. The impact of this vulnerability can range from crashing the application to potentially gaining unauthorized access to sensitive information.
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.4.42.4.4pip install --upgrade "tensorflow-gpu==2.4.4" -
>= 2.5.0, < 2.5.22.5.2pip install --upgrade "tensorflow-gpu==2.5.2" -
>= 2.6.0, < 2.6.12.6.1pip install --upgrade "tensorflow-gpu==2.6.1" -
>= 2.7.0rc0, < 2.7.02.7.0pip install --upgrade "tensorflow-gpu==2.7.0"
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 setting the pool size to 0 or using negative dimensions in the Keras pooling layers. By ensuring that the pool size is greater than 0 and all dimensions are positive, the vulnerability can be mitigated. Here is an example of how to define a valid pooling layer in TensorFlow GPU:
from tensorflow.keras.layers import MaxPooling2D
pooling_layer = MaxPooling2D(pool_size=(2, 2))
By specifying a pool size greater than 0 and positive dimensions, the vulnerability will not be triggered.
Conclusion
The vulnerability in TensorFlow GPU's Keras pooling layers can lead to a segfault when the pool size is 0 or a dimension is negative. This can potentially result in a denial of service or arbitrary code execution. Users are advised to update their TensorFlow GPU installations to the latest patched versions to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow GPU is a variant of TensorFlow that utilizes GPU hardware for accelerated machine learning computations. It provides faster performance and improved efficiency compared to running TensorFlow on CPU.
Keras pooling layers are a set of layers in TensorFlow that perform downsampling operations on input data. They are commonly used in convolutional neural networks (CNNs) to reduce the spatial dimensions of feature maps.
The vulnerability arises from the lack of strict positivity checks in the TensorFlow implementation of pooling operations. When the pool size is set to 0 or a dimension is negative, it can trigger a segfault.
The consequences of this vulnerability can range from crashing the application to potentially enabling an attacker to execute arbitrary code on a system running TensorFlow GPU. It could also lead to a denial of service (DoS) situation.
To mitigate the risk of exploitation, it is recommended to update TensorFlow GPU to one of the patched versions: TensorFlow 2.7.0, TensorFlow 2.6.1, TensorFlow 2.5.2, or TensorFlow 2.4.4. These versions include a fix for the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.