CVE-2021-29536: TensorFlow GPU - Heap Buffer Overflow in QuantizedReshape

tensorflow-gpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29536: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.

>= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < a324ac84e573fba362a5e53d4e74d5de6729933e

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-29536 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow GPU is a variant of TensorFlow that leverages GPU hardware for accelerated computation. It is widely used in various industries for training and inference of machine learning models.

Vulnerability Detail

The vulnerability identified as CVE-2021-29536 affects the QuantizedReshape function in TensorFlow GPU. An attacker can exploit this vulnerability by passing invalid thresholds for the quantization process. The implementation assumes that the provided arguments are valid scalars and directly accesses their numeric values. However, if any of these tensors is empty, accessing the element at position 0 results in a heap buffer overflow. This can lead to arbitrary code execution or a denial-of-service condition. The vulnerability has been assigned a CVSS score of X.X, indicating its severity.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-gpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-gpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-gpu==2.4.3"

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 empty tensors as arguments to the QuantizedReshape function. It is recommended to validate the input tensors before invoking the function to prevent the heap buffer overflow. Here is an example of how to perform the validation in Python:

import tensorflow as tf

def safe_quantized_reshape(input_tensor, shape_tensor):
    if input_tensor.size == 0 or shape_tensor.size == 0:
        raise ValueError('Input tensors must not be empty.')
    return tf.quantization.quantized_reshape(input_tensor, shape_tensor)

Conclusion

The vulnerability identified as CVE-2021-29536 in TensorFlow GPU's QuantizedReshape function can be exploited by passing invalid thresholds for quantization, leading to a heap buffer overflow. This can result in arbitrary code execution or a denial-of-service condition. Users are strongly advised to update their TensorFlow GPU installations to the fixed versions mentioned above. Additionally, implementing the recommended workaround of validating input tensors can provide temporary protection against this vulnerability. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow GPU is a variant of TensorFlow that leverages GPU hardware for accelerated computation. It is specifically designed to take advantage of the parallel processing capabilities of GPUs, enabling faster training and inference of machine learning models.

The vulnerability in QuantizedReshape arises from the assumption that the provided quantization thresholds are always valid scalars. If any of the tensors passed as arguments is empty, attempting to access the element at position 0 results in a heap buffer overflow.

Exploiting this vulnerability can lead to arbitrary code execution or a denial-of-service condition. An attacker could craft malicious inputs to trigger the heap buffer overflow and gain control over the affected TensorFlow GPU instance or disrupt its normal operation.

To protect your TensorFlow GPU installation, it is crucial to update to one of the fixed versions: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4. These versions include the necessary fixes to prevent the heap buffer overflow vulnerability.

Yes, a temporary workaround is to validate the input tensors before invoking the QuantizedReshape function. By ensuring that the tensors are not empty, you can prevent the heap buffer overflow. Refer to the 'workaround' section for an example of how to perform the validation in Python.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-gpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-gpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-gpu==2.4.3"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback