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.
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 |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
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.
Classification
Compliance Impact
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.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 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
AI Threat Alert