CVE-2021-41227: TensorFlow: OOB read in ImmutableConst leaks memory
MEDIUM PoC AVAILABLEA local attacker with low privileges can read arbitrary process memory through TensorFlow's ImmutableConst operation by exploiting improper handling of memory-mapped tstring types. In shared ML infrastructure (multi-tenant GPU clusters, notebook servers), this could expose model weights, API credentials, or training data held in process memory. Patch to TF 2.7.0, 2.6.1, 2.5.2, or 2.4.4 immediately; restrict local access to ML training and serving environments as compensating control.
Risk Assessment
Medium overall, elevated in shared-compute ML environments. The local attack vector is the primary risk limiter — exploitation requires a foothold on the TensorFlow host. However, ML infrastructure frequently runs on shared GPU servers or multi-tenant Jupyter environments where local access is common and expected. In those contexts, the confidentiality impact is effectively HIGH: an adversary co-tenant could craft a malicious saved model or graph and read sensitive data from the TF runtime process memory. No integrity or availability impact. EPSS data unavailable but CWE-125 out-of-bounds reads in popular ML frameworks are regularly targeted post-exploitation.
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 TensorFlow to 2.7.0+, 2.6.1+, 2.5.2+, or 2.4.4+ (commits 1cb6bb6 and 3712a2d).
-
VALIDATE INPUT
Reject SavedModels or TF graphs from untrusted sources before execution — scan for ImmutableConst ops with memory-mapped string tensors until patched.
-
ISOLATE
Run TensorFlow inference/training workloads in dedicated containers or VMs with minimal privileges; do not share TF worker processes across trust boundaries.
-
AUDIT
Inventory all TF versions deployed in training and serving pipelines; include transitive dependencies in ML Docker images.
-
DETECT
Monitor for unexpected process memory spikes or model files containing tstring memory-mapped constants in production serving.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-41227?
A local attacker with low privileges can read arbitrary process memory through TensorFlow's ImmutableConst operation by exploiting improper handling of memory-mapped tstring types. In shared ML infrastructure (multi-tenant GPU clusters, notebook servers), this could expose model weights, API credentials, or training data held in process memory. Patch to TF 2.7.0, 2.6.1, 2.5.2, or 2.4.4 immediately; restrict local access to ML training and serving environments as compensating control.
Is CVE-2021-41227 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-41227, increasing the risk of exploitation.
How to fix CVE-2021-41227?
1. PATCH: Upgrade TensorFlow to 2.7.0+, 2.6.1+, 2.5.2+, or 2.4.4+ (commits 1cb6bb6 and 3712a2d). 2. VALIDATE INPUT: Reject SavedModels or TF graphs from untrusted sources before execution — scan for ImmutableConst ops with memory-mapped string tensors until patched. 3. ISOLATE: Run TensorFlow inference/training workloads in dedicated containers or VMs with minimal privileges; do not share TF worker processes across trust boundaries. 4. AUDIT: Inventory all TF versions deployed in training and serving pipelines; include transitive dependencies in ML Docker images. 5. DETECT: Monitor for unexpected process memory spikes or model files containing tstring memory-mapped constants in production serving.
What systems are affected by CVE-2021-41227?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, on-premise ML infrastructure, shared notebook environments, MLaaS platforms executing user-submitted models.
What is the CVSS score for CVE-2021-41227?
CVE-2021-41227 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.08%.
Technical Details
NVD Description
TensorFlow is an open source platform for machine learning. In affected versions the `ImmutableConst` operation in TensorFlow can be tricked into reading arbitrary memory contents. This is because the `tstring` TensorFlow string class has a special case for memory mapped strings but the operation itself does not offer any support for this datatype. 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 attacker with local access to a shared ML training server (e.g., a data scientist account on a GPU cluster) crafts a malicious TensorFlow SavedModel containing an ImmutableConst operation with a carefully constructed memory-mapped tstring tensor. When the model is loaded and executed — either by their own session or by tricking the platform into running it — the out-of-bounds read traverses adjacent memory regions of the TF process. This could expose API keys loaded by a co-tenant's training job, model weights stored in memory, or environment variables containing database credentials, all without triggering application-layer alerts.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N References
- github.com/tensorflow/tensorflow/commit/1cb6bb6c2a6019417c9adaf9e6843ba75ee2580b Patch 3rd Party
- github.com/tensorflow/tensorflow/commit/3712a2d3455e6ccb924daa5724a3652a86f6b585 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-j8c8-67vp-6mx7 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