CVE-2022-29205
Segfault/DoS vulnerability pre-2.9.0 TensorFlow due to unsupported quantized types in tf.compat.v1 ops
- CVSS 5.5
- CWE-476 NULL Pointer Dereference
- Cryptographic
- Remote
TensorFlow is an open source platform for machine learning. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, there is a potential for segfault / denial of service in TensorFlow by calling `tf.compat.v1.*` ops which don't yet have support for quantized types, which was added after migration to TensorFlow 2.x. In these scenarios, since the kernel is missing, a `nullptr` value is passed to `ParseDimensionValue` for the `py_value` argument. Then, this is dereferenced, resulting in segfault. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue.
- CVSS base score
- 5.5
- Published
- 2022-05-20
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Cryptographic
- Subcategory
- Unencrypted communication
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- TensorFlow
- Fixed by upgrading
- Yes
Solution
Update TensorFlow to version 2.9.0, 2.8.1, 2.7.2, or 2.6.4.
Vulnerable code sample
import tensorflow as tf
# This code demonstrates the potential vulnerability before it was fixed.
# WARNING: Running this code may lead to a segmentation fault or crash.
# Ensure you are using a version of TensorFlow that is vulnerable (prior to 2.9.0, 2.8.1, 2.7.2, or 2.6.4).
# Disabling eager execution to simulate the conditions of the vulnerability
tf.compat.v1.disable_eager_execution()
# Attempting to use a quantized operation that does not support quantized types
# This is where the vulnerability can occur
quantized_tensor = tf.compat.v1.quantize(tf.constant([1.0, 2.0]), min_range=0.0, max_range=3.0, T=tf.quint8)
print(quantized_tensor)Patched code sample
import tensorflow as tf
# Example of using a TensorFlow operation that could lead to the vulnerability
# This code is intended to demonstrate the potential vulnerability and should not be run.
# In practice, ensure you are using a patched version of TensorFlow (>= 2.9.0, 2.8.1, 2.7.2, or 2.6.4).
# Using an old version of TensorFlow (before the patch)
# tf.compat.v1.disable_eager_execution() # Uncommenting this line could lead to the vulnerability
# Example operation that could trigger the vulnerability
# quantized_tensor = tf.compat.v1.quantize(tf.constant([1.0, 2.0]), min_range=0.0, max_range=3.0, T=tf.quint8)
# Instead, use a patched version of TensorFlow and avoid using incompatible ops
# Ensure TensorFlow is updated to a version that addresses CVE-2022-29205
# Example of a safe operation in updated TensorFlow
quantized_tensor = tf.quantization.quantize(tf.constant([1.0, 2.0]), min_range=0.0, max_range=3.0, T=tf.quint8)
print(quantized_tensor)Cite this entry
@misc{vaitp:cve202229205,
title = {{Segfault/DoS vulnerability pre-2.9.0 TensorFlow due to unsupported quantized types in tf.compat.v1 ops}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-29205},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-29205/}}
}
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 ::
