Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unsoundness in os_socketaddr #1384

Merged
merged 1 commit into from
Aug 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/os_socketaddr/RUSTSEC-0000-0000.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```toml
[advisory]
id = "RUSTSEC-0000-0000"
package = "os_socketaddr"
date = "2022-08-26"
url = "https://github.com/a-ba/os_socketaddr/issues/3"
categories = ["memory-corruption"]
keywords = ["memory", "layout", "cast"]
informational = "unsound"

[versions]
patched = [">= 0.2.2"]
```

# `os_socketaddr` invalidly assumes the memory layout of std::net::SocketAddr

The [`os_socketaddr`](https://crates.io/crates/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](https://github.com/rust-lang/rust/pull/78802)
in nightly `std`. Starting from rustc 1.64 the affected versions of this crate will have undefined
behaviour.