Files
vuln-osv/data/crates.io/RUSTSEC-2020-0161.json
T

1 line
1.8 KiB
JSON

{"schema_version":"1.7.3","id":"RUSTSEC-2020-0161","published":"2020-05-07T12:00:00Z","modified":"2023-11-08T04:17:08.031225Z","aliases":["GHSA-83gg-pwxf-jr89"],"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.","affected":[{"package":{"name":"array-macro","ecosystem":"crates.io","purl":"pkg:cargo/array-macro"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0.1.2"},{"fixed":"1.0.5"}]}],"ecosystem_specific":{"affected_functions":null,"affects":{"arch":[],"functions":[],"os":[]}},"database_specific":{"categories":["memory-corruption"],"cvss":null,"informational":"unsound","source":"https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2020-0161.json"}}],"references":[{"type":"PACKAGE","url":"https://crates.io/crates/array-macro"},{"type":"ADVISORY","url":"https://rustsec.org/advisories/RUSTSEC-2020-0161.html"},{"type":"WEB","url":"https://gitlab.com/KonradBorowski/array-macro/-/commit/01940637dd8f3bfeeee3faf9639fa9ae52f19f4d"}],"database_specific":{"license":"CC0-1.0"}}