CVE-2021-29572
TensorFlow SdcaOptimizer null pointer dereference
- CVSS 5.5
- CWE-476 NULL Pointer Dereference
- Cryptographic
- Remote
TensorFlow is an end-to-end open source platform for machine learning. The implementation of `tf.raw_ops.SdcaOptimizer` triggers undefined behavior due to dereferencing a null pointer. The implementation(https://github.com/tensorflow/tensorflow/blob/60a45c8b6192a4699f2e2709a2645a751d435cc3/tensorflow/core/kernels/sdca_internal.cc) does not validate that the user supplied arguments satisfy all constraints expected by the op(https://www.tensorflow.org/api_docs/python/tf/raw_ops/SdcaOptimizer). The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.
- CVSS base score
- 5.5
- Published
- 2021-05-14
- 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.5.0 or higher.
Vulnerable code sample
import tensorflow as tf
def sdca_optimizer():
# VULNERABLE: This code is susceptible to command injection
try:
optimizer = tf.raw_ops.SdcaOptimizer(
sparse_example_indices=[],
sparse_feature_indices=[],
sparse_feature_values=[],
dense_features=[],
example_weights=[],
example_labels=[],
sparse_indices=[],
sparse_weights=[],
dense_weights=[],
example_state_data=[],
loss_type="logistic_loss",
l1=0.01,
l2=0.01,
num_loss_partitions=1,
num_inner_iterations=1,
dual_coefficients=None,
primal_loss=None
)
print("Executed function without crash")
except Exception as e:
print(f"TensorFlow Error: {e}")
sdca_optimizer()Patched code sample
import tensorflow as tf
def sdca_optimizer():
# SECURE: This version prevents command injection
try:
optimizer = tf.raw_ops.SdcaOptimizer(
sparse_example_indices=[],
sparse_feature_indices=[],
sparse_feature_values=[],
dense_features=[],
example_weights=[],
example_labels=[],
sparse_indices=[],
sparse_weights=[],
dense_weights=[],
example_state_data=[],
loss_type="logistic_loss",
l1=0.01,
l2=0.01,
num_loss_partitions=1,
num_inner_iterations=1,
dual_coefficients=[],
primal_loss=[]
)
print("Executed function successfully")
except Exception as e:
print(f"TensorFlow Error: {e}")
sdca_optimizer()Cite this entry
@misc{vaitp:cve202129572,
title = {{TensorFlow SdcaOptimizer null pointer dereference}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2021},
note = {VAITP Python Vulnerability Dataset, entry CVE-2021-29572},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-29572/}}
}
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 ::
