CVE-2021-37645 in TensorFlowinfo

Summary

by MITRE • 08/13/2021

TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation of `tf.raw_ops.QuantizeAndDequantizeV4Grad` is vulnerable to an integer overflow issue caused by converting a signed integer value to an unsigned one and then allocating memory based on this value. The [implementation](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/quantize_and_dequantize_op.cc#L126) uses the `axis` value as the size argument to `absl::InlinedVector` constructor. But, the constructor uses an unsigned type for the argument, so the implicit conversion transforms the negative value to a large integer. We have patched the issue in GitHub commit 96f364a1ca3009f98980021c4b32be5fdcca33a1. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, and TensorFlow 2.4.3, as these are also affected and still in supported range.

If you want to get best quality of vulnerability data, you may have to visit VulDB.

Analysis

by VulDB Data Team • 08/17/2021

The vulnerability identified as CVE-2021-37645 affects TensorFlow, a widely-used open-source machine learning platform that processes and analyzes large datasets through complex neural network operations. This particular flaw resides within the `tf.raw_ops.QuantizeAndDequantizeV4Grad` implementation, which handles gradient computations for quantization and dequantization operations commonly employed in model optimization. The issue represents a critical security concern that could potentially enable attackers to manipulate memory allocation behaviors within TensorFlow's computational graph processing.

The technical root cause of this vulnerability stems from an integer overflow condition that occurs during type conversion between signed and unsigned integer representations. Specifically, the implementation utilizes the `axis` parameter value as a size argument for constructing an `absl::InlinedVector` object, where the constructor expects an unsigned integer type parameter. When a negative `axis` value is passed, the implicit conversion to unsigned type transforms this negative value into an extremely large positive integer, leading to unintended memory allocation behavior. This conversion process violates fundamental principles of integer arithmetic and type safety, creating a scenario where memory allocation requests could exceed system limits or cause unexpected program behavior.

The operational impact of this vulnerability extends beyond simple memory corruption, potentially enabling remote code execution or denial of service conditions within systems that process machine learning workloads through TensorFlow. Attackers could exploit this weakness by crafting malicious inputs that trigger the problematic code path with negative axis values, causing the system to allocate excessive memory or potentially overwrite adjacent memory regions. This type of vulnerability aligns with CWE-190, which describes integer overflow conditions that can lead to memory corruption, and represents a significant risk in environments where TensorFlow processes untrusted data inputs or where attackers might attempt to manipulate model parameters.

The fix implemented by the TensorFlow team addresses this vulnerability through a targeted code modification that prevents the problematic type conversion from occurring. The patch ensures proper validation of input parameters before they are used in memory allocation operations, specifically by checking for negative values that would cause the unsigned conversion issue. This remediation approach follows established security practices for preventing integer overflow vulnerabilities and aligns with ATT&CK technique T1059.001, which covers the use of command and scripting interpreters to execute malicious code. The vulnerability affects TensorFlow versions 2.4.0 through 2.5.0, with the fix being incorporated into the upcoming TensorFlow 2.6.0 release and backported to the supported 2.5.1 and 2.4.3 versions to ensure broader protection across the supported release lifecycle.

Responsible

GitHub, Inc.

Reservation

07/29/2021

Disclosure

08/13/2021

Moderation

accepted

CPE

ready

EPSS

0.00152

KEV

no

Activities

very low

Sources

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!