CVE-2021-29610: TensorFlow: heap R/W via quantization axis underflow

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

A logic flaw in TensorFlow's QuantizeAndDequantizeV2 op allows negative axis values to bypass validation, enabling heap read/write with local low-privilege access. Patch immediately to TF 2.5.0 or the respective backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) for any deployment running quantized models. Risk is bounded by the local attack vector but insider threats and compromised ML environments make this exploitable in real pipelines.

What is the risk?

Medium-high operational risk for shared ML environments. CVSS 7.8 (High) with local/low-complexity attack vector limits external exposure but lateral movement and insider scenarios remain realistic. Heap underflow yielding full C/I/A impact could enable memory disclosure or code execution within ML serving or training infrastructure. Not in CISA KEV and no evidence of active exploitation in the wild, but unpatched TensorFlow deployments remain a target of opportunity — especially in multi-tenant notebook environments.

What systems are affected?

Package Ecosystem Vulnerable Range Patched
TensorFlow pip No patch
195.8K OpenSSF 7.1 3.7K dependents Pushed 2d ago 4% patched ~1372d to patch Full package profile →

Do you use TensorFlow? You're affected.

How severe is it?

CVSS 3.1
7.8 / 10
EPSS
0.2%
chance of exploitation in 30 days
Higher than 10% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Moderate
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, VulnCheck KEV, CISA SSVC, EPSS, Metasploit, Exploit-DB, trickest/cve, Nuclei templates, and inthewild.io exploitation reports.

What is the attack surface?

AV AC PR UI S C I A
AV Local
AC Low
PR Low
UI None
S Unchanged
C High
I High
A High

What should I do?

5 steps
  1. Patch: Upgrade to TensorFlow 2.5.0 or apply backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.

  2. Audit all TF deployments for version compliance — prioritize internet-accessible inference endpoints and shared training environments.

  3. Restrict execution of untrusted TF graphs and model files in shared platforms.

  4. Container isolation: run TF workloads in sandboxed containers with minimal privileges to limit heap exploitation blast radius.

  5. If observability exists, flag any QuantizeAndDequantizeV2 calls with axis < -1 in op telemetry.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.9.3 - Information security of AI systems
NIST AI RMF
MANAGE-2.4 - Residual risks and vulnerabilities are managed
OWASP LLM Top 10
LLM05 - Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2021-29610?

A logic flaw in TensorFlow's QuantizeAndDequantizeV2 op allows negative axis values to bypass validation, enabling heap read/write with local low-privilege access. Patch immediately to TF 2.5.0 or the respective backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) for any deployment running quantized models. Risk is bounded by the local attack vector but insider threats and compromised ML environments make this exploitable in real pipelines.

Is CVE-2021-29610 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2021-29610, increasing the risk of exploitation.

How to fix CVE-2021-29610?

1. Patch: Upgrade to TensorFlow 2.5.0 or apply backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4. 2. Audit all TF deployments for version compliance — prioritize internet-accessible inference endpoints and shared training environments. 3. Restrict execution of untrusted TF graphs and model files in shared platforms. 4. Container isolation: run TF workloads in sandboxed containers with minimal privileges to limit heap exploitation blast radius. 5. If observability exists, flag any QuantizeAndDequantizeV2 calls with axis < -1 in op telemetry.

What systems are affected by CVE-2021-29610?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, edge inference, quantization-aware training, multi-tenant ML platforms.

What is the CVSS score for CVE-2021-29610?

CVE-2021-29610 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.20%.

What is the AI security impact?

Affected AI Architectures

training pipelinesmodel servingedge inferencequantization-aware trainingmulti-tenant ML platforms

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0011 User Execution
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Article 15
ISO 42001: A.9.3
NIST AI RMF: MANAGE-2.4
OWASP LLM Top 10: LLM05

What are the technical details?

Original Advisory

TensorFlow is an end-to-end open source platform for machine learning. The validation in `tf.raw_ops.QuantizeAndDequantizeV2` allows invalid values for `axis` argument:. The validation(https://github.com/tensorflow/tensorflow/blob/eccb7ec454e6617738554a255d77f08e60ee0808/tensorflow/core/kernels/quantize_and_dequantize_op.cc#L74-L77) uses `||` to mix two different conditions. If `axis_ < -1` the condition in `OP_REQUIRES` will still be true, but this value of `axis_` results in heap underflow. This allows attackers to read/write to other data on the heap. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.

Exploitation Scenario

An adversary with local access — a compromised data scientist workstation or a shared Jupyter environment — crafts a TensorFlow script invoking QuantizeAndDequantizeV2 with axis=-2 or lower. The OR-logic validation bug (using || instead of &&) allows this to pass the OP_REQUIRES check. TF then performs pointer arithmetic resulting in a heap underflow, granting the attacker a read/write primitive against adjacent heap memory. From there, they can extract sensitive data (credentials, model weights, training PII) or corrupt adjacent heap objects to escalate privileges. In a multi-tenant ML platform, a low-privileged user could target another user's process memory through this primitive.

Weaknesses (CWE)

CWE-787 — Out-of-bounds Write: The product writes data past the end, or before the beginning, of the intended buffer.

  • [Requirements] Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other languages, such as Ada and C#, typically provide overflow protection, but the protection can be disabled by the programmer. Be wary that a language's interface to native code may still be subject to overflows, even if the language itself is theoretically safe.
  • [Architecture and Design] Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. Examples include the Safe C String Library (SafeStr) by Messier and Viega [REF-57], and the Strsafe.h library from Microsoft [REF-56]. These libraries provide safer versions of overflow-prone string-handling functions.

Source: MITRE CWE corpus.

CVSS Vector

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Timeline

Published
May 14, 2021
Last Modified
November 21, 2024
First Seen
May 14, 2021

Related Vulnerabilities