CVE-2021-29549: TensorFlow: divide-by-zero DoS in quantized batch norm op
MEDIUM PoC AVAILABLEA 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 |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
5 steps-
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.
-
Workaround: Validate tensor input shapes before passing to QuantizedBatchNormWithGlobalNormalization—reject any input where batch or spatial dimensions are zero.
-
Detection: Monitor TF process crash logs for 'division by zero' or SIGFPE signals originating from quantized_add_op; alert on repeated inference worker restarts.
-
Isolation: Run inference workers in separate processes with restart policies; use resource quotas to prevent a single crashing job from affecting others.
-
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:
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.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H References
- github.com/tensorflow/tensorflow/commit/744009c9e5cc5d0447f0dc39d055f917e1fd9e16 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-x83m-p7pv-ch8v Exploit Patch 3rd Party
Timeline
Related Vulnerabilities
CVE-2020-15196 9.9 TensorFlow: heap OOB read in sparse/ragged count ops
Same package: tensorflow CVE-2020-15205 9.8 TensorFlow: heap overflow in StringNGrams, ASLR bypass
Same package: tensorflow CVE-2020-15208 9.8 TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow CVE-2019-16778 9.8 TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflow CVE-2022-23587 9.8 TensorFlow: integer overflow in Grappler enables RCE
Same package: tensorflow
AI Threat Alert