CVE-2021-29539 in TensorFlowinfo

Summary

by MITRE • 05/15/2021

TensorFlow is an end-to-end open source platform for machine learning. Calling `tf.raw_ops.ImmutableConst`(https://www.tensorflow.org/api_docs/python/tf/raw_ops/ImmutableConst) with a `dtype` of `tf.resource` or `tf.variant` results in a segfault in the implementation as code assumes that the tensor contents are pure scalars. We have patched the issue in 4f663d4b8f0bec1b48da6fa091a7d29609980fa4 and will release TensorFlow 2.5.0 containing the patch. TensorFlow nightly packages after this commit will also have the issue resolved. If using `tf.raw_ops.ImmutableConst` in code, you can prevent the segfault by inserting a filter for the `dtype` argument.

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Analysis

by VulDB Data Team • 05/16/2021

The vulnerability described in CVE-2021-29539 affects TensorFlow, a widely-used open source machine learning platform that serves as the foundation for numerous artificial intelligence applications across industries. This security flaw specifically targets the tf.raw_ops.ImmutableConst operation within TensorFlow's low-level API, which is designed to create immutable constant tensors. The issue manifests when developers or applications invoke this operation with data types of tf.resource or tf.variant, creating a critical system instability that can lead to application crashes and potential denial of service conditions. The vulnerability represents a fundamental implementation flaw in TensorFlow's tensor handling mechanisms, where the code assumes all tensor contents consist of pure scalars without proper validation for complex data types.

The technical implementation flaw stems from the assumption that tensors passed to tf.raw_ops.ImmutableConst contain only scalar values, a design decision that fails to account for the complexity of tf.resource and tf.variant data types. These data types represent more sophisticated tensor structures that contain references to other tensors or variant objects, respectively, which cannot be processed using the simple scalar assumption. When the operation encounters these complex data types, the code executes memory access patterns that result in segmentation faults, causing the application to crash. This type of vulnerability falls under CWE-125, which describes out-of-bounds read conditions, and CWE-248, which covers unspecified behavior, as the implementation does not properly handle unexpected data type scenarios. The segmentation fault occurs because the memory management code attempts to access memory locations that do not correspond to scalar values, leading to invalid memory access patterns that violate the operating system's memory protection mechanisms.

The operational impact of this vulnerability extends beyond simple application crashes, as it can affect production machine learning environments where TensorFlow is deployed for critical tasks such as model inference, training pipelines, and automated decision-making systems. Attackers could potentially exploit this vulnerability to cause denial of service against TensorFlow-based applications, particularly in scenarios where user input or external data sources are processed through TensorFlow operations. The vulnerability is particularly concerning in cloud environments where TensorFlow services might be exposed to untrusted inputs, as it could enable attackers to disrupt machine learning workflows or potentially escalate privileges through memory corruption techniques. Organizations using TensorFlow for production workloads that might process external data through tf.raw_ops.ImmutableConst operations face significant risk, as the crash could result in complete service interruption and data processing failures. This vulnerability also aligns with ATT&CK technique T1499.004, which covers network disruption, and T1059.001, which involves command and script injection, as it could be leveraged to create service disruption scenarios.

The patch for this vulnerability, implemented in commit 4f663d4b8f0bec1b48da6fa091a7d29609980fa4, addresses the core issue by adding proper validation checks for the dtype parameter before processing tensor contents. The fix ensures that tf.raw_ops.ImmutableConst properly validates data types and handles tf.resource and tf.variant types appropriately, preventing the segmentation fault that would otherwise occur. Organizations should update to TensorFlow 2.5.0 or later versions that include this patch to eliminate the vulnerability. For environments where immediate updates are not feasible, developers can implement a workaround by filtering the dtype argument before calling tf.raw_ops.ImmutableConst, ensuring that only compatible data types are processed through this operation. Security teams should also consider monitoring for unusual patterns of tf.raw_ops.ImmutableConst usage in production environments, as this could indicate potential exploitation attempts or misconfigured applications that might be vulnerable to this class of memory corruption issues. The fix demonstrates proper defensive programming practices that align with security best practices for handling complex data structures in machine learning frameworks.

Responsible

GitHub, Inc.

Reservation

03/30/2021

Disclosure

05/15/2021

Moderation

accepted

CPE

ready

EPSS

0.00189

KEV

no

Activities

very low

Sources

Want to know what is going to be exploited?

We predict KEV entries!