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

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
High
Not published

CVE-2021-29535: Heap buffer overflow in QuantizedMul. 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

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile 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 is widely used in various industries and research domains due to its flexibility and scalability. However, a vulnerability has been discovered in TensorFlow that can lead to a heap buffer overflow in the QuantizedMul operation.

Vulnerability Detail

The vulnerability arises from the assumption made in the implementation of QuantizedMul that the four threshold arguments passed to it are always valid scalars. However, if any of these tensors is empty, accessing the element at position 0 results in a heap buffer overflow. An attacker can exploit this vulnerability by providing invalid thresholds for quantization. The impact of this vulnerability can be severe, potentially leading to remote code execution or denial of service attacks.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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

As a temporary workaround, users can avoid passing empty tensors as thresholds to the QuantizedMul operation. It is important to validate the input tensors and ensure they contain valid values before invoking the operation. Here is an example of how to perform this validation in Python:

import tensorflow as tf

def safe_quantized_mul(a, b, min_a, max_a, min_b, max_b):
    if a.size == 0 or b.size == 0:
        raise ValueError('Input tensors must not be empty')
    return tf.quantization.quantized_mul(a, b, min_a, max_a, min_b, max_b)

Conclusion

The heap buffer overflow vulnerability in TensorFlow's QuantizedMul operation can have severe consequences, including remote code execution and denial of service attacks. It is crucial for users to update their TensorFlow installations to the patched versions as soon as they become available. Regularly updating TensorFlow is also recommended to stay protected against the latest security vulnerabilities. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem of tools and libraries for developing and deploying machine learning models.

QuantizedMul is an operation in TensorFlow that performs element-wise multiplication of two quantized tensors. It is commonly used in machine learning models that involve quantization.

An attacker can exploit this vulnerability by providing invalid thresholds for quantization when invoking the QuantizedMul operation. This can lead to a heap buffer overflow and potentially enable remote code execution or denial of service attacks.

This vulnerability affects TensorFlow versions 0 and above. Specifically, versions 2.1.4, 2.2.3, 2.3.3, and 2.4.2 are known to be affected. It is recommended to update to the patched versions as soon as they become available.

Yes, a temporary workaround is to ensure that the input tensors passed to the QuantizedMul operation are not empty. It is important to validate the input tensors and ensure they contain valid values before invoking the operation.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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 →

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