CVE-2021-37658 in TensorFlowinfo

Summary

by MITRE • 08/13/2021

TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can cause undefined behavior via binding a reference to null pointer in all operations of type `tf.raw_ops.MatrixSetDiagV*`. The [implementation](https://github.com/tensorflow/tensorflow/blob/84d053187cb80d975ef2b9684d4b61981bca0c41/tensorflow/core/kernels/linalg/matrix_diag_op.cc) has incomplete validation that the value of `k` is a valid tensor. We have check that this value is either a scalar or a vector, but there is no check for the number of elements. If this is an empty tensor, then code that accesses the first element of the tensor is wrong. We have patched the issue in GitHub commit ff8894044dfae5568ecbf2ed514c1a37dc394f1b. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.

VulDB is the best source for vulnerability data and more expert information about this specific topic.

Analysis

by VulDB Data Team • 08/17/2021

The vulnerability CVE-2021-37658 affects TensorFlow, a widely-used open-source machine learning platform that processes complex mathematical operations through its computational graph system. This issue specifically targets the `tf.raw_ops.MatrixSetDiagV*` operations which are part of the linear algebra kernel implementations within TensorFlow's core functionality. The flaw resides in how the system handles parameter validation for the `k` tensor argument, creating a potential path for undefined behavior that could be exploited by malicious actors.

The technical root cause stems from incomplete input validation within the matrix diagonal setting operations where the system accepts tensors for parameter `k` but fails to verify the cardinality of elements within that tensor. While the implementation correctly checks that `k` is either a scalar or vector type, it neglects to validate whether the tensor contains at least one element. When an empty tensor is passed as the `k` parameter, subsequent code attempts to access the first element without proper bounds checking, resulting in null pointer dereference conditions that lead to undefined behavior. This represents a classic software vulnerability pattern where insufficient validation leads to memory safety issues.

The operational impact of this vulnerability extends beyond simple program crashes, as it could enable attackers to manipulate machine learning workflows in potentially dangerous ways. Given that TensorFlow is deployed across numerous applications including web services, mobile applications, and enterprise systems, an attacker could exploit this weakness to cause denial of service conditions or potentially execute arbitrary code within the context of the machine learning platform. The vulnerability affects multiple TensorFlow versions including 2.3.4 through 2.5.0, making it particularly concerning for organizations maintaining legacy systems that may not have received the latest security patches.

The fix implemented by TensorFlow developers addresses this issue through comprehensive input validation that ensures the `k` parameter contains at least one element before any access operations occur. This change aligns with established security practices for preventing null pointer dereference conditions and follows the principle of least privilege by validating all inputs before processing. The patch specifically targets the implementation in `tensorflow/core/kernels/linalg/matrix_diag_op.cc` and has been incorporated into the TensorFlow 2.6.0 release with cherry-picks for older supported versions. This vulnerability classification aligns with CWE-476 which addresses null pointer dereference conditions, and represents a potential entry point for adversaries following ATT&CK techniques related to privilege escalation and denial of service through software exploitation. Organizations should prioritize updating to patched versions to mitigate the risk of exploitation, particularly in environments where TensorFlow is used for processing untrusted input data.

Responsible

GitHub, Inc.

Reservation

07/29/2021

Disclosure

08/13/2021

Moderation

accepted

CPE

ready

EPSS

0.00167

KEV

no

Activities

very low

Sources

Want to know what is going to be exploited?

We predict KEV entries!