CVE-2020-35920: Socket2 :net::SocketAddr Vulnerability

MODERATE
Advisory Identifier: GHSA-458v-4hrf-g3m4
CVSS 5.5
CWE-188
Published
Advisory Summary

CVE-2020-35920 is a MODERATE (CVSS 5.5) :net::socketaddr vulnerability (CWE-188: Reliance on Data/Memory Layout) affecting Socket2 libraries in the crates.io ecosystem. The issue involves :net::socketaddr. Remediation is available by upgrading affected packages to version 0.3.16, 0.2.36.

CVE-2020-35920 at a Glance

CVE Identifier CVE-2020-35920
GHSA Identifier GHSA-458v-4hrf-g3m4
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-188: Reliance on Data/Memory Layout
Affected Product Socket2
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2020-35920

To remediate this vulnerability, upgrade all affected Socket2 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
net2 fixed: 0.2.36
Upgrade net2 to 0.2.36
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 CVE-2020-35920, inspect your project dependencies for Socket2:

inspect dependencies for socket2

Analyze the terminal output to locate any version of Socket2 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-188: Reliance on Data/Memory Layout, where the product makes invalid assumptions about how protocol data or memory is organized at a lower level, resulting in unintended program behavior. In Socket2, 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 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.

CVE-2020-35920 Affected Socket2 Versions

2 component(s)
Fixed Versions:
0.3.160.2.36
Product / Package Ecosystem Affected Versions Fixed Version
socket2
crates.io
< 0.3.16
0.3.16
net2
crates.io
< 0.2.36
0.2.36

References

Frequently Asked Questions

What is CVE-2020-35920?
CVE-2020-35920 is a security vulnerability in Socket2 involving :net::SocketAddr under CWE-188: Reliance on Data/Memory Layout.
Which Socket2 versions are affected?
Affected versions include releases prior to 0.3.16, 0.2.36 across affected packages: socket2, net2.
What version fixes CVE-2020-35920?
Upgrading to 0.3.16, 0.2.36 (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.
Is net2 affected?
Yes, net2 is affected in releases prior to 0.2.36. Upgrade your dependency to 0.2.36 or later.
What is the CVSS score of CVE-2020-35920?
CVE-2020-35920 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2020-35920?
CVE-2020-35920 is classified under CWE-188: Reliance on Data/Memory Layout (The product makes invalid assumptions about how protocol data or memory is organized at a lower level, resulting in unintended program behavior.).
How can I check crates.io dependencies for CVE-2020-35920?
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-458v-4hrf-g3m4",
  "modified" : "2024-02-12T15:55:27Z",
  "published" : "2021-08-25T20:50:37Z",
  "aliases" : [ "CVE-2020-35920" ],
  "summary" : "socket2 invalidly assumes the memory layout of std::net::SocketAddr",
  "details" : "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.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "socket2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.3.16"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "net2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.2.36"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-35920"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deprecrated/net2-rs/issues/105"
  }, {
    "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-0078.html"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2020-0079.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-188" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-19T18:53:58Z",
    "nvd_published_at" : "2020-12-31T09:15:16Z"
  }
}