CVE-2021-29566: TensorFlow: heap OOB write in Dilation2D training op
HIGH PoC AVAILABLEA 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 |
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 TF 2.5.0, or apply cherrypick commits for 2.4.2, 2.3.3, 2.2.3, or 2.1.4 as applicable.
-
Isolate: Run training jobs in sandboxed containers with seccomp/AppArmor profiles — prevents heap exploitation from escalating.
-
Restrict: Limit access to tf.raw_ops in multi-tenant notebook environments using Python module restrictions or OPA policies.
-
Detect: Alert on anomalous TensorFlow process crashes (segfaults/SIGABRT) on training workers as a signal of active exploitation attempts.
-
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:
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
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0035 AI Artifact Collection 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 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 References
- github.com/tensorflow/tensorflow/commit/3f6fe4dfef6f57e768260b48166c27d148f3015f Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-pvrc-hg3f-58r6 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