CVE-2022-36086: Linked list allocator :extend` Vulnerability

HIGH
Advisory Identifier: GHSA-xg8p-34w2-j49j
CVSS 8.4
CWE-1284 CWE-119
Published
Advisory Summary

CVE-2022-36086 is a HIGH (CVSS 8.4) :extend` vulnerability (CWE-1284: Improper Validation of Specified Quantity in Input) affecting Linked list allocator libraries in the crates.io ecosystem. The issue involves :extend`. Remediation is available by upgrading affected packages to version 0.10.2.

CVE-2022-36086 at a Glance

CVE Identifier CVE-2022-36086
GHSA Identifier GHSA-xg8p-34w2-j49j
Severity HIGH
CVSS v3.1 Base Score 8.4
CWE Classification CWE-1284: Improper Validation of Specified Quantity in Input
Affected Product Linked list allocator
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 8.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-36086

To remediate this vulnerability, upgrade all affected Linked list allocator dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

linked_list_allocator fixed: 0.10.2
Upgrade linked_list_allocator to 0.10.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for linked_list_allocator

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-36086, inspect your project dependencies for Linked list allocator:

inspect dependencies for linked_list_allocator

Analyze the terminal output to locate any version of Linked list allocator in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.10.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1284: Improper Validation of Specified Quantity in Input, where the product receives input that is expected to specify a quantity (such as size or length), but it does not validate or incorrectly validates that the quantity has the required properties. In Linked list allocator, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Impact _What kind of vulnerability is it? Who is impacted?_ 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. ### Initialization Functions 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. ### `Heap::extend` This vulnerability impacts three specific uses of the `Heap::extend` method: - When calling `Heap::extend` with a size smaller than two `usize`s (e.g., 16 on `x86_64`), the size was erroneously rounded up to the minimum size, which could result in an **_out-of-bounds write_**. - Calling `Heap::extend` on an empty heap tried to construct a heap starting at address 0, which is also an **_out-of-bounds write_**. - One specific way to trigger this accidentally is to call `Heap::new` (or a similar constructor) with a heap size that is smaller than two `usize`s. This was treated as an empty heap as well. - Calling `Heap::extend` on a heap whose size is not a multiple of the size of two `usize`s resulted in _unaligned writes_. It also left the heap in an unexpected state, which might lead to subsequent issues. We did not find a way to exploit this undefined behavior yet (apart from DoS on platforms that fault on unaligned writes). ## Patches _Has the problem been patched? What versions should users upgrade to?_ We published a patch in version `0.10.2` and recommend all users to upgrade to it. This patch release includes the following changes: - The initialization functions now panic if the given size is not large enough to store the necessary metadata. Depending on the alignment of the heap bottom pointer, the minimum size is between `2 * size_of::<usize>` and `3 * size_of::<usize>`. - The `extend` method now panics when trying to extend an unitialized heap. - Extend calls with a size smaller than `size_of::<usize>() * 2` are now buffered internally and not added to the list directly. The buffered region will be merged with future `extend` calls. - The `size()` method now returns the _usable_ size of the heap, which might be slightly smaller than the `top() - bottom()` difference because of alignment constraints. ## Workarounds _Is there a way for users to fix or remediate the vulnerability without upgrading?_ To avoid this issue, 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>()`. ## For more information If you have any questions or comments about this advisory: * Open an issue in this repository * Email @phil-opp at [security@phil-opp.com](mailto:security@phil-opp.com) ## Acknowledgements This issue was responsibly reported by Evan Richter at ForAllSecure and found with [Mayhem](https://forallsecure.com/mayhem-for-code) and [cargo fuzz](https://github.com/rust-fuzz/cargo-fuzz).

CVE-2022-36086 Affected Linked list allocator Versions

1 component(s)
Fixed Versions:
0.10.2
Product / Package Ecosystem Affected Versions Fixed Version
linked_list_allocator
crates.io
< 0.10.2
0.10.2

References

Frequently Asked Questions

What is CVE-2022-36086?
CVE-2022-36086 is a security vulnerability in Linked list allocator involving :extend` under CWE-1284: Improper Validation of Specified Quantity in Input.
Which Linked list allocator versions are affected?
Affected versions include releases prior to 0.10.2 across affected packages: linked_list_allocator.
What version fixes CVE-2022-36086?
Upgrading to 0.10.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is linked_list_allocator affected?
Yes, linked_list_allocator is affected in releases prior to 0.10.2. Upgrade your dependency to 0.10.2 or later.
What is the CVSS score of CVE-2022-36086?
CVE-2022-36086 has a CVSS v3.1 base score of 8.4 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-36086?
CVE-2022-36086 is classified under CWE-1284: Improper Validation of Specified Quantity in Input (The product receives input that is expected to specify a quantity (such as size or length), but it does not validate or incorrectly validates that the quantity has the required properties.).
How can I check crates.io dependencies for CVE-2022-36086?
Run the dependency tree command: 'inspect dependencies for linked_list_allocator'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xg8p-34w2-j49j",
  "modified" : "2022-09-16T17:41:33Z",
  "published" : "2022-09-16T17:41:33Z",
  "aliases" : [ "CVE-2022-36086" ],
  "summary" : "linked_list_allocator vulnerable to out-of-bound writes on `Heap` initialization and `Heap::extend`",
  "details" : "## Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nThis 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.\n\n### Initialization Functions\n\nThe 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.\n\n### `Heap::extend`\n\nThis vulnerability impacts three specific uses of the `Heap::extend` method:\n\n- When calling `Heap::extend` with a size smaller than two `usize`s (e.g., 16 on `x86_64`), the size was erroneously rounded up to the minimum size, which could result in an **_out-of-bounds write_**.\n- Calling `Heap::extend` on an empty heap tried to construct a heap starting at address 0, which is also an **_out-of-bounds write_**.\n  - One specific way to trigger this accidentally is to call `Heap::new` (or a similar constructor) with a heap size that is smaller than two `usize`s. This was treated as an empty heap as well.\n- Calling `Heap::extend` on a heap whose size is not a multiple of the size of two `usize`s resulted in _unaligned writes_. It also left the heap in an unexpected state, which might lead to subsequent issues. We did not find a way to exploit this undefined behavior yet (apart from DoS on platforms that fault on unaligned writes).\n\n## Patches\n_Has the problem been patched? What versions should users upgrade to?_\n\nWe published a patch in version `0.10.2` and recommend all users to upgrade to it. This patch release includes the following changes:\n\n- The initialization functions now panic if the given size is not large enough to store the necessary metadata. Depending on the alignment of the heap bottom pointer, the minimum size is between `2 * size_of::<usize>` and `3 * size_of::<usize>`.\n- The `extend` method now panics when trying to extend an unitialized heap.\n- Extend calls with a size smaller than `size_of::<usize>() * 2` are now buffered internally and not added to the list directly. The buffered region will be merged with future `extend` calls.\n- The `size()` method now returns the _usable_ size of the heap, which might be slightly smaller than the `top() - bottom()` difference because of alignment constraints.\n\n## Workarounds\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_\n\nTo avoid this issue, 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>()`.\n\n## For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in this repository\n* Email @phil-opp at [security@phil-opp.com](mailto:security@phil-opp.com)\n\n## Acknowledgements\n\nThis issue was responsibly reported by Evan Richter at ForAllSecure and found with [Mayhem](https://forallsecure.com/mayhem-for-code) and [cargo fuzz](https://github.com/rust-fuzz/cargo-fuzz).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "linked_list_allocator"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.10.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.10.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-osdev/linked-list-allocator/security/advisories/GHSA-xg8p-34w2-j49j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-36086"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rust-osdev/linked-list-allocator/commit/013b0758643943e8df5b17bbb495460ff47e8bbf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-xg8p-34w2-j49j"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-osdev/linked-list-allocator"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2022-0063.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-119", "CWE-1284" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-09-16T17:41:33Z",
    "nvd_published_at" : "2022-09-07T23:15:00Z"
  }
}