CVE-2021-29537: Heap buffer overflow in tensorflow
Summary
CVE-2021-29537: Heap buffer overflow in QuantizedResizeBilinear. 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-29537 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 developed by Google. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow supports various platforms and programming languages, making it widely used in both academia and industry. However, a vulnerability has been discovered in TensorFlow that could lead to a heap buffer overflow.
Vulnerability Detail
The vulnerability, identified as CVE-2021-29537, exists in the QuantizedResizeBilinear function of TensorFlow. An attacker can exploit this vulnerability by passing in invalid thresholds for the quantization. This can be done by providing empty tensors for the images, size, min, and max parameters. The implementation of the function assumes that these parameters are always valid scalars and tries to access their numeric values directly. However, if any of these tensors is empty, accessing the element at position 0 results in a heap buffer overflow. This vulnerability has a CVSS score of 2.5, indicating a low severity level.
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
If updating TensorFlow is not immediately possible, users can mitigate the risk by ensuring that the images, size, min, and max parameters passed to the QuantizedResizeBilinear function are not empty. This can be done by validating the input tensors before invoking the function. Here is an example workaround in Python:
import tensorflow as tf
images = tf.constant([], shape=[0], dtype=tf.qint32)
size = tf.constant([], shape=[0], dtype=tf.int32)
min = tf.constant([], dtype=tf.float32)
max = tf.constant([], dtype=tf.float32)
if images.size > 0 and size.size > 0 and min.size > 0 and max.size > 0:
tf.raw_ops.QuantizedResizeBilinear(images=images, size=size, min=min, max=max, align_corners=False, half_pixel_centers=False)
else:
print('Invalid input tensors. Please provide non-empty tensors.')
Conclusion
The vulnerability in TensorFlow has been addressed by the TensorFlow team in the latest patched versions. It is recommended to update your TensorFlow installation to one of the fixed versions to mitigate the risk. If you have any further questions or need assistance with 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.
This vulnerability allows an attacker to cause a heap buffer overflow in TensorFlow, which could potentially lead to arbitrary code execution or a denial of service.
To fix this vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4.
Yes, if you are unable to immediately update TensorFlow, you can mitigate the risk by validating the input tensors before invoking the QuantizedResizeBilinear function.
You can find more information about this vulnerability in the TensorFlow security guide and the GitHub advisory database.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.