CVE-2021-29535: TensorFlow-GPU Heap Buffer Overflow in QuantizedMul

tensorflow-gpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29535: 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 < efea03b38fb8d3b81762237dc85e579cc5fc6e87

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-29535 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an end-to-end 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 GPUs, which can significantly speed up the training process. However, TensorFlow-GPU is vulnerable to a heap buffer overflow in the QuantizedMul operation, which can be exploited by an attacker to execute arbitrary code or cause a denial of service.

Vulnerability Detail

The vulnerability in TensorFlow-GPU arises from a flaw in the implementation of the QuantizedMul operation. When invalid thresholds for quantization are passed as arguments, the implementation assumes that the arguments are valid scalars and tries to access the numeric value directly. However, if any of these tensors is empty, accessing the element at position 0 results in a heap buffer overflow. This can be exploited by an attacker to overwrite adjacent memory and potentially execute arbitrary code or crash the application. The vulnerability affects versions of TensorFlow-GPU up to 2.4.3.

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 workaround, users can avoid passing empty tensors as arguments to the QuantizedMul operation. By ensuring that the thresholds for quantization are valid and non-empty, the vulnerability can be mitigated. Here is an example of how to check for empty tensors before invoking the QuantizedMul operation:

import tensorflow as tf

def safe_quantized_mul(a, b, c, d):
    if tf.size(a) == 0 or tf.size(b) == 0 or tf.size(c) == 0 or tf.size(d) == 0:
        raise ValueError('Invalid thresholds for quantization')
    else:
        return tf.quantized_mul(a, b, c, d)

Conclusion

The heap buffer overflow vulnerability in TensorFlow-GPU's QuantizedMul operation can be mitigated by upgrading to the fixed versions or applying the backported fixes. Users should ensure that their TensorFlow-GPU installations are up to date to protect against potential exploitation. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that 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 GPUs, which can significantly speed up the training process.

The QuantizedMul operation in TensorFlow-GPU performs element-wise multiplication of quantized tensors. It is commonly used in machine learning models that involve quantization, which is the process of representing numerical values with a reduced precision to improve efficiency.

An attacker can exploit the vulnerability by passing empty tensors as arguments to the QuantizedMul operation. This triggers a heap buffer overflow, allowing the attacker to overwrite adjacent memory and potentially execute arbitrary code or crash the application.

To fix the vulnerability, users should upgrade their TensorFlow-GPU installation to version 2.5.0 or later. Alternatively, they can install the backported fixes for versions 2.4.2, 2.3.3, 2.2.3, and 2.1.4. The updated versions can be obtained from the official TensorFlow website or through the package manager.

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