CVE-2022-41909
TensorFlow segfaults in tf.raw_ops.CompositeTensorVariantToComponents due to an invalid input
- CVSS 7.5
- CWE-476
- Input Validation and Sanitization
- Local
TensorFlow is an open source platform for machine learning. An input `encoded` that is not a valid `CompositeTensorVariant` tensor will trigger a segfault in `tf.raw_ops.CompositeTensorVariantToComponents`. We have patched the issue in GitHub commits bf594d08d377dc6a3354d9fdb494b32d45f91971 and 660ce5a89eb6766834bdc303d2ab3902aef99d3d. The fix will be included in TensorFlow 2.11. We will also cherrypick this commit on TensorFlow 2.10.1, 2.9.3, and TensorFlow 2.8.4, as these are also affected and still in supported range.
- CWE
- CWE-476
- CVSS base score
- 7.5
- Published
- 2022-11-18
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- TensorFlow
- Fixed by upgrading
- Yes
Solution
Update TensorFlow to version 2.11 or later.
Vulnerable code sample
import tensorflow as tf
# This function demonstrates the vulnerability by directly calling the raw op
def trigger_vulnerability(encoded):
# If 'encoded' is not a valid CompositeTensorVariant, this may cause a segfault
return tf.raw_ops.CompositeTensorVariantToComponents(encoded)
# Example usage with an invalid input
# Here, we intentionally pass an invalid tensor type
invalid_encoded = tf.constant([1, 2, 3]) # Not a CompositeTensorVariant
components = trigger_vulnerability(invalid_encoded) # This could trigger a segfaultPatched code sample
import tensorflow as tf
def safe_composite_tensor_variant_to_components(encoded):
if not isinstance(encoded, tf.Tensor) or encoded.dtype != tf.variant:
raise ValueError("Input must be a valid CompositeTensorVariant tensor.")
return tf.raw_ops.CompositeTensorVariantToComponents(encoded)
# Example usage
try:
# This will raise an error if 'encoded' is not a valid CompositeTensorVariant
components = safe_composite_tensor_variant_to_components(encoded)
except ValueError as e:
print(e)Cite this entry
@misc{vaitp:cve202241909,
title = {{TensorFlow segfaults in tf.raw_ops.CompositeTensorVariantToComponents due to an invalid input}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-41909},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-41909/}}
}
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 ::
