GHSA-83gg-pwxf-jr89: Array macro `array!` Macro Is Unsound Vulnerability

MODERATE
Published
Advisory Summary

GHSA-83gg-pwxf-jr89 is a MODERATE `array!` macro is unsound vulnerability (General Security Weakness) affecting Array macro libraries in the crates.io ecosystem. The issue involves `array!` macro is unsound in presence of traits that implement methods it calls internally. Remediation is available by upgrading affected packages to version 1.0.5.

GHSA-83gg-pwxf-jr89 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-83gg-pwxf-jr89
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Array macro
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-83gg-pwxf-jr89

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

array-macro fixed: 1.0.5
Upgrade array-macro to 1.0.5
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 array-macro

How to Check if You Are Affected

To determine whether your application is affected by GHSA-83gg-pwxf-jr89, inspect your project dependencies for Array macro:

inspect dependencies for array-macro

Analyze the terminal output to locate any version of Array macro in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.5), 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 General Security Weakness. In Array macro, 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

Affected versions of this crate called some methods using auto-ref. The affected code looked like this. ```rust let mut arr = $crate::__core::mem::MaybeUninit::uninit(); let mut vec = $crate::__ArrayVec::<T>::new(arr.as_mut_ptr() as *mut T); ``` In this case, the problem is that `as_mut_ptr` is a method of `&mut MaybeUninit`, not `MaybeUninit`. This made it possible for traits to hijack the method calls in order to cause unsoundness. ```rust trait AsMutPtr<T> { fn as_mut_ptr(&self) -> *mut T; } impl<T> AsMutPtr<T> for std::mem::MaybeUninit<T> { fn as_mut_ptr(&self) -> *mut T { std::ptr::null_mut() } } array![0; 1]; ``` The flaw was corrected by explicitly referencing variables in macro body in order to avoid auto-ref.

GHSA-83gg-pwxf-jr89 Affected Array macro Versions

1 component(s)
Fixed Versions:
1.0.5
Product / Package Ecosystem Affected Versions Fixed Version
array-macro
crates.io
≥ 0.1.2
< 1.0.5
1.0.5

References

Frequently Asked Questions

What is GHSA-83gg-pwxf-jr89?
GHSA-83gg-pwxf-jr89 is a security vulnerability in Array macro involving `array!` macro is unsound in presence of traits that implement methods it calls internally under General Security Weakness.
Which Array macro versions are affected?
Affected versions include releases prior to 1.0.5 across affected packages: array-macro.
What version fixes GHSA-83gg-pwxf-jr89?
Upgrading to 1.0.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is array-macro affected?
Yes, array-macro is affected in releases prior to 1.0.5. Upgrade your dependency to 1.0.5 or later.
What CWE is associated with GHSA-83gg-pwxf-jr89?
GHSA-83gg-pwxf-jr89 is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-83gg-pwxf-jr89?
Run the dependency tree command: 'inspect dependencies for array-macro'. 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-83gg-pwxf-jr89",
  "modified" : "2022-06-20T18:27:06Z",
  "published" : "2022-06-16T23:40:19Z",
  "aliases" : [ ],
  "summary" : "`array!` macro is unsound in presence of traits that implement methods it calls internally",
  "details" : "Affected versions of this crate called some methods using auto-ref. The affected code looked like this.\n\n```rust\nlet mut arr = $crate::__core::mem::MaybeUninit::uninit();\nlet mut vec = $crate::__ArrayVec::<T>::new(arr.as_mut_ptr() as *mut T);\n```\n\nIn this case, the problem is that `as_mut_ptr` is a method of `&mut MaybeUninit`, not `MaybeUninit`. This made it possible for traits to hijack the method calls in order to cause unsoundness.\n\n```rust\ntrait AsMutPtr<T> {\n    fn as_mut_ptr(&self) -> *mut T;\n}\nimpl<T> AsMutPtr<T> for std::mem::MaybeUninit<T> {\n    fn as_mut_ptr(&self) -> *mut T {\n        std::ptr::null_mut()\n    }\n}\narray![0; 1];\n```\n\nThe flaw was corrected by explicitly referencing variables in macro body in order to avoid auto-ref.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "array-macro"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.2"
      }, {
        "fixed" : "1.0.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/xfix/array-macro/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustsec/advisory-db/blob/main/crates/array-macro/RUSTSEC-2020-0161.md"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/xfix/array-macro"
  }, {
    "type" : "WEB",
    "url" : "https://gitlab.com/KonradBorowski/array-macro/-/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2020-0161.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-16T23:40:19Z",
    "nvd_published_at" : null
  }
}