Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. array-macro
  4. ›
  5. GHSA-83gg-pwxf-jr89

GHSA-83gg-pwxf-jr89: `array!` macro is unsound in presence of traits that implement methods it calls internally

June 16, 2022 (updated June 20, 2022)

Affected versions of this crate called some methods using auto-ref. The affected code looked like this.

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.

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.

References

  • github.com/advisories/GHSA-83gg-pwxf-jr89
  • github.com/rustsec/advisory-db/blob/main/crates/array-macro/RUSTSEC-2020-0161.md
  • github.com/xfix/array-macro
  • github.com/xfix/array-macro/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d
  • gitlab.com/KonradBorowski/array-macro/-/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d
  • rustsec.org/advisories/RUSTSEC-2020-0161.html

Code Behaviors & Features

Detect and mitigate GHSA-83gg-pwxf-jr89 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions starting from 0.1.2 before 1.0.5

Fixed versions

  • 1.0.5

Solution

Upgrade to version 1.0.5 or above.

Source file

cargo/array-macro/GHSA-83gg-pwxf-jr89.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:16:20 +0000.