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.

Risk Assessment

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.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed 6d ago 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
7.8 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 1% 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, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

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

Recommended Action

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.

Classification

Compliance Impact

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.01%.

Technical Details

NVD Description

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)

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