CVE-2021-29547: TensorFlow: OOB read DoS via empty tensor in QuantizedBatchNorm
MEDIUM PoC AVAILABLEThis is a local denial-of-service vulnerability in TensorFlow's quantized batch normalization operation affecting all versions prior to 2.5.0 (backports available to 2.1.4). Patch immediately if running quantized TensorFlow models in shared or multi-tenant environments such as Jupyter hubs, ML platforms, or model serving infrastructure. Exploitability is limited to local/low-privilege access, so priority should be proportional to your exposure surface.
What is the risk?
Practical risk is low-to-medium. The CVSS local attack vector (AV:L) significantly constrains real-world exploitability — an attacker needs local access or the ability to submit crafted inputs to a TF execution environment. Impact is purely availability (A:H), with no confidentiality or integrity loss. Risk escalates in multi-tenant ML platforms (shared Jupyter, Vertex AI Workbench, SageMaker Studio) where co-tenants could intentionally crash shared TF processes. Not in CISA KEV; no active exploitation observed.
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 TensorFlow 2.5.0, or cherrypick backports to 2.4.2, 2.3.3, 2.2.3, or 2.1.4.
-
INPUT VALIDATION
Add pre-flight checks asserting non-empty shape on all tensor inputs before calling quantized ops — enforce
tf.debugging.assert_positive(tf.size(tensor))at pipeline ingress. -
ISOLATION
Run model serving and training workers in separate processes/containers per user in multi-tenant environments; a crash should not propagate across tenants.
-
DETECTION
Monitor for unexpected TensorFlow process crashes (segfaults in logs) on inference or training infrastructure; repeated crashes may indicate probe attempts.
-
DEPENDENCY AUDIT
Scan your ML dependency tree for pinned TF versions below 2.1.4; update lock files accordingly.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29547?
This is a local denial-of-service vulnerability in TensorFlow's quantized batch normalization operation affecting all versions prior to 2.5.0 (backports available to 2.1.4). Patch immediately if running quantized TensorFlow models in shared or multi-tenant environments such as Jupyter hubs, ML platforms, or model serving infrastructure. Exploitability is limited to local/low-privilege access, so priority should be proportional to your exposure surface.
Is CVE-2021-29547 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29547, increasing the risk of exploitation.
How to fix CVE-2021-29547?
1. PATCH: Upgrade to TensorFlow 2.5.0, or cherrypick backports to 2.4.2, 2.3.3, 2.2.3, or 2.1.4. 2. INPUT VALIDATION: Add pre-flight checks asserting non-empty shape on all tensor inputs before calling quantized ops — enforce `tf.debugging.assert_positive(tf.size(tensor))` at pipeline ingress. 3. ISOLATION: Run model serving and training workers in separate processes/containers per user in multi-tenant environments; a crash should not propagate across tenants. 4. DETECTION: Monitor for unexpected TensorFlow process crashes (segfaults in logs) on inference or training infrastructure; repeated crashes may indicate probe attempts. 5. DEPENDENCY AUDIT: Scan your ML dependency tree for pinned TF versions below 2.1.4; update lock files accordingly.
What systems are affected by CVE-2021-29547?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, quantized/edge inference, multi-tenant ML platforms.
What is the CVSS score for CVE-2021-29547?
CVE-2021-29547 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.19%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0029 Denial of AI Service 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 cause a segfault and denial of service via accessing data outside of bounds in `tf.raw_ops.QuantizedBatchNormWithGlobalNormalization`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/55a97caa9e99c7f37a0bbbeb414dc55553d3ae7f/tensorflow/core/kernels/quantized_batch_norm_op.cc#L176-L189) assumes the inputs are not empty. If any of these inputs is empty, `.flat<T>()` is an empty buffer, so accessing the element at index 0 is accessing data outside of bounds. 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 attacker with access to a shared ML notebook environment (e.g., a co-tenant on a Jupyter Hub or a researcher submitting a job to a shared GPU cluster) submits a TensorFlow script that calls `tf.raw_ops.QuantizedBatchNormWithGlobalNormalization` with one or more empty tensors (e.g., `tf.constant([], dtype=tf.quint8)`). The unpatched implementation proceeds without checking tensor size, accesses index 0 of an empty buffer, triggers a segfault, and crashes the TensorFlow worker process. In a model-serving context, an adversary submitting crafted inference requests to an endpoint backed by an unpatched TF runtime achieves the same effect, taking down the serving pod.
Weaknesses (CWE)
CWE-125 — Out-of-bounds Read: The product reads data past the end, or before the beginning, of the intended buffer.
- [Implementation] Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylis
- [Architecture and Design] Use a language that provides appropriate memory abstractions.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H References
- github.com/tensorflow/tensorflow/commit/d6ed5bcfe1dcab9e85a4d39931bd18d99018e75b Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-4fg4-p75j-w5xj 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