CVE-2021-29549: TensorFlow: divide-by-zero DoS in quantized batch norm op

MEDIUM PoC AVAILABLE
Published May 14, 2021
CISO Take

A local attacker with low privileges can crash TensorFlow processes by crafting tensor inputs with zero-element shapes in QuantizedBatchNormWithGlobalNormalization, causing runtime division by zero. This is directly exploitable in multi-tenant ML platforms where users submit inference or training jobs. Patch immediately to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your branch.

Risk Assessment

Medium risk overall, but operationally significant in shared ML environments. The local attack vector limits internet-facing exposure, but in Kubernetes-based ML platforms, Jupyter hubs, or any multi-tenant training/inference cluster, 'local' effectively means any authenticated user or compromised container. Exploitation is trivial—no AI/ML expertise required, just a crafted tensor shape. No data exfiltration or code execution; pure availability impact on TF processes.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed 6d ago 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
5.5 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 1% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

Attack Surface

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

Recommended Action

5 steps
  1. Patch: Upgrade to TensorFlow 2.5.0, or apply the cherrypick to 2.4.2, 2.3.3, 2.2.3, or 2.1.4.

  2. Workaround: Validate tensor input shapes before passing to QuantizedBatchNormWithGlobalNormalization—reject any input where batch or spatial dimensions are zero.

  3. Detection: Monitor TF process crash logs for 'division by zero' or SIGFPE signals originating from quantized_add_op; alert on repeated inference worker restarts.

  4. Isolation: Run inference workers in separate processes with restart policies; use resource quotas to prevent a single crashing job from affecting others.

  5. Audit: Inventory all TF versions in use across training and serving infrastructure; prioritize clusters accepting external or user-submitted graphs.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Art. 9 - Risk management system
ISO 42001
A.9.3 - AI system operation and availability
NIST AI RMF
MANAGE-2.2 - Mechanisms are in place to sustain the value of deployed AI systems
OWASP LLM Top 10
LLM04 - Model Denial of Service

Frequently Asked Questions

What is CVE-2021-29549?

A local attacker with low privileges can crash TensorFlow processes by crafting tensor inputs with zero-element shapes in QuantizedBatchNormWithGlobalNormalization, causing runtime division by zero. This is directly exploitable in multi-tenant ML platforms where users submit inference or training jobs. Patch immediately to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your branch.

Is CVE-2021-29549 actively exploited?

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

How to fix CVE-2021-29549?

1. Patch: Upgrade to TensorFlow 2.5.0, or apply the cherrypick to 2.4.2, 2.3.3, 2.2.3, or 2.1.4. 2. Workaround: Validate tensor input shapes before passing to QuantizedBatchNormWithGlobalNormalization—reject any input where batch or spatial dimensions are zero. 3. Detection: Monitor TF process crash logs for 'division by zero' or SIGFPE signals originating from quantized_add_op; alert on repeated inference worker restarts. 4. Isolation: Run inference workers in separate processes with restart policies; use resource quotas to prevent a single crashing job from affecting others. 5. Audit: Inventory all TF versions in use across training and serving infrastructure; prioritize clusters accepting external or user-submitted graphs.

What systems are affected by CVE-2021-29549?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, quantized model deployment, multi-tenant ML platforms.

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

CVE-2021-29549 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.01%.

Technical Details

NVD Description

TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a runtime division by zero error and denial of service in `tf.raw_ops.QuantizedBatchNormWithGlobalNormalization`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/6f26b3f3418201479c264f2a02000880d8df151c/tensorflow/core/kernels/quantized_add_op.cc#L289-L295) computes a modulo operation without validating that the divisor is not zero. Since `vector_num_elements` is determined based on input shapes(https://github.com/tensorflow/tensorflow/blob/6f26b3f3418201479c264f2a02000880d8df151c/tensorflow/core/kernels/quantized_add_op.cc#L522-L544), a user can trigger scenarios where this quantity is 0. 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 access to a shared ML inference API (e.g., a Jupyter environment, an internal model-serving endpoint, or a cloud ML notebook service) constructs a TensorFlow graph that calls tf.raw_ops.QuantizedBatchNormWithGlobalNormalization with input tensors shaped such that vector_num_elements evaluates to zero at runtime. When the graph is executed, the modulo operation triggers a division-by-zero, crashing the TensorFlow worker process. In a shared serving cluster, this causes the inference replica to restart, producing availability disruption or SLA violations. A persistent attacker can automate this to keep replicas in a crash loop, effectively denying service without any elevated privileges.

CVSS Vector

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

Timeline

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

Related Vulnerabilities