CVE-2021-29573: TensorFlow: div-by-zero in MaxPoolGrad op causes DoS
MEDIUM PoC AVAILABLEThis medium-severity vulnerability allows a local, low-privileged attacker to crash TensorFlow processes by passing a zero-batch tensor to MaxPoolGradWithArgmax — no remote vector, no data exfiltration. Primary risk is availability disruption in shared or multi-tenant ML training environments. Patch immediately to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4; the fix is available and straightforward.
What is the risk?
Risk is LOW to MEDIUM depending on deployment context. CVSS 5.5 (local) reflects limited exploitability: attacker needs local access and low privileges. In isolated single-tenant training environments the blast radius is minimal. Risk escalates in multi-tenant ML platforms (shared Jupyter, Kubeflow, SageMaker Studio) where untrusted users can submit training jobs — a malicious insider or compromised notebook could repeatedly crash shared training workers. Not in CISA KEV and no evidence of active exploitation as of disclosure date.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| TensorFlow | pip | — | No patch |
Do you use TensorFlow? You're affected.
How severe is it?
What is the attack surface?
What should I do?
5 steps-
PATCH
Upgrade to TensorFlow 2.5.0 or cherrypicked fixes: 2.4.2, 2.3.3, 2.2.3, 2.1.4. Commit 376c352a is the authoritative fix.
-
WORKAROUND
Add upstream batch dimension validation before any call to MaxPoolGradWithArgmax — assert or tf.debugging.assert_greater(tf.shape(tensor)[0], 0).
-
MULTI-TENANT PLATFORMS: Restrict user-submitted training jobs to sandboxed environments; treat TF process crashes as potential abuse signals.
-
DETECTION
Alert on abnormal TF process termination in training clusters; log SIGFPE/division-by-zero signals from ML worker processes.
-
INVENTORY
Run 'pip show tensorflow' across all ML nodes; flag any version below the patched releases.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29573?
This medium-severity vulnerability allows a local, low-privileged attacker to crash TensorFlow processes by passing a zero-batch tensor to MaxPoolGradWithArgmax — no remote vector, no data exfiltration. Primary risk is availability disruption in shared or multi-tenant ML training environments. Patch immediately to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4; the fix is available and straightforward.
Is CVE-2021-29573 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29573, increasing the risk of exploitation.
How to fix CVE-2021-29573?
1. PATCH: Upgrade to TensorFlow 2.5.0 or cherrypicked fixes: 2.4.2, 2.3.3, 2.2.3, 2.1.4. Commit 376c352a is the authoritative fix. 2. WORKAROUND: Add upstream batch dimension validation before any call to MaxPoolGradWithArgmax — assert or tf.debugging.assert_greater(tf.shape(tensor)[0], 0). 3. MULTI-TENANT PLATFORMS: Restrict user-submitted training jobs to sandboxed environments; treat TF process crashes as potential abuse signals. 4. DETECTION: Alert on abnormal TF process termination in training clusters; log SIGFPE/division-by-zero signals from ML worker processes. 5. INVENTORY: Run 'pip show tensorflow' across all ML nodes; flag any version below the patched releases.
What systems are affected by CVE-2021-29573?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving with gradient-based inference, multi-tenant ML platforms, MLOps CI/CD pipelines.
What is the CVSS score for CVE-2021-29573?
CVE-2021-29573 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.19%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0029 Denial of AI Service AML.T0049 Exploit Public-Facing Application Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an end-to-end open source platform for machine learning. The implementation of `tf.raw_ops.MaxPoolGradWithArgmax` is vulnerable to a division by 0. The implementation(https://github.com/tensorflow/tensorflow/blob/279bab6efa22752a2827621b7edb56a730233bd8/tensorflow/core/kernels/maxpooling_op.cc#L1033-L1034) fails to validate that the batch dimension of the tensor is non-zero, before dividing by this quantity. 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 insider threat or attacker with access to a shared Kubeflow or MLflow training cluster submits a crafted training script that passes a tensor with batch_size=0 to a model containing a max-pooling layer with gradient computation (e.g., during a backward pass). TensorFlow attempts to divide by the batch dimension, triggers a division-by-zero (CWE-369), and the training worker process crashes. The attacker repeats this in a loop to create sustained denial of service against the shared training infrastructure, delaying production model deployments. In a CI/CD MLOps pipeline, this could block automated retraining jobs indefinitely.
Weaknesses (CWE)
CWE-369 — Divide By Zero: The product divides a value by zero.
Source: MITRE CWE corpus.
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/376c352a37ce5a68b721406dc7e77ac4b6cf483d Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-9vpm-rcf4-9wqw 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