Skip to main content

CVE-2022-36086: CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer in rust-osdev linked-list-allocator

Medium
Published: Wed Sep 07 2022 (09/07/2022, 22:50:09 UTC)
Source: CVE
Vendor/Project: rust-osdev
Product: linked-list-allocator

Description

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>()`.

AI-Powered Analysis

AILast updated: 06/21/2025, 23:36:53 UTC

Technical Analysis

CVE-2022-36086 is a medium-severity vulnerability affecting the rust-osdev project's linked-list-allocator library, specifically versions prior to 0.10.2. The linked-list-allocator is a memory allocator designed for no_std Rust environments, commonly used in embedded systems and operating system development where the standard library is unavailable. The vulnerability arises from improper bounds checking during heap initialization and extension operations. Specifically, the heap initialization methods (Heap::new, Heap::init, Heap::init_from_slice, and LockedHeap::new) do not enforce a minimum heap size check, allowing initialization with a heap size smaller than three times the size of a usize type. This leads to out-of-bounds writes when metadata is written beyond the allocated heap buffer. Similarly, the Heap::extend method can be misused with sizes smaller than twice the size of usize, causing similar memory corruption issues. These out-of-bounds writes can corrupt adjacent memory, potentially leading to undefined behavior, data corruption, or program crashes. The vulnerability is rooted in CWE-119 (Improper Restriction of Operations within the Bounds of a Memory Buffer) and CWE-787 (Out-of-Bounds Write). The issue was patched in version 0.10.2 of linked-list-allocator. Workarounds include enforcing minimum heap sizes during initialization and extension and ensuring the total heap size remains a multiple of twice the size of usize. No known exploits have been reported in the wild to date. This vulnerability primarily affects embedded and OS development projects using Rust's linked-list-allocator in no_std contexts, which may include IoT devices, firmware, and specialized hardware systems.

Potential Impact

For European organizations, the impact of this vulnerability depends largely on the adoption of Rust-based embedded systems and no_std environments in critical infrastructure, industrial control systems, and IoT deployments. Out-of-bounds writes can lead to memory corruption, causing system instability, crashes, or potential escalation to arbitrary code execution if exploited in a targeted manner. This could disrupt operations in sectors relying on embedded Rust code, such as manufacturing automation, automotive systems, telecommunications infrastructure, and smart city deployments. Given the allocator’s use in low-level system components, exploitation could compromise device integrity and availability, potentially affecting safety-critical systems. While no exploits are currently known, the vulnerability poses a risk to the integrity and availability of embedded devices, which could cascade into operational disruptions or safety hazards. European organizations with supply chains or products incorporating Rust no_std components should assess their exposure. The vulnerability is less likely to impact traditional IT infrastructure but is significant for embedded and firmware security.

Mitigation Recommendations

1. Upgrade linked-list-allocator to version 0.10.2 or later, which contains the official patch addressing the heap size validation issues. 2. For projects unable to upgrade immediately, implement strict validation to ensure heap initialization sizes exceed three times the size of usize and that Heap::extend calls use sizes larger than twice the size of usize. 3. Enforce that total heap sizes are multiples of twice the size of usize to maintain allocator invariants. 4. Conduct thorough code audits of embedded Rust projects using linked-list-allocator to identify unsafe heap initializations or extensions. 5. Implement runtime checks or assertions in development builds to detect improper heap sizes early. 6. For critical embedded devices, consider additional memory protection mechanisms such as MPU (Memory Protection Unit) configurations to limit the impact of out-of-bounds writes. 7. Monitor Rust ecosystem advisories and update dependencies regularly to incorporate security fixes. 8. Engage with hardware and firmware vendors to confirm whether their products use vulnerable versions and request patches or mitigations if applicable.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-07-15T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9849c4522896dcbf6911

Added to database: 5/21/2025, 9:09:29 AM

Last enriched: 6/21/2025, 11:36:53 PM

Last updated: 8/15/2025, 8:40:19 AM

Views: 17

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats