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

- Severity: Medium (rating, scored by GitHub)
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2020-05-07T12:00:00.000Z
- Modified: 2023-11-08T04:17:08.031Z
- Also known as: RUSTSEC-2020-0161

## Description

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.

(As written by GitHub Advisory Database.)

## Affected

- array-macro (crates.io): from 0.1.2 before 1.0.5

## References

- <https://github.com/xfix/array-macro/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d> (web)
- <https://github.com/rustsec/advisory-db/blob/main/crates/array-macro/RUSTSEC-2020-0161.md> (web)
- <https://github.com/xfix/array-macro> (package)
- <https://gitlab.com/KonradBorowski/array-macro/-/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d> (web)
- <https://rustsec.org/advisories/RUSTSEC-2020-0161.html> (advisory, web)
- <https://crates.io/crates/array-macro> (package)

## Sources

- GitHub Advisory Database: [GHSA-83gg-pwxf-jr89](https://github.com/advisories/GHSA-83gg-pwxf-jr89), CC-BY-4.0, modified 2023-11-08
- RustSec Advisory Database: [RUSTSEC-2020-0161](https://rustsec.org/advisories/RUSTSEC-2020-0161.html), CC0-1.0, modified 2023-11-08

---

Page: https://cve.day/GHSA-83gg-pwxf-jr89 · Whole record: https://cve.day/GHSA-83gg-pwxf-jr89.json · Rebuilt by cve.day 2026-11-25T22:56:43.008Z
