CVE-2021-29552: TensorFlow: DoS via empty num_segments tensor assertion
MEDIUMPoC AVAILABLEA local attacker with ability to submit TensorFlow operations can crash the TF process by passing an empty tensor to UnsortedSegmentJoin, triggering a failed assertion. Upgrade to TensorFlow 2.5.0 or the respective backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) immediately if running shared or multi-tenant ML infrastructure. Production serving behind an inference API is not directly exposed unless arbitrary op execution is permitted.
What is the risk?
Medium. CVSS 5.5 reflects a local attack vector and low-privileges requirement, meaning the attacker must already have code execution or op-submission access on the host. Risk elevates significantly in multi-tenant environments — shared Jupyter hubs, AI sandboxes, or model serving platforms that allow user-submitted computation graphs are the realistic exposure surface. No evidence of active exploitation or weaponized PoC in the wild; patch is available and straightforward.
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 stepsPATCH
Upgrade to TensorFlow ≥2.5.0, or cherry-pick to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4 as appropriate. Commit 704866eabe03a9aeda044ec91a8d0c83fc1ebdbe.
VALIDATE INPUTS
Add shape validation for num_segments tensors at inference/serving boundaries — reject empty or zero-element tensors before they reach TF ops.
ISOLATE
Run TF workers in isolated processes or containers so a crash does not cascade to the broader serving infrastructure.
DETECT
Monitor for abnormal TF process exits or assertion failure logs (SIGABRT / CHECK failures in TF logs).
MULTI-TENANT HARDENING: In shared notebook environments, restrict or sandbox TF op execution to prevent malicious op graph submission.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29552?
A local attacker with ability to submit TensorFlow operations can crash the TF process by passing an empty tensor to UnsortedSegmentJoin, triggering a failed assertion. Upgrade to TensorFlow 2.5.0 or the respective backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) immediately if running shared or multi-tenant ML infrastructure. Production serving behind an inference API is not directly exposed unless arbitrary op execution is permitted.
Is CVE-2021-29552 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29552, increasing the risk of exploitation.
How to fix CVE-2021-29552?
1. PATCH: Upgrade to TensorFlow ≥2.5.0, or cherry-pick to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4 as appropriate. Commit 704866eabe03a9aeda044ec91a8d0c83fc1ebdbe. 2. VALIDATE INPUTS: Add shape validation for num_segments tensors at inference/serving boundaries — reject empty or zero-element tensors before they reach TF ops. 3. ISOLATE: Run TF workers in isolated processes or containers so a crash does not cascade to the broader serving infrastructure. 4. DETECT: Monitor for abnormal TF process exits or assertion failure logs (SIGABRT / CHECK failures in TF logs). 5. MULTI-TENANT HARDENING: In shared notebook environments, restrict or sandbox TF op execution to prevent malicious op graph submission.
What systems are affected by CVE-2021-29552?
This vulnerability affects the following AI/ML architecture patterns: model serving, training pipelines, shared ML platforms.
What is the CVSS score for CVE-2021-29552?
CVE-2021-29552 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.001AI SoftwareAML.T0029Denial of AI ServiceAML.T0049Exploit Public-Facing ApplicationCompliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service by controlling the values of `num_segments` tensor argument for `UnsortedSegmentJoin`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/a2a607db15c7cd01d754d37e5448d72a13491bdb/tensorflow/core/kernels/unsorted_segment_join_op.cc#L92-L93) assumes that the `num_segments` tensor is a valid scalar. Since the tensor is empty the `CHECK` involved in `.scalar<T>()()` that checks that the number of elements is exactly 1 will be invalidated and this would result in process termination. 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 platform (e.g., a data science Jupyter environment or a model serving endpoint that accepts custom TF computation graphs) crafts a request that invokes UnsortedSegmentJoin with num_segments set to an empty tensor (shape=[0]). The TF runtime's .scalar<T>()() call checks for exactly one element, fails the internal CHECK assertion, and terminates the TF process via SIGABRT. In a shared environment, this crashes the worker serving all tenants. In a hostile insider scenario, a malicious ML engineer could embed this op into a training job to repeatedly crash infrastructure during a critical model deployment window.
Weaknesses (CWE)
CWE-617 — Reachable Assertion: The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.
- [Implementation] If the assertion statement is required (e.g., for security or reliability), change the invoking code to avoid the conditions that trigger the assertion.
- [Implementation] Consider changing the assertion to some other less "fatal" error. This might not be easy to implement, since other code may be needed to handle the error.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:HReferences
Timeline
Related Vulnerabilities
CVE-2026-189489.9Feast: insecure UDF deserialization enables RCE
Same package: tensorflowCVE-2020-151969.9TensorFlow: heap OOB read in sparse/ragged count ops
Same package: tensorflowCVE-2020-152059.8TensorFlow: heap overflow in StringNGrams, ASLR bypass
Same package: tensorflowCVE-2019-167789.8TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflowCVE-2020-152089.8TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow