GHSA-c439-chv8-8g2j `os_socketaddr` invalidly assumes the memory layout of std::net::SocketAddr
The os_socketaddr crate causes undefined behavior by incorrectly casting Rust socket addresses to C structures, potentially leading to crashes or code execution.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is GHSA-c439-chv8-8g2j?
GHSA-c439-chv8-8g2j is a memory corruption vulnerability in os_socketaddr, published on 26 Aug 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
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.
Which versions are affected by GHSA-c439-chv8-8g2j?
3 open source packages ship an affected version, including os_socketaddr.
| Package | Affected | Fixed in |
|---|---|---|
os_socketaddr crates.io | All versions | 0.2.2 |
os_socketaddr crates.io | All versions | 0.2.2 |
os_socketaddr crates.io | From 0.0.0-0 | 0.2.2 |
How do I fix GHSA-c439-chv8-8g2j?
Upgrade os_socketaddr to 0.2.2 or later.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is GHSA-c439-chv8-8g2j being exploited?
There is no known exploitation of GHSA-c439-chv8-8g2j in the wild and no public exploit code.
Sources
Also known as RUSTSEC-2022-0052.