CVE-2021-41211: TensorFlow GPU - Out-of-Bounds Read in QuantizeV2 Shape Inference
Summary
CVE-2021-41211: TensorFlow is an open source platform for machine learning. Affects tensorflow-gpu across 3 version ranges.
>= 2.6.0, < 2.6.1
>= 2.7.0rc0, < 2.7.0
< a0d64445116c43cf46a5666bd4eee28e7a82f244
Fixed in 2.6.1 or 2.7.0, depending 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-41211 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 specific package that enables GPU acceleration for TensorFlow. It allows users to leverage the power of GPUs to accelerate their machine learning workflows.
Vulnerability Detail
The vulnerability (CVE-2021-41211) exists in the shape inference code for the QuantizeV2 function in TensorFlow GPU. When the axis parameter is a negative value less than -1, the code triggers a read outside the bounds of a heap-allocated array. This results in accessing data before the start of the heap buffer, leading to a heap out-of-bounds read. The issue arises due to the code assuming that axis is a valid index into the dimensions of the input tensor, without proper validation. The vulnerability can be exploited by an attacker to read sensitive information from the heap, potentially leading to information disclosure or further exploitation.
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.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 passing a negative value less than -1 for the axis parameter in the QuantizeV2 function. By ensuring that axis is a non-negative value or within the valid range of dimensions, the vulnerability can be mitigated. Here's an example of a valid usage:
import tensorflow as tf
input_tensor = tf.constant([1, 2, 3, 4, 5])
axis = 0
quantized_tensor = tf.quantization.quantize_v2(input_tensor, axis)
Conclusion
In conclusion, the vulnerability (CVE-2021-41211) in TensorFlow GPU's shape inference code for QuantizeV2 can lead to a heap out-of-bounds read. Users are advised to update their TensorFlow GPU installations to versions 2.6.1 or 2.7.0 once the fixes are released. A temporary workaround is available by avoiding negative values less than -1 for the axis parameter. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
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 specific package that enables GPU acceleration for TensorFlow. It allows users to leverage the power of GPUs to accelerate their machine learning workflows.
The vulnerability allows an attacker to trigger a heap out-of-bounds read in TensorFlow GPU, potentially leading to information disclosure or further exploitation.
The vulnerability will be fixed in TensorFlow 2.7.0 and backported to TensorFlow 2.6.1. Users should update their TensorFlow GPU installations to either of these versions once the fixes are released.
Yes, as a temporary workaround, users can avoid passing a negative value less than -1 for the axis parameter in the QuantizeV2 function.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.