Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. mopa
  4. ›
  5. CVE-2021-45695

CVE-2021-45695: Incorrect reliance on Trait memory layout in mopa

January 6, 2022 (updated June 13, 2023)

The mopa crate redefines the deprecated TraitObject struct from core::raw. This is done to then transmute a reference to a trait object (&dyn Trait for any trait Trait) into this struct and retrieve the data field for the purpose of downcasting. This is used to implement downcast_ref_unchecked(), in terms of which downcast_ref() is also implemented. Same goes for mutable reference downcasting and Box downcasting.

The Rust compiler explicitly reserves the right to change the memory layout of &dyn Trait for any trait Trait. The worst case scenario is that it swaps data and vtable, making an executable location breach and compromisation of ASLR possible, since reads from data would read vtable instead. Likewise, arbitrary code execution is also theoretically possible if reads of vtable generated by the compiler read data instead.

References

  • github.com/advisories/GHSA-2gxj-qrp2-53jv
  • github.com/chris-morgan/mopa
  • github.com/chris-morgan/mopa/issues/13
  • nvd.nist.gov/vuln/detail/CVE-2021-45695
  • raw.githubusercontent.com/rustsec/advisory-db/main/crates/mopa/RUSTSEC-2021-0095.md
  • rustsec.org/advisories/RUSTSEC-2021-0095.html

Code Behaviors & Features

Detect and mitigate CVE-2021-45695 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions up to 0.2.2

Solution

Unfortunately, there is no solution available yet.

Impact 9.8 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Source file

cargo/mopa/CVE-2021-45695.yml

Spotted a mistake? Edit the file on GitLab.

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

Page generated Wed, 14 May 2025 12:15:46 +0000.