RUSTSEC-2021-0095
(unsound)
on 2021-06-01:
mopa
is technically unsound
mopa
is technically unsound
This crate has no reviews yet. To add a review, set up your cargo-crev
.
Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories. There is absolutely no guarantee that the repository URL declared by the crate belongs to the crate, or that the code in the repository is the code inside the published tarball.
To review the actual code of the crate, it's best to use cargo crev open mopa
. Alternatively, you can download the tarball of mopa v0.2.2 or view the source online.
The
mopa
crate redefines the deprecatedTraitObject
struct fromcore::raw
like so:This is done to then transmute a reference to a trait object (
&dyn Trait
for any traitTrait
) into this struct and retrieve thedata
field for the purpose of downcasting. This is used to implementdowncast_ref_unchecked()
, in terms of whichdowncast_ref()
is also implemented. Same goes for mutable reference downcasting andBox
downcasting.The Rust compiler explicitly reserves the right to change the memory layout of
&dyn Trait
for any traitTrait
. The worst case scenario is that it swapsdata
andvtable
, making an executable location breach and compromisation of ASLR possible, since reads fromdata
would readvtable
instead. Likewise, arbitrary code execution is also theoretically possible if reads ofvtable
generated by the compiler readdata
instead.While, as of Rust 1.52, this unsound assumption still holds true, updating the compiler may silently create UB in a crate which previously compiled and run without issues, compromising the security of builds which are believed to be reproducible.
A potential strategy to resolve this has already been suggested in an issue on the GitHub repository of the crate.
CVE-2021-45695
GHSA-2gxj-qrp2-53jv
GHSA-8mv5-7x95-7wcf