CVE-2021-29550: TensorFlow: FractionalAvgPool DoS via divide-by-zero
MEDIUM PoC AVAILABLEA locally-exploitable divide-by-zero in TensorFlow's FractionalAvgPool op crashes the TF runtime when attacker-controlled tensor shapes cause output_size to reach zero. Exposure is limited to systems where untrusted users can submit TensorFlow operations (e.g., shared ML platforms, multi-tenant training environments). Patch immediately to TF 2.5.0 or the applicable backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) and restrict who can submit raw TF ops.
Risk Assessment
Effective risk is LOW-MEDIUM for most organizations. The local attack vector (AV:L) and low-privilege requirement mean this is not remotely exploitable without first gaining system access. In multi-tenant ML platforms or Jupyter-style environments where users can execute arbitrary TF ops, risk elevates to MEDIUM since a single malicious notebook cell can crash a shared inference or training node. No active exploitation reported; not in CISA KEV. CVSS 5.5 is accurate for isolated deployments but underestimates impact in shared-compute AI infrastructure.
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.5.0 or backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4 per commit 548b5eaf23685d86f722233d8fbc21d0a4aecb96. Run
pip show tensorflowto confirm version. -
Validate inputs
Add pre-op assertion that
input_size[i] >= pooling_ratio[i]before invoking FractionalAvgPool; reject or sanitize out-of-range values at API boundaries. -
Restrict op access
If running a shared ML platform, use TF op allowlists or sandboxed execution (e.g., TF Serving with input schema validation) to prevent raw op invocation by untrusted users.
-
Detect
Monitor for unexpected TF process crashes or segfaults in training/serving logs — repeated crashes on FractionalAvgPool inputs may indicate probing.
-
Isolate jobs
Run multi-tenant training jobs in separate containers/processes so a crash in one job cannot affect others.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29550?
A locally-exploitable divide-by-zero in TensorFlow's FractionalAvgPool op crashes the TF runtime when attacker-controlled tensor shapes cause output_size to reach zero. Exposure is limited to systems where untrusted users can submit TensorFlow operations (e.g., shared ML platforms, multi-tenant training environments). Patch immediately to TF 2.5.0 or the applicable backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) and restrict who can submit raw TF ops.
Is CVE-2021-29550 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29550, increasing the risk of exploitation.
How to fix CVE-2021-29550?
1. **Patch**: Upgrade TensorFlow to 2.5.0 or backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4 per commit 548b5eaf23685d86f722233d8fbc21d0a4aecb96. Run `pip show tensorflow` to confirm version. 2. **Validate inputs**: Add pre-op assertion that `input_size[i] >= pooling_ratio[i]` before invoking FractionalAvgPool; reject or sanitize out-of-range values at API boundaries. 3. **Restrict op access**: If running a shared ML platform, use TF op allowlists or sandboxed execution (e.g., TF Serving with input schema validation) to prevent raw op invocation by untrusted users. 4. **Detect**: Monitor for unexpected TF process crashes or segfaults in training/serving logs — repeated crashes on FractionalAvgPool inputs may indicate probing. 5. **Isolate jobs**: Run multi-tenant training jobs in separate containers/processes so a crash in one job cannot affect others.
What systems are affected by CVE-2021-29550?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, shared ML platforms, inference servers.
What is the CVSS score for CVE-2021-29550?
CVE-2021-29550 has a CVSS v3.1 base score of 5.5 (MEDIUM). 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 cause a runtime division by zero error and denial of service in `tf.raw_ops.FractionalAvgPool`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/acc8ee69f5f46f92a3f1f11230f49c6ac266f10c/tensorflow/core/kernels/fractional_avg_pool_op.cc#L85-L89) computes a divisor quantity by dividing two user controlled values. The user controls the values of `input_size[i]` and `pooling_ratio_[i]` (via the `value.shape()` and `pooling_ratio` arguments). If the value in `input_size[i]` is smaller than the `pooling_ratio_[i]`, then the floor operation results in `output_size[i]` being 0. The `DCHECK_GT` line is a no-op outside of debug mode, so in released versions of TF this does not trigger. Later, these computed values are used as arguments(https://github.com/tensorflow/tensorflow/blob/acc8ee69f5f46f92a3f1f11230f49c6ac266f10c/tensorflow/core/kernels/fractional_avg_pool_op.cc#L96-L99) to `GeneratePoolingSequence`(https://github.com/tensorflow/tensorflow/blob/acc8ee69f5f46f92a3f1f11230f49c6ac266f10c/tensorflow/core/kernels/fractional_pool_common.cc#L100-L108). There, the first computation is a division in a modulo operation. Since `output_length` can be 0, this results in runtime crashing. 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 ML training platform (e.g., internal Jupyter Hub, MLflow Projects, or a model-as-a-service endpoint accepting custom model files) uploads or executes a model containing a FractionalAvgPool layer configured with `pooling_ratio > input_size` (e.g., input shape [1, 2, 2, 1] with pooling_ratio [1.0, 3.0, 3.0, 1.0]). When the operator executes, `output_size` computes to 0, the DCHECK is suppressed in release builds, and the subsequent modulo operation divides by zero — crashing the TF runtime. In a shared compute cluster this takes down the entire training node, causing a denial of service for all co-located jobs. An attacker could automate this to keep the platform continuously unavailable.
Weaknesses (CWE)
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/548b5eaf23685d86f722233d8fbc21d0a4aecb96 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-f78g-q7r4-9wcv 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