The socket2 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. The standard library does not say anything about the memory layout, and this will cause invalid memory access if the standard library changes the implementation. No warnings or errors will be emitted once the change happens.
References
- https://nvd.nist.gov/vuln/detail/CVE-2020-35920
- https://github.com/rust-lang/socket2-rs/issues/119
- https://rustsec.org/advisories/RUSTSEC-2020-0079.html
- https://github.com/deprecrated/net2-rs/issues/105
- https://rustsec.org/advisories/RUSTSEC-2020-0078.html
- https://github.com/advisories/GHSA-458v-4hrf-g3m4