CVE-2021-29566: TensorFlow: heap OOB write in Dilation2D training op

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

A heap out-of-bounds write in TensorFlow's dilation convolution backpropagation kernel enables code execution on ML training infrastructure by any user who can submit a crafted training job. In shared ML platforms (Kubeflow, SageMaker, Jupyter hubs), a low-privileged user could escalate to full server compromise. Patch immediately to TF 2.5.0 or the respective backport release for your branch.

What is the risk?

CVSS 7.8 High with local/low-privilege access lowers the internet-exposed risk profile, but shared ML training environments are common attack surfaces where this matters. Exploitation complexity is low once attack position is established — no AI/ML expertise required beyond crafting a malformed op call. Risk is elevated for organizations running multi-tenant ML platforms or accepting externally-sourced training scripts.

What systems are affected?

Package Ecosystem Vulnerable Range Patched
TensorFlow pip No patch
195.8K OpenSSF 7.1 3.7K dependents Pushed 2d ago 4% patched ~1372d to patch Full package profile →

Do you use TensorFlow? You're affected.

How severe is it?

CVSS 3.1
7.8 / 10
EPSS
0.2%
chance of exploitation in 30 days
Higher than 10% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Moderate
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, VulnCheck KEV, CISA SSVC, EPSS, Metasploit, Exploit-DB, trickest/cve, Nuclei templates, and inthewild.io exploitation reports.

What is the attack surface?

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

What should I do?

5 steps
  1. Patch: Upgrade to TF 2.5.0, or apply cherrypick commits for 2.4.2, 2.3.3, 2.2.3, or 2.1.4 as applicable.

  2. Isolate: Run training jobs in sandboxed containers with seccomp/AppArmor profiles — prevents heap exploitation from escalating.

  3. Restrict: Limit access to tf.raw_ops in multi-tenant notebook environments using Python module restrictions or OPA policies.

  4. Detect: Alert on anomalous TensorFlow process crashes (segfaults/SIGABRT) on training workers as a signal of active exploitation attempts.

  5. Audit: Inventory all TensorFlow versions in training pipelines using SBOM tooling.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.8.4 - AI system security
NIST AI RMF
MANAGE 2.2 - Mechanisms are in place to maintain AI systems through their lifecycle
OWASP LLM Top 10
LLM05:2025 - Improper Output Handling / Insecure Plugin Design

Frequently Asked Questions

What is CVE-2021-29566?

A heap out-of-bounds write in TensorFlow's dilation convolution backpropagation kernel enables code execution on ML training infrastructure by any user who can submit a crafted training job. In shared ML platforms (Kubeflow, SageMaker, Jupyter hubs), a low-privileged user could escalate to full server compromise. Patch immediately to TF 2.5.0 or the respective backport release for your branch.

Is CVE-2021-29566 actively exploited?

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

How to fix CVE-2021-29566?

1. Patch: Upgrade to TF 2.5.0, or apply cherrypick commits for 2.4.2, 2.3.3, 2.2.3, or 2.1.4 as applicable. 2. Isolate: Run training jobs in sandboxed containers with seccomp/AppArmor profiles — prevents heap exploitation from escalating. 3. Restrict: Limit access to tf.raw_ops in multi-tenant notebook environments using Python module restrictions or OPA policies. 4. Detect: Alert on anomalous TensorFlow process crashes (segfaults/SIGABRT) on training workers as a signal of active exploitation attempts. 5. Audit: Inventory all TensorFlow versions in training pipelines using SBOM tooling.

What systems are affected by CVE-2021-29566?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, MLOps platforms.

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

CVE-2021-29566 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.20%.

What is the AI security impact?

Affected AI Architectures

training pipelinesmodel servingMLOps platforms

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0035 AI Artifact Collection
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Article 15
ISO 42001: A.8.4
NIST AI RMF: MANAGE 2.2
OWASP LLM Top 10: LLM05:2025

What are the technical details?

Original Advisory

TensorFlow is an end-to-end open source platform for machine learning. An attacker can write outside the bounds of heap allocated arrays by passing invalid arguments to `tf.raw_ops.Dilation2DBackpropInput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/afd954e65f15aea4d438d0a219136fc4a63a573d/tensorflow/core/kernels/dilation_ops.cc#L321-L322) does not validate before writing to the output array. The values for `h_out` and `w_out` are guaranteed to be in range for `out_backprop` (as they are loop indices bounded by the size of the array). However, there are no similar guarantees relating `h_in_max`/`w_in_max` and `in_backprop`. 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

A malicious insider or compromised data scientist account on a shared ML platform submits a training script calling `tf.raw_ops.Dilation2DBackpropInput` with crafted tensor dimensions where `h_in_max`/`w_in_max` values reference memory outside the `in_backprop` buffer bounds. The resulting heap write corrupts adjacent allocator metadata. On an unpatched training worker running as a service account with access to model weights, training data, and secrets, this yields code execution — enabling exfiltration of proprietary model weights, training datasets containing PII, or lateral movement to production serving infrastructure.

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

Timeline

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

Related Vulnerabilities