GHSA-83gg-pwxf-jr89: Array macro `array!` Macro Is Unsound Vulnerability
MODERATEGHSA-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
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.
Upgrade array-macro to 1.0.5
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
GHSA-83gg-pwxf-jr89 Affected Array macro Versions
1 component(s)| 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?
Which Array macro versions are affected?
What version fixes GHSA-83gg-pwxf-jr89?
Is array-macro affected?
What CWE is associated with GHSA-83gg-pwxf-jr89?
How can I check crates.io dependencies for GHSA-83gg-pwxf-jr89?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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
}
}