GHSA-p5w9-856p-8q4g: Assumed memory layout of std :net::SocketAddr Vulnerability

MODERATE
CWE-824
Published
Advisory Summary

GHSA-p5w9-856p-8q4g is a MODERATE :net::socketaddr vulnerability (CWE-824: Access of Uninitialized Pointer) affecting Assumed memory layout of std libraries in the crates.io ecosystem. The issue involves :net::socketaddr. Remediation is available by upgrading affected packages to version 0.3.16.

GHSA-p5w9-856p-8q4g at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-p5w9-856p-8q4g
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-824: Access of Uninitialized Pointer
Affected Product Assumed memory layout of std
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-p5w9-856p-8q4g

To remediate this vulnerability, upgrade all affected Assumed memory layout of std dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

socket2 fixed: 0.3.16
Upgrade socket2 to 0.3.16
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for socket2

How to Check if You Are Affected

To determine whether your application is affected by GHSA-p5w9-856p-8q4g, inspect your project dependencies for Assumed memory layout of std:

inspect dependencies for socket2

Analyze the terminal output to locate any version of Assumed memory layout of std in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.16), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-824: Access of Uninitialized Pointer, where the product accesses or uses a pointer that has not been initialized. In Assumed memory layout of std, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The [`socket2`](https://crates.io/crates/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.

GHSA-p5w9-856p-8q4g Affected Assumed memory layout of std Versions

1 component(s)
Fixed Versions:
0.3.16
Product / Package Ecosystem Affected Versions Fixed Version
socket2
crates.io
< 0.3.16
0.3.16

References

Frequently Asked Questions

What is GHSA-p5w9-856p-8q4g?
GHSA-p5w9-856p-8q4g is a security vulnerability in Assumed memory layout of std involving :net::SocketAddr under CWE-824: Access of Uninitialized Pointer.
Which Assumed memory layout of std versions are affected?
Affected versions include releases prior to 0.3.16 across affected packages: socket2.
What version fixes GHSA-p5w9-856p-8q4g?
Upgrading to 0.3.16 (or the latest patched release for your respective branch) resolves the vulnerability.
Is socket2 affected?
Yes, socket2 is affected in releases prior to 0.3.16. Upgrade your dependency to 0.3.16 or later.
What CWE is associated with GHSA-p5w9-856p-8q4g?
GHSA-p5w9-856p-8q4g is classified under CWE-824: Access of Uninitialized Pointer (The product accesses or uses a pointer that has not been initialized.).
How can I check crates.io dependencies for GHSA-p5w9-856p-8q4g?
Run the dependency tree command: 'inspect dependencies for socket2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-p5w9-856p-8q4g",
  "modified" : "2021-08-24T17:42:08Z",
  "published" : "2021-08-25T21:00:23Z",
  "withdrawn" : "2021-08-24T17:42:08Z",
  "aliases" : [ ],
  "summary" : "Assumed memory layout of std::net::SocketAddr",
  "details" : "The [`socket2`](https://crates.io/crates/socket2) crate has assumed `std::net::SocketAddrV4`\nand `std::net::SocketAddrV6` have the same memory layout as the system C representation\n`sockaddr`. It has simply casted the pointers to convert the socket addresses to the\nsystem representation. The standard library does not say anything about the memory\nlayout, and this will cause invalid memory access if the standard library\nchanges the implementation. No warnings or errors will be emitted once the\nchange happens.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "socket2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.3.16"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/socket2-rs/issues/119"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-lang/socket2-rs"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2020-0079.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-824" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-06T17:25:39Z",
    "nvd_published_at" : null
  }
}