CVE-2021-29540: TensorFlow: heap buffer overflow in Conv2D gradient op

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

A heap buffer overflow in TensorFlow's Conv2DBackpropFilter allows local attackers with low privileges to achieve full process compromise (RCE, data exfiltration, crash). Patch immediately to TensorFlow 2.1.4+/2.2.3+/2.3.3+/2.4.2+/2.5.0+ on any system running training workloads. Shared ML training infrastructure—JupyterHub clusters, MLOps platforms, multi-tenant GPU farms—are the highest-risk environments.

Risk Assessment

Risk is HIGH for organizations operating shared ML training infrastructure where multiple users or workloads submit training jobs. The local attack vector (AV:L) limits exposure versus network-exploitable CVEs, but in practice most ML training environments are accessible via notebooks, REST APIs, or job schedulers that effectively provide remote code paths. Low privilege requirement (PR:L) means any authenticated cluster user can exploit this. Full C/I/A impact means a compromised training node could exfiltrate model weights, training data, and credentials. The 2021 publication date raises concern that unpatched legacy training environments remain exposed.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed today 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 9% 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

6 steps
  1. PATCH

    Upgrade TensorFlow to 2.5.0 or cherrypick fixes into 2.1.4, 2.2.3, 2.3.3, or 2.4.2. Verify installed version with pip show tensorflow.

  2. ISOLATE

    Run training workloads in containers with seccomp/AppArmor profiles and no-new-privileges flags to limit post-exploitation lateral movement.

  3. VALIDATE INPUTS

    Add explicit validation that len(filter_sizes) matches expected filter tensor shape before invoking Conv2D gradient operations.

  4. AUDIT

    Scan all training environments for TensorFlow < 2.5.0 using pip list | grep tensorflow or SBOM tooling.

  5. DETECT

    Monitor for anomalous process spawning or memory corruption signals (SIGSEGV/SIGBUS) in training job logs.

  6. NETWORK CONTROLS

    Ensure training nodes are not directly internet-exposed; require VPN or bastion access.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity Article 9 - Risk management system
ISO 42001
8.4 - AI system operation A.6.2.6 - AI system software integrity
NIST AI RMF
GOVERN 1.1 - Policies for AI risk management MANAGE 2.2 - Mechanisms to respond to AI risks
OWASP LLM Top 10
LLM06 - Sensitive Information Disclosure

Frequently Asked Questions

What is CVE-2021-29540?

A heap buffer overflow in TensorFlow's Conv2DBackpropFilter allows local attackers with low privileges to achieve full process compromise (RCE, data exfiltration, crash). Patch immediately to TensorFlow 2.1.4+/2.2.3+/2.3.3+/2.4.2+/2.5.0+ on any system running training workloads. Shared ML training infrastructure—JupyterHub clusters, MLOps platforms, multi-tenant GPU farms—are the highest-risk environments.

Is CVE-2021-29540 actively exploited?

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

How to fix CVE-2021-29540?

1. PATCH: Upgrade TensorFlow to 2.5.0 or cherrypick fixes into 2.1.4, 2.2.3, 2.3.3, or 2.4.2. Verify installed version with `pip show tensorflow`. 2. ISOLATE: Run training workloads in containers with seccomp/AppArmor profiles and no-new-privileges flags to limit post-exploitation lateral movement. 3. VALIDATE INPUTS: Add explicit validation that len(filter_sizes) matches expected filter tensor shape before invoking Conv2D gradient operations. 4. AUDIT: Scan all training environments for TensorFlow < 2.5.0 using `pip list | grep tensorflow` or SBOM tooling. 5. DETECT: Monitor for anomalous process spawning or memory corruption signals (SIGSEGV/SIGBUS) in training job logs. 6. NETWORK CONTROLS: Ensure training nodes are not directly internet-exposed; require VPN or bastion access.

What systems are affected by CVE-2021-29540?

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

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

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

Technical Details

NVD Description

TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a heap buffer overflow to occur in `Conv2DBackpropFilter`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1b0296c3b8dd9bd948f924aa8cd62f87dbb7c3da/tensorflow/core/kernels/conv_grad_filter_ops.cc#L495-L497) computes the size of the filter tensor but does not validate that it matches the number of elements in `filter_sizes`. Later, when reading/writing to this buffer, code uses the value computed here, instead of the number of elements in the tensor. 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 adversary with access to a shared Jupyter notebook environment (e.g., a disgruntled data scientist, a compromised notebook session via XSS/SSRF, or a malicious training job submitted via MLflow/Kubeflow) crafts a TensorFlow call where filter_sizes specifies a shape larger than the actual filter tensor. When Conv2DBackpropFilter computes the expected buffer size from filter_sizes and writes gradient data, it overflows into adjacent heap memory. On a predictable heap layout, the attacker overwrites a function pointer or vtable entry to redirect execution. From the training node, they exfiltrate model weights, training datasets (potentially PII), and environment secrets (cloud credentials, API keys in env vars). In a GPU cluster with shared NFS storage, this becomes lateral movement across all training jobs.

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