Skip to content

GHSA-rjjg-hgv6-h69v BIT-tensorflow-2020-15193 CVE-2020-15193 PYSEC-2020-116 PYSEC-2020-273 PYSEC-2020-308

Memory corruption in Tensorflow

High PyPI
Severity
0.0 / 10
High · CVSS 4.0
Exploit chance (EPSS)
0.83%
Chance of exploitation in the next 30 days. Higher than 57.57% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-908 Use of Uninitialized Resource
Fix
Available
3 packages have a fixed version

Description

Impact

The implementation of dlpack.to_dlpack can be made to use uninitialized memory resulting in further memory corruption. This is because the pybind11 glue code assumes that the argument is a tensor: https://github.com/tensorflow/tensorflow/blob/0e68f4d3295eb0281a517c3662f6698992b7b2cf/tensorflow/python/tfe_wrapper.cc#L1361

However, there is nothing stopping users from passing in a Python object instead of a tensor.

In [2]: tf.experimental.dlpack.to_dlpack([2])                                                                                                                                            
==1720623==WARNING: MemorySanitizer: use-of-uninitialized-value                                                                                                                            
    #0 0x55b0ba5c410a in tensorflow::(anonymous namespace)::GetTensorFromHandle(TFE_TensorHandle*, TF_Status*) third_party/tensorflow/c/eager/dlpack.cc:46:7
    #1 0x55b0ba5c38f4 in tensorflow::TFE_HandleToDLPack(TFE_TensorHandle*, TF_Status*) third_party/tensorflow/c/eager/dlpack.cc:252:26
... 

The uninitialized memory address is due to a reinterpret_cast https://github.com/tensorflow/tensorflow/blob/0e68f4d3295eb0281a517c3662f6698992b7b2cf/tensorflow/python/eager/pywrap_tensor.cc#L848-L850

Since the PyObject is a Python object, not a TensorFlow Tensor, the cast to EagerTensor fails.

Patches

We have patched the issue in 22e07fb204386768e5bcbea563641ea11f96ceb8 and will release a patch release for all affected versions.

We recommend users to upgrade to TensorFlow 2.2.1 or 2.3.1.

For more information

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

Attribution

This vulnerability has been reported by members of the Aivul Team from Qihoo 360.

Affected versions

PyPI

PackageVulnerableFixed in
tensorflow
>= 2.2.0, < 2.2.1
2.2.1
tensorflow
>= 2.3.0, < 2.3.1
2.3.1
tensorflow
< 2.2.1
>= 2.3.0rc0, < 2.3.1
2.2.1
2.3.1
tensorflow-cpu
>= 2.2.0, < 2.2.1
2.2.1
tensorflow-cpu
>= 2.3.0, < 2.3.1
2.3.1
tensorflow-cpu
< 2.2.1
>= 2.3.0rc0, < 2.3.1
2.2.1
2.3.1
tensorflow-gpu
>= 2.2.0, < 2.2.1
2.2.1
tensorflow-gpu
>= 2.3.0, < 2.3.1
2.3.1
tensorflow-gpu
< 2.2.1
>= 2.3.0rc0, < 2.3.1
2.2.1
2.3.1

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

tensorflow PyPI → 2.2.1

pip
pip install --upgrade "tensorflow>=2.2.1"
poetry
poetry add "tensorflow>=2.2.1"
uv
uv add "tensorflow>=2.2.1"

tensorflow-cpu PyPI → 2.2.1

pip
pip install --upgrade "tensorflow-cpu>=2.2.1"
poetry
poetry add "tensorflow-cpu>=2.2.1"
uv
uv add "tensorflow-cpu>=2.2.1"

tensorflow-gpu PyPI → 2.2.1

pip
pip install --upgrade "tensorflow-gpu>=2.2.1"
poetry
poetry add "tensorflow-gpu>=2.2.1"
uv
uv add "tensorflow-gpu>=2.2.1"

Severity breakdown

CVSS 4.0 0.0

CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N

Attack vector
Network
Attack complexity
Low
Attack requirements
None
Privileges required
Low
User interaction
None
Confidentiality (vulnerable system)
None
Integrity (vulnerable system)
High
Availability (vulnerable system)
Low
Confidentiality (subsequent systems)
None
Integrity (subsequent systems)
None
Availability (subsequent systems)
None

CVSS 3.1 7.1

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
Low

Weakness

CWE-908: Use of Uninitialized Resource

The product uses or accesses a resource that has not been initialized.

How to prevent it
  • Implementation: Explicitly initialize the resource before use. If this is performed through an API function or standard procedure, follow all required steps.
  • Implementation: Pay close attention to complex conditionals that affect initialization, since some branches might not perform the initialization.
  • Implementation: Avoid race conditions (CWE-362) during initialization routines.
  • Build and Compilation: Run or compile the product with settings that generate warnings about uninitialized variables or data.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-gjh7-xx4r-x345
TensorFlow has segfault in array_ops.upper_bound
High Also affects tensorflow
GHSA-fxgc-95xx-grvq
TensorFlow Denial of Service vulnerability
Medium Also affects tensorflow
GHSA-93vr-9q9m-pj8p
TensorFlow vulnerable to Out-of-Bounds Read in DynamicStitch
High Also affects tensorflow
GHSA-qjqc-vqcf-5qvj
TensorFlow vulnerable to seg fault in `tf.raw_ops.Print`
High Also affects tensorflow
GHSA-7jvm-xxmr-v5cw
TensorFlow vulnerable to integer overflow in EditDistance
High Also affects tensorflow
GHSA-64jg-wjww-7c5w
TensorFlow has Null Pointer Error in TensorArrayConcatV2
High Also affects tensorflow
GHSA-6hg6-5c2q-7rcr
TensorFlow has Heap-buffer-overflow in AvgPoolGrad
High Also affects tensorflow
GHSA-558h-mq8x-7q9g
TensorFlow has Null Pointer Error in SparseSparseMaximum
High Also affects tensorflow
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor