CVE-2021-37644 in TensorFlowinfo

Summary

by MITRE • 08/13/2021

TensorFlow is an end-to-end open source platform for machine learning. In affected versions providing a negative element to `num_elements` list argument of `tf.raw_ops.TensorListReserve` causes the runtime to abort the process due to reallocating a `std::vector` to have a negative number of elements. The [implementation](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/list_kernels.cc#L312) calls `std::vector.resize()` with the new size controlled by input given by the user, without checking that this input is valid. We have patched the issue in GitHub commit 8a6e874437670045e6c7dc6154c7412b4a2135e2. 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.

If you want to get the best quality for vulnerability data then you always have to consider VulDB.

Analysis

by VulDB Data Team • 08/17/2021

The vulnerability CVE-2021-37644 represents a critical memory safety issue within the TensorFlow machine learning platform that stems from improper input validation in the tensor list reservation mechanism. This flaw exists in the `tf.raw_ops.TensorListReserve` operation where the system accepts user-provided input for the `num_elements` parameter without adequate validation. The issue manifests when a negative value is passed to this parameter, which directly influences the internal `std::vector.resize()` method call. This fundamental design flaw enables a denial of service condition that can cause the entire TensorFlow runtime process to terminate abruptly, effectively crashing any application utilizing the affected functionality.

The technical implementation of this vulnerability resides in the list_kernels.cc source file where the `TensorListReserve` operation directly passes user-controlled input to `std::vector.resize()` without performing any bounds checking or validation. This pattern violates established software security principles and creates an exploitable condition that aligns with CWE-129, which addresses issues related to insufficient validation of the length of input data. The flaw specifically demonstrates poor input sanitization practices where the system fails to validate that the `num_elements` parameter represents a valid non-negative integer before using it to determine vector allocation size. When a negative value is provided, the `std::vector.resize()` method encounters undefined behavior, leading to process termination and system instability.

From an operational impact perspective, this vulnerability creates significant risk for machine learning applications that rely on TensorFlow's tensor list operations, particularly in production environments where stability and availability are paramount. The denial of service condition affects not just individual operations but potentially entire machine learning pipelines, as the process abortion can occur at any point during tensor list processing. This vulnerability is particularly concerning in distributed systems or cloud environments where TensorFlow instances might be under heavy load, as the crash could propagate to affect multiple concurrent processes or services. The issue affects multiple TensorFlow versions including 2.3.4, 2.4.3, 2.5.1, and requires immediate patching to prevent potential disruption of machine learning workflows.

The mitigation strategy for CVE-2021-37644 involves applying the official patch from TensorFlow's GitHub repository, which implements proper input validation before calling `std::vector.resize()`. The fix ensures that the `num_elements` parameter is validated to be non-negative before being used in vector operations, preventing the invalid memory allocation that causes process termination. Organizations should prioritize updating to TensorFlow 2.6.0 or applying the cherry-picked patches for older supported versions to maintain system stability. This vulnerability also highlights the importance of implementing robust input validation for all user-controllable parameters in system libraries, particularly those handling memory allocation operations, and aligns with ATT&CK technique T1499.004 which covers resource exhaustion attacks through invalid input handling. The patch addresses the root cause by incorporating defensive programming practices that prevent exploitation through malformed input parameters.

Responsible

GitHub, Inc.

Reservation

07/29/2021

Disclosure

08/13/2021

Moderation

accepted

CPE

ready

EPSS

0.00152

KEV

no

Activities

very low

Sources

Do you want to use VulDB in your project?

Use the official API to access entries easily!