CVE-2021-41197: TensorFlow: integer overflow in tensor dims causes DoS

MEDIUM PoC AVAILABLE
Published November 5, 2021
CISO Take

A local attacker with low privileges can crash TensorFlow processes by crafting tensors with dimensions that overflow int64_t, triggering CHECK-failures. This is a denial-of-service risk in shared ML inference environments where users can submit arbitrary inputs. Patch to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 immediately if these versions are in your supported range.

What is the risk?

Medium risk overall, but elevated in multi-tenant ML serving scenarios. The local attack vector and low privilege requirement limit opportunistic exploitation, but in shared inference environments (Jupyter hubs, MLflow model servers, internal APIs) any authenticated user could trigger a crash. No confidentiality or integrity impact — pure availability. Not actively exploited in the wild and not in CISA KEV.

What systems are affected?

Package Ecosystem Vulnerable Range Patched
TensorFlow pip No patch
195.8K OpenSSF 7.1 3.7K dependents Pushed 2d ago 4% patched ~1372d to patch Full package profile →

Do you use TensorFlow? You're affected.

How severe is it?

CVSS 3.1
5.5 / 10
EPSS
0.3%
chance of exploitation in 30 days
Higher than 22% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, VulnCheck KEV, CISA SSVC, EPSS, Metasploit, Exploit-DB, trickest/cve, Nuclei templates, and inthewild.io exploitation reports.

What is the attack surface?

AV AC PR UI S C I A
AV Local
AC Low
PR Low
UI None
S Unchanged
C None
I None
A High

What should I do?

5 steps
  1. Patch: upgrade to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 depending on your branch.

  2. Workaround: validate tensor shape inputs at API boundaries before passing to TensorFlow ops — reject any dimension product that would exceed INT64_MAX.

  3. Detection: monitor for unexpected TensorFlow process crashes or CHECK-failure stack traces in logs (grep for 'CHECK fail' or 'MultiplyWithoutOverflow').

  4. Isolation: run inference workers in isolated processes/containers so a single crash does not take down the entire serving stack.

  5. Confirm no public-facing endpoints accept raw tensor shapes without validation.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Art. 9 - Risk management system for high-risk AI systems
ISO 42001
8.4 - AI system risk management — availability and resilience
NIST AI RMF
MANAGE-2.2 - Mechanisms to sustain treatment of AI risks

Frequently Asked Questions

What is CVE-2021-41197?

A local attacker with low privileges can crash TensorFlow processes by crafting tensors with dimensions that overflow int64_t, triggering CHECK-failures. This is a denial-of-service risk in shared ML inference environments where users can submit arbitrary inputs. Patch to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 immediately if these versions are in your supported range.

Is CVE-2021-41197 actively exploited?

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

How to fix CVE-2021-41197?

1. Patch: upgrade to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 depending on your branch. 2. Workaround: validate tensor shape inputs at API boundaries before passing to TensorFlow ops — reject any dimension product that would exceed INT64_MAX. 3. Detection: monitor for unexpected TensorFlow process crashes or CHECK-failure stack traces in logs (grep for 'CHECK fail' or 'MultiplyWithoutOverflow'). 4. Isolation: run inference workers in isolated processes/containers so a single crash does not take down the entire serving stack. 5. Confirm no public-facing endpoints accept raw tensor shapes without validation.

What systems are affected by CVE-2021-41197?

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

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

CVE-2021-41197 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.31%.

What is the AI security impact?

Affected AI Architectures

model servingtraining pipelinesinference

MITRE ATLAS Techniques

AML.T0029 Denial of AI Service
AML.T0034 Cost Harvesting
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Art. 9
ISO 42001: 8.4
NIST AI RMF: MANAGE-2.2

What are the technical details?

Original Advisory

TensorFlow is an open source platform for machine learning. In affected versions TensorFlow allows tensor to have a large number of dimensions and each dimension can be as large as desired. However, the total number of elements in a tensor must fit within an `int64_t`. If an overflow occurs, `MultiplyWithoutOverflow` would return a negative result. In the majority of TensorFlow codebase this then results in a `CHECK`-failure. Newer constructs exist which return a `Status` instead of crashing the binary. This is similar to CVE-2021-29584. 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 shared ML inference environment (e.g., internal model API, Jupyter notebook server, MLflow serving endpoint) submits a POST request with a tensor shape such as [9223372036854775807, 9223372036854775807]. TensorFlow's MultiplyWithoutOverflow silently returns a negative value, triggering a CHECK-failure that crashes the TensorFlow serving process. In containerized environments without restart policies, this takes the inference service offline. In persistent notebook environments, it terminates the kernel. A low-skill attacker can automate this in a loop to maintain denial of service.

Weaknesses (CWE)

CWE-190 — Integer Overflow or Wraparound: The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.

  • [Requirements] Ensure that all protocols are strictly defined, such that all out-of-bounds behavior can be identified simply, and require strict conformance to the protocol.
  • [Requirements] Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. If possible, choose a language or compiler that performs automatic bounds checking.

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

Timeline

Published
November 5, 2021
Last Modified
November 21, 2024
First Seen
November 5, 2021

Related Vulnerabilities