CVE-2021-29558: TensorFlow: heap buffer overflow in SparseSplit op
HIGH PoC AVAILABLEPatch all TensorFlow installations in the 2.1.x–2.4.x range immediately — fixed in 2.5.0 and backported to 2.4.2, 2.3.3, 2.2.3, and 2.1.4. The local attack vector is misleading: shared Jupyter/notebook clusters and MLOps platforms where users can invoke raw ops effectively make this remotely exploitable by any platform user. Prioritize patching in multi-tenant training infrastructure and any serving environment that accepts user-defined TensorFlow graphs.
What is the risk?
CVSS 7.8 with a local attack vector understates real-world risk in typical AI/ML environments. Low attack complexity and no user interaction required mean exploitation is straightforward for anyone with notebook or platform access. Enterprise JupyterHub clusters, hosted ML training platforms, and model-serving infrastructure that proxies user-controlled TF operations elevate this to near-critical. The SparseSplit op is common in NLP and recommendation system pipelines, broadening the attack surface across production workloads.
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 TensorFlow to 2.5.0 or apply cherrypicks: 2.4.2, 2.3.3, 2.2.3, 2.1.4.
-
AUDIT
Inventory all TensorFlow installations across training clusters, serving infrastructure, notebook environments, and CI/CD pipelines.
-
RESTRICT
Disable or sandbox tf.raw_ops access in multi-tenant platforms; do not allow user-controlled operation parameters in production serving.
-
ISOLATE
Run TensorFlow workloads in per-tenant containers or VMs to limit blast radius from exploitation.
-
DETECT
Monitor TF worker processes for anomalous crashes or heap corruption signals that may indicate active exploitation attempts.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29558?
Patch all TensorFlow installations in the 2.1.x–2.4.x range immediately — fixed in 2.5.0 and backported to 2.4.2, 2.3.3, 2.2.3, and 2.1.4. The local attack vector is misleading: shared Jupyter/notebook clusters and MLOps platforms where users can invoke raw ops effectively make this remotely exploitable by any platform user. Prioritize patching in multi-tenant training infrastructure and any serving environment that accepts user-defined TensorFlow graphs.
Is CVE-2021-29558 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29558, increasing the risk of exploitation.
How to fix CVE-2021-29558?
1. PATCH: Upgrade TensorFlow to 2.5.0 or apply cherrypicks: 2.4.2, 2.3.3, 2.2.3, 2.1.4. 2. AUDIT: Inventory all TensorFlow installations across training clusters, serving infrastructure, notebook environments, and CI/CD pipelines. 3. RESTRICT: Disable or sandbox tf.raw_ops access in multi-tenant platforms; do not allow user-controlled operation parameters in production serving. 4. ISOLATE: Run TensorFlow workloads in per-tenant containers or VMs to limit blast radius from exploitation. 5. DETECT: Monitor TF worker processes for anomalous crashes or heap corruption signals that may indicate active exploitation attempts.
What systems are affected by CVE-2021-29558?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, notebook environments, MLOps platforms.
What is the CVSS score for CVE-2021-29558?
CVE-2021-29558 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.21%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0016.001 Software Tools 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. An attacker can cause a heap buffer overflow in `tf.raw_ops.SparseSplit`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/699bff5d961f0abfde8fa3f876e6d241681fbef8/tensorflow/core/util/sparse/sparse_tensor.h#L528-L530) accesses an array element based on a user controlled offset. 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 attacker with low-privileged access to a shared ML platform (e.g., enterprise JupyterHub or a hosted notebook service) submits a crafted TensorFlow computation graph calling tf.raw_ops.SparseSplit with a malicious user-controlled offset value. This triggers an out-of-bounds write in the C++ sparse tensor implementation, corrupting adjacent heap memory. If the TF worker runs with elevated permissions — common in training infrastructure — this can lead to privilege escalation or arbitrary code execution within the worker process, potentially compromising the training environment, model artifacts, or underlying host.
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 References
- github.com/tensorflow/tensorflow/commit/8ba6fa29cd8bf9cef9b718dc31c78c73081f5b31 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-mqh2-9wrp-vx84 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