CVE-2021-45687 — raw-cpuid
CVE-2021-45687 is a Improper Input Validation vulnerability in raw-cpuid. A fix is available for raw-cpuid — see the affected versions and patch details below.
Optional `Deserialize` implementations lacking validation
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
Real-World Exposure
raw-cpuidReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects crates.io packages — download data is not available via public APIs for these ecosystems.
Description
When activating the non-default feature serialize, most structs implement
serde::Deserialize without sufficient validation. This allows breaking
invariants in safe code, leading to:
- Undefined behavior in
as_string()methods (which usestd::str::from_utf8_unchecked()internally). - Panics due to failed assertions.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🦀crates.io | raw-cpuid | ≥ 3.1.0&&< 9.1.1 | 9.1.1cargo update -p raw-cpuid --precise 9.1.1 |
Affected Products
raw-cpuidraw-cpuid_projectDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for raw-cpuid, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update raw-cpuid to 9.1.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-45687 is resolved across your whole dependency graph.
Workarounds
Do not deserialise data from untrusted sources: where the format allows it, restrict deserialisation to an explicit allowlist of expected types, and prefer a data-only format (JSON, Protobuf) over one that can reconstruct arbitrary objects until you can upgrade.
Frequently Asked Questions
Is CVE-2021-45687 in your dependencies?
Find it across crates.io, including transitive dependencies.