rustsec-2021-0013
Vulnerability from osv_rustsec
Undefined behavior in as_string() methods
VendorInfo::as_string(), SoCVendorBrand::as_string(),
and ExtendedFunctionInfo::processor_brand_string() construct byte slices
using std::slice::from_raw_parts(), with data coming from
#[repr(Rust)] structs. This is always undefined behavior.
See https://github.com/gz/rust-cpuid/issues/40.
This flaw has been fixed in v9.0.0, by making the relevant structs
#[repr(C)].
native_cpuid::cpuid_count() is unsound
native_cpuid::cpuid_count() exposes the unsafe __cpuid_count() intrinsic
from core::arch::x86 or core::arch::x86_64 as a safe function, and uses
it internally, without checking the
safety requirement:
The CPU the program is currently running on supports the function being called.
CPUID is available in most, but not all, x86/x86_64 environments. The crate compiles only on these architectures, so others are unaffected.
This issue is mitigated by the fact that affected programs are expected to crash deterministically every time.
See https://github.com/gz/rust-cpuid/issues/41.
The flaw has been fixed in v9.0.0, by intentionally breaking compilation when targeting SGX or 32-bit x86 without SSE. This covers all affected CPUs.
{
"affected": [
{
"database_specific": {
"categories": [
"memory-corruption",
"denial-of-service"
],
"cvss": null,
"informational": null
},
"ecosystem_specific": {
"affected_functions": null,
"affects": {
"arch": [
"x86",
"x86_64"
],
"functions": [],
"os": []
}
},
"package": {
"ecosystem": "crates.io",
"name": "raw-cpuid",
"purl": "pkg:cargo/raw-cpuid"
},
"ranges": [
{
"events": [
{
"introduced": "0.0.0-0"
},
{
"fixed": "9.0.0"
}
],
"type": "SEMVER"
}
],
"versions": []
}
],
"aliases": [
"CVE-2021-26306",
"CVE-2021-26307",
"GHSA-hvqc-pc78-x9wh",
"GHSA-jrf8-cmgg-gv2m"
],
"database_specific": {
"license": "CC0-1.0"
},
"details": "## Undefined behavior in `as_string()` methods\n\n`VendorInfo::as_string()`, `SoCVendorBrand::as_string()`,\nand `ExtendedFunctionInfo::processor_brand_string()` construct byte slices\nusing `std::slice::from_raw_parts()`, with data coming from\n`#[repr(Rust)]` structs. This is always undefined behavior.\n\nSee https://github.com/gz/rust-cpuid/issues/40.\n\nThis flaw has been fixed in v9.0.0, by making the relevant structs\n`#[repr(C)]`.\n\n## `native_cpuid::cpuid_count()` is unsound\n\n`native_cpuid::cpuid_count()` exposes the unsafe `__cpuid_count()` intrinsic\nfrom `core::arch::x86` or `core::arch::x86_64` as a safe function, and uses\nit internally, without checking the\n[safety requirement](https://doc.rust-lang.org/core/arch/index.html#overview):\n\n\u003e The CPU the program is currently running on supports the function being\n\u003e called.\n\nCPUID is available in most, but not all, x86/x86_64 environments. The crate\ncompiles only on these architectures, so others are unaffected.\n\nThis issue is mitigated by the fact that affected programs are expected\nto crash deterministically every time.\n\nSee https://github.com/gz/rust-cpuid/issues/41.\n\nThe flaw has been fixed in v9.0.0, by intentionally breaking compilation\nwhen targeting SGX or 32-bit x86 without SSE. This covers all affected CPUs.",
"id": "RUSTSEC-2021-0013",
"modified": "2023-06-13T13:10:24Z",
"published": "2021-01-20T12:00:00Z",
"references": [
{
"type": "PACKAGE",
"url": "https://crates.io/crates/raw-cpuid"
},
{
"type": "ADVISORY",
"url": "https://rustsec.org/advisories/RUSTSEC-2021-0013.html"
},
{
"type": "WEB",
"url": "https://github.com/RustSec/advisory-db/pull/614"
}
],
"related": [],
"severity": [],
"summary": "Soundness issues in `raw-cpuid`"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.