RUSTSEC-2023-0017 (unsound) on 2023-03-04: maligned::align_first causes incorrect deallocation

maligned::align_first manually allocates with an alignment larger than T, and then uses Vec::from_raw_parts on that allocation to get a Vec<T>.

GlobalAlloc::dealloc requires that the layout argument must be the same layout that was used to allocate that block of memory.

When deallocating, Box and Vec may not respect the specified alignment and can cause undefined behavior.

GHSA-wm8x-php5-hvq6

This review is from Crev, a distributed system for code reviews. To add your review, set up cargo-crev.

0.2.1 (current) Rating: Negative + Unmaintained Thoroughness: None Understanding: None

by gitlab.com/KonradBorowski on 2022-04-08

Functions whose name starts with align_first are unsound as they create allocations whose alignment doesn't match the alignment of an allocation. This can cause hard to debug issues when using alignment aware allocator.

See https://github.com/tylerhawkes/maligned/issues/5


Lib.rs has been able to verify that all files in the crate's tarball are in the crate's repository with a git tag matching the version. Please note that this check is still in beta, and absence of this confirmation does not mean that the files don't match.

Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories, so there is a possibility that published crates have a misleading repository URL, or contain different code from the code in the repository.

To review the actual code of the crate, it's best to use cargo crev open maligned. Alternatively, you can download the tarball of maligned v0.2.1 or view the source online.