CVE-2021-41212: TensorFlow: heap OOB read in ragged.cross shape inference
HIGH PoC AVAILABLEAny TensorFlow deployment (training, serving, notebooks) running versions prior to 2.4.4/2.5.2/2.6.1/2.7.0 that processes ragged tensors is exposed to a local heap out-of-bounds read triggerable by crafted inputs to tf.ragged.cross. Patch immediately — if you run multi-tenant Jupyter/Colab environments or expose TF serving endpoints that accept user-controlled tensor shapes, the risk escalates significantly. Prioritize patching ML infrastructure where untrusted inputs can reach ragged tensor operations.
Risk Assessment
Effective risk is moderate-to-high for organizations with shared or externally-accessible ML infrastructure. The CVSS local attack vector (AV:L) limits scope for remote exploitation, but in practice TensorFlow Serving, Jupyter hubs, and ML pipeline APIs expose tensor shape processing to untrusted inputs — effectively elevating this to a network-reachable condition. AC:L (low complexity) means exploitation requires minimal skill once a vulnerable endpoint is identified. No CISA KEV listing and no public PoC weaponization as of disclosure, but the GitHub advisory tags it as 'Exploit' available.
Affected Systems
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| tensorflow | pip | — | No patch |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
4 steps-
Patch: Upgrade to TensorFlow >=2.7.0, or apply cherrypick patches for 2.4.4, 2.5.2, 2.6.1. Pin versions in requirements.txt/conda envs and enforce in CI.
-
Immediate workaround: If patching is delayed, disable or sandbox endpoints that accept user-controlled ragged tensor shapes. Validate input tensor rank and shape bounds before passing to tf.ragged.cross.
-
Detection: Monitor for unexpected TF process crashes (SIGSEGV/SIGABRT) in serving infrastructure — repeated crashes against ragged ops are an indicator. Enable AddressSanitizer in dev/staging builds to catch OOB access during testing.
-
Inventory: Audit ML pipelines for use of tf.ragged.cross and related ragged ops; prioritize multi-tenant or externally-facing deployments.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-41212?
Any TensorFlow deployment (training, serving, notebooks) running versions prior to 2.4.4/2.5.2/2.6.1/2.7.0 that processes ragged tensors is exposed to a local heap out-of-bounds read triggerable by crafted inputs to tf.ragged.cross. Patch immediately — if you run multi-tenant Jupyter/Colab environments or expose TF serving endpoints that accept user-controlled tensor shapes, the risk escalates significantly. Prioritize patching ML infrastructure where untrusted inputs can reach ragged tensor operations.
Is CVE-2021-41212 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-41212, increasing the risk of exploitation.
How to fix CVE-2021-41212?
1. Patch: Upgrade to TensorFlow >=2.7.0, or apply cherrypick patches for 2.4.4, 2.5.2, 2.6.1. Pin versions in requirements.txt/conda envs and enforce in CI. 2. Immediate workaround: If patching is delayed, disable or sandbox endpoints that accept user-controlled ragged tensor shapes. Validate input tensor rank and shape bounds before passing to tf.ragged.cross. 3. Detection: Monitor for unexpected TF process crashes (SIGSEGV/SIGABRT) in serving infrastructure — repeated crashes against ragged ops are an indicator. Enable AddressSanitizer in dev/staging builds to catch OOB access during testing. 4. Inventory: Audit ML pipelines for use of tf.ragged.cross and related ragged ops; prioritize multi-tenant or externally-facing deployments.
What systems are affected by CVE-2021-41212?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, shared ML notebooks, feature engineering pipelines.
What is the CVSS score for CVE-2021-41212?
CVE-2021-41212 has a CVSS v3.1 base score of 7.1 (HIGH). The EPSS exploitation probability is 0.02%.
Technical Details
NVD Description
TensorFlow is an open source platform for machine learning. In affected versions the shape inference code for `tf.ragged.cross` can trigger a read outside of bounds of heap allocated array. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4, as these are also affected and still in supported range.
Exploitation Scenario
An adversary with access to a TensorFlow Serving endpoint or shared Jupyter environment submits inference requests or notebook code containing tf.ragged.cross calls with maliciously shaped input tensors. During shape inference — before any computation runs — the vulnerable code reads beyond the bounds of a heap-allocated array. In a multi-tenant ML platform, this crashes the TF worker process (denying service to other users) and may leak heap contents including portions of loaded model weights or co-located inference request buffers. In a training pipeline context, an insider or compromised CI/CD job injects the malformed op into a training graph, crashing distributed workers and potentially exfiltrating memory from the training coordinator process.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H References
- github.com/tensorflow/tensorflow/commit/fa6b7782fbb14aa08d767bc799c531f5e1fb3bb8 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-fr77-rrx3-cp7g Exploit Patch 3rd Party
- github.com/ARPSyndicate/cvemon Exploit
- github.com/adwisatya/SnykVulndb Exploit
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