CVE-2020-15207
Out-of-bounds access in TensorFlow Lite (before versions 1.15.4, 2.0.3, 2.1.2, 2.2.1, and 2.3.1)
- CVSS 9.0
- CWE-787
- Memory Corruption
- Remote
In tensorflow-lite before versions 1.15.4, 2.0.3, 2.1.2, 2.2.1 and 2.3.1, to mimic Python's indexing with negative values, TFLite uses `ResolveAxis` to convert negative values to positive indices. However, the only check that the converted index is now valid is only present in debug builds. If the `DCHECK` does not trigger, then code execution moves ahead with a negative index. This, in turn, results in accessing data out of bounds which results in segfaults and/or data corruption. The issue is patched in commit 2d88f470dea2671b430884260f3626b1fe99830a, and is released in TensorFlow versions 1.15.4, 2.0.3, 2.1.2, 2.2.1, or 2.3.1.
- CWE
- CWE-787
- CVSS base score
- 9.0
- Published
- 2020-09-25
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Memory Corruption
- Subcategory
- Out-of-Bound Accesses
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- TensorFlow
- Fixed by upgrading
- Yes
Solution
Update to TensorFlow version 1.15.4, 2.0.3, 2.1.2, 2.2.1, or 2.3.1 or higher
Vulnerable code sample
import tensorflow as tf
def demonstrate_cve(tensor_shape):
tensor = tf.zeros(tensor_shape)
indices = tf.constant([[-1]])
try:
result = tf.gather_nd(tensor, indices)
print("Result:", result)
except Exception as e:
print("Exception:", e)
tensor_shape = [3, 4, 5]
demonstrate_cve(tensor_shape)Patched code sample
import tensorflow as tf
def demonstrate_cve(tensor_shape):
tensor = tf.zeros(tensor_shape)
def check_axis(axis, tensor_shape):
if axis < 0:
axis += len(tensor_shape)
if axis < 0 or axis >= len(tensor_shape):
raise ValueError(f"Axis {axis} is out of bounds for tensor with shape {tensor_shape}")
return axis
indices = tf.constant([[-1]])
resolved_axis = check_axis(indices[0][0], tensor_shape)
indices = tf.constant([[resolved_axis]])
try:
result = tf.gather_nd(tensor, indices)
print("Result:", result)
except Exception as e:
print("Exception:", e)
tensor_shape = [3, 4, 5]
demonstrate_cve(tensor_shape)Cite this entry
@misc{vaitp:cve202015207,
title = {{Out-of-bounds access in TensorFlow Lite (before versions 1.15.4, 2.0.3, 2.1.2, 2.2.1, and 2.3.1)}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-15207},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-15207/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
