CVE-2021-41211: Heap OOB in shape inference for `QuantizeV2` in TensorFlow
Summary
CVE-2021-41211: Heap OOB in shape inference for QuantizeV2. Affects tensorflow versions >= 2.6.0, < 2.6.1. Fixed in 2.6.1. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · 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 machine learning framework widely used for developing and deploying machine learning models. It provides a comprehensive ecosystem of tools, libraries, and resources for building and training neural networks. The QuantizeV2 function in TensorFlow is responsible for quantizing floating-point tensors to a lower precision data type. This vulnerability affects versions 2.6.0 and 2.6.1 of the TensorFlow package.
Vulnerability Detail
The shape inference code for QuantizeV2 in TensorFlow can trigger a read outside of the bounds of a heap-allocated array. This occurs when the axis parameter is a negative value less than -1. The code assumes that axis is a valid index into the dimensions of the input tensor, but if axis is less than -1, it results in a heap out-of-bounds read. An attacker could potentially exploit this vulnerability to read sensitive data from the heap or cause a denial-of-service condition.
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 version below is the minimum fixed release for this vulnerability.
If you need the minimum change
2.6.1
This is the first release that contains the fix.
pip install --upgrade "tensorflow==2.6.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a workaround, users can avoid passing a negative value less than -1 for the axis parameter when calling the QuantizeV2 function. Ensure that the axis value is within the valid range of the input tensor dimensions.
Conclusion
The vulnerability in TensorFlow's QuantizeV2 function can result in a heap out-of-bounds read, potentially leading to unauthorized access to sensitive data or a denial-of-service condition. It is crucial to update to TensorFlow 2.7.0 or 2.6.1 to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
The vulnerability can lead to a heap out-of-bounds read, potentially allowing an attacker to access sensitive data or cause a denial-of-service condition.
Versions 2.6.0 and 2.6.1 of TensorFlow are affected by this vulnerability.
Yes, the vulnerability has been patched in TensorFlow commit a0d64445116c43cf46a5666bd4eee28e7a82f244. The fix will be included in TensorFlow 2.7.0 and has also been backported to TensorFlow 2.6.1.
To protect your application, it is recommended to update your TensorFlow installation to version 2.7.0 once it is released. Alternatively, you can upgrade to TensorFlow 2.6.1, which includes the fix for this vulnerability.
Yes, as a workaround, ensure that the axis parameter passed to the QuantizeV2 function is not a negative value less than -1 and falls within the valid range of the input tensor dimensions.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.