CVE-2022-36086 in linked_list_allocatorinfo

Summary

by MITRE • 09/08/2022

linked_list_allocator is an allocator usable for no_std systems. Prior to version 0.10.2, the heap initialization methods were missing a minimum size check for the given heap size argument. This could lead to out-of-bound writes when a heap was initialized with a size smaller than `3 * size_of::<usize>` because of metadata write operations. This vulnerability impacts all the initialization functions on the `Heap` and `LockedHeap` types, including `Heap::new`, `Heap::init`, `Heap::init_from_slice`, and `LockedHeap::new`. It also affects multiple uses of the `Heap::extend` method. Version 0.10.2 contains a patch for the issue. As a workaround, ensure that the heap is only initialized with a size larger than `3 * size_of::<usize>` and that the `Heap::extend` method is only called with sizes larger than `2 * size_of::<usize>()`. Also, ensure that the total heap size is (and stays) a multiple of `2 * size_of::<usize>()`.

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

Analysis

by VulDB Data Team • 10/14/2022

The linked_list_allocator crate presents a critical memory safety vulnerability in embedded and systems programming environments where heap management operates without standard library support. This vulnerability affects versions prior to 0.10.2 and stems from inadequate validation during heap initialization processes. The flaw manifests when developers initialize heap structures with insufficient memory allocation, creating conditions where metadata operations can overwrite adjacent memory regions. The vulnerability specifically targets heap initialization functions including Heap::new, Heap::init, Heap::init_from_slice, and LockedHeap::new, along with Heap::extend method usage patterns. These functions fail to validate that the provided heap size argument meets minimum requirements necessary for proper metadata storage and allocation management.

The technical root cause of this vulnerability lies in the absence of size validation checks during heap construction phases. When heap initialization occurs with a size smaller than three times the size of a usize type, the allocator's metadata write operations can extend beyond allocated boundaries. This condition creates a classic out-of-bounds write scenario that can lead to memory corruption and potentially arbitrary code execution. The vulnerability affects not only the initial heap setup but also subsequent heap expansion operations through the extend method, amplifying the potential impact across the entire heap lifecycle. The minimum size requirement of 3 * size_of::<usize> represents the critical threshold needed to accommodate essential metadata structures required for linked list-based heap management. This specific constraint aligns with common memory allocator design principles where metadata overhead must be properly accounted for within available heap space.

The operational impact of this vulnerability extends beyond simple memory corruption to potentially enable sophisticated attack vectors in systems utilizing no_std environments. Attackers could exploit this weakness to manipulate heap metadata, leading to heap spraying techniques or memory overwrite scenarios that compromise system stability and security. The vulnerability affects embedded systems, operating system kernels, and other resource-constrained environments where linked_list_allocator is commonly deployed. The potential for privilege escalation exists when this allocator is used in kernel contexts or security-sensitive applications where heap corruption could lead to system compromise. This vulnerability demonstrates the critical importance of proper input validation in systems programming environments where memory safety is paramount.

Mitigation strategies for this vulnerability require immediate version updates to 0.10.2 or later where the patch addresses the missing size validation checks. Until patching is complete, administrators should enforce strict heap initialization parameters ensuring that all heap allocations exceed 3 size_of::<usize> minimum requirements. The Heap::extend method should only be invoked with size parameters larger than 2 size_of::<usize> to prevent similar issues during heap expansion. Additionally, maintaining heap sizes as multiples of 2 * size_of::<usize> ensures proper alignment and prevents fragmentation issues that could compound the vulnerability. This vulnerability classification aligns with CWE-129 Input Validation and CWE-787 Out-of-bounds Write categories, representing a fundamental failure in memory boundary checking. The ATT&CK framework would categorize this as a memory corruption technique where adversaries leverage insufficient input validation to manipulate heap structures and potentially achieve code execution. Organizations should implement automated dependency checking to ensure all systems using linked_list_allocator are updated to patched versions and establish security policies around heap initialization practices in no_std environments.

Responsible

GitHub, Inc.

Reservation

07/15/2022

Disclosure

09/08/2022

Moderation

accepted

CPE

ready

EPSS

0.00727

KEV

no

Activities

very low

Sources

Do you need the next level of professionalism?

Upgrade your account now!