`CHECK`-failures in `TensorByteSize` in Tensorflow

Description

Impact

A malicious user can cause a denial of service by altering a SavedModel such that TensorByteSize would trigger CHECK failures.

int64_t TensorByteSize(const TensorProto& t) {
  // num_elements returns -1 if shape is not fully defined.
  int64_t num_elems = TensorShape(t.tensor_shape()).num_elements();
  return num_elems < 0 ? -1 : num_elems * DataTypeSize(t.dtype());
}

TensorShape constructor throws a CHECK-fail if shape is partial or has a number of elements that would overflow the size of an int. The PartialTensorShape constructor instead does not cause a CHECK-abort if the shape is partial, which is exactly what this function needs to be able to return -1.

Patches

We have patched the issue in GitHub commit c2426bba00a01de6913738df8fa78e0215fcce02.

The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.

For more information

Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.

Basic information

Type
reviewed
Severity
medium
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2022-02-10 00:34:01 UTC
Updated
2024-11-07 22:28:15 UTC
GitHub reviewed
2022-02-04 19:53:00 UTC
NVD published
2022-02-04

EPSS Score

Score Percentile
0.22% 44.52%

CVSS Scores

Base score Version Severity Vector
6.5 3.1
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:L)
A normal user session is enough; they don’t have to be admin.
User interaction (UI:N)
Nobody has to click “OK” or open a trap file; it can work without a victim helping.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:N)
Doesn’t really leak secrets in a meaningful way.
Integrity (I:N)
Data isn’t meaningfully altered or forged.
Availability (A:H)
Could take the service down hard or make it unusable for people who depend on it.

Identifiers

CWEs

CWE id Name
CWE-617 Reachable Assertion

Affected packages (9)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
pip tensorflow < 2.5.3 2.5.3
pip tensorflow >= 2.6.0, < 2.6.3 2.6.3
pip tensorflow = 2.7.0 2.7.1
pip tensorflow-cpu < 2.5.3 2.5.3
pip tensorflow-cpu >= 2.6.0, < 2.6.3 2.6.3
pip tensorflow-cpu = 2.7.0 2.7.1
pip tensorflow-gpu < 2.5.3 2.5.3
pip tensorflow-gpu >= 2.6.0, < 2.6.3 2.6.3
pip tensorflow-gpu = 2.7.0 2.7.1

References

cvelogic Threat Intelligence