Rust advisories / os_socketaddr
Unsound HighRUSTSEC-2022-0052 · os_socketaddr
RUSTSEC-2022-0052: `os_socketaddr` invalidly assumes the memory layout of std::net::SocketAddr
Short answeros_socketaddr has an API that can cause undefined behaviour from safe code: `os_socketaddr` invalidly assumes the memory layout of std::net::SocketAddr. Fixed in 0.2.2.
| Crate | os_socketaddr |
|---|---|
| Type | Unsound (memory-corruption) |
| Affected versions | Before 0.2.2. |
| Fixed in | 0.2.2 |
| Severity | High (GitHub rating) |
| Published | 2022-08-26 |
| Last changed | 2023-11-08 |
| Also known as | GHSA-c439-chv8-8g2j |
What to do
- See which version you have:
cargo tree -i os_socketaddr(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p os_socketaddr. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for exampleos_socketaddr = "0.2.2") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
The os_socketaddr crate has assumed std::net::SocketAddrV4 and std::net::SocketAddrV6 have the same memory layout as the system C representation sockaddr. It has simply casted the pointers to convert the socket addresses to the system representation.
These layout were changed into idiomatic rust types in nightly std. Starting from rustc 1.64 the affected versions of this crate will have undefined behaviour.
References
- Package: crates.io/crates/os_socketaddr
- Advisory: rustsec.org/advisories/RUSTSEC-2022-0052.html
- Report: github.com/a-ba/os_socketaddr/issues/3
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Up next
Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →Also worth your time
Did this answer your question?