CVE-2023-25568: Boxo bitswap/server Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-m974-xj4j-7qv5
CVSS 8.2
CWE-400 CWE-770
Published
Advisory Summary

CVE-2023-25568 is a HIGH (CVSS 8.2) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Boxo bitswap/server libraries in the Go ecosystem. The issue involves dos unbounded persistent memory leak. Remediation is available by upgrading affected packages to version 0.6.0, 0.4.1.

CVE-2023-25568 at a Glance

CVE Identifier CVE-2023-25568
GHSA Identifier GHSA-m974-xj4j-7qv5
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Boxo bitswap/server
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.2

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

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

How to Fix CVE-2023-25568

To remediate this vulnerability, upgrade all affected Boxo bitswap/server dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/ipfs/go-libipfs fixed: 0.6.0
Upgrade github.com/ipfs/go-libipfs to 0.6.0
github.com/ipfs/go-libipfs fixed: 0.4.1
Upgrade github.com/ipfs/go-libipfs to 0.4.1
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 github.com/ipfs/go-libipfs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-25568, inspect your project dependencies for Boxo bitswap/server:

inspect dependencies for github.com/ipfs/go-libipfs

Analyze the terminal output to locate any version of Boxo bitswap/server in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.6.0), 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Boxo bitswap/server, 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

### Impact An attacker is able allocate arbitrarily many bytes in the Bitswap server by sending many `WANT_BLOCK` and or `WANT_HAVE` requests which are queued in an unbounded queue, with allocations that persist even if the connection is closed. This affects users accepting untrusted connections with the Bitswap server, this also affects users using the old API stubs at `github.com/ipfs/boxo/bitswap` because it transitively uses `github.com/ipfs/boxo/bitswap/server`. We have [renamed go-libipfs to boxo](https://github.com/ipfs/boxo/issues/215); this document uses both terms interchangeably. The version numbers for both are applicable, as they share the same historical timeline. ### Remediation Apply one of: - Update `boxo` to [`v0.6.0`](https://github.com/ipfs/boxo/releases/tag/v0.6.0) or later - Update `boxo` to [`v0.4.1`](https://github.com/ipfs/boxo/releases/tag/v0.4.1) Note that ***`v0.5.0` is NOT safe***, `v0.4.1` is a backport of the `v0.6.0` security fixes on top of `v0.4.0`. ### Mitigations 1. The server now limits how many wantlist entries per peer it knows. The `MaxQueuedWantlistEntriesPerPeer` option allows configuring how many wantlist entries the server remembers; if a peer sends a wantlist bigger than this (including a sum of multiple delta updates) the server will truncate the wantlist to the match the limit. This defaults to `1024` entries per peer. 2. The server now properly clears state about peers when they disconnect. Peer state is more lazily allocated (only when a wantlist is received in the first place) and is properly cleared when the `PeerDisconnected` callback is received. 3. The server now ignores CIDs above some size. Clients were able to send any CID as long as the total protobuf message were bellow the 4MiB limit. This is allowed to allocate lots of memory with very little entries. This can be configured using the `MaxCidSize` option and defaults to `168 bytes`. 4. The server now closes the connection if an inline CID is requested (either as `WANT_*` or `CANCEL`). The attack were more effective if done with CIDs that are present in target's blockstore, this is because this will push longer-lasting jobs on some priority queue. Since inline CID are literal data (instead of hashes of data), everyone always "has" any inline CID (since instead of loading the data from disk, it can be extracted from the CID). It makes no sense for anyone to ever ask you about an inline CID since they could also just parse it themselves. Thus, as a defensive measure, we kill the connection with peers that ask about an inline CID. ### Vulnerable symbols - `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).MessageReceived` - `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).NotifyNewBlocks` - `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).findOrCreate` - `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).PeerConnected` ### Patches - https://github.com/ipfs/boxo/commit/9cb5cb54d40b57084d1221ba83b9e6bb3fcc3197 (mitigations 1 and 2) - https://github.com/ipfs/boxo/commit/62cbac40b96f49e39cd7fedc77ee6b56adce4916 (mitigations 3 and 4) - https://github.com/ipfs/boxo/commit/baa748b682fabb21a4c1f7628a8af348d4645974 (tests) ### Workarounds If you are using the stubs at `github.com/ipfs/go-libipfs/bitswap` and not taking advantage of the features provided by the server, refactoring your code to use the new split API will allow you to run in a client-only mode using: [`github.com/ipfs/boxo/bitswap/client`](https://pkg.go.dev/github.com/ipfs/boxo/bitswap/client).

CVE-2023-25568 Affected Boxo bitswap/server Versions

2 component(s)
Fixed Versions:
0.6.00.4.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/ipfs/go-libipfs
Go
≥ 0.5.0
< 0.6.0
0.6.0
github.com/ipfs/go-libipfs
Go
< 0.4.1
0.4.1

References

Frequently Asked Questions

What is CVE-2023-25568?
CVE-2023-25568 is a security vulnerability in Boxo bitswap/server involving DOS unbounded persistent memory leak under CWE-400: Uncontrolled Resource Consumption.
Which Boxo bitswap/server versions are affected?
Affected versions include releases prior to 0.6.0, 0.4.1 across affected packages: github.com/ipfs/go-libipfs.
What version fixes CVE-2023-25568?
Upgrading to 0.6.0, 0.4.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/ipfs/go-libipfs affected?
Yes, github.com/ipfs/go-libipfs is affected in releases prior to 0.6.0, 0.4.1. Upgrade your dependency to 0.6.0, 0.4.1 or later.
What is the CVSS score of CVE-2023-25568?
CVE-2023-25568 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H.
What CWE is associated with CVE-2023-25568?
CVE-2023-25568 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check Go dependencies for CVE-2023-25568?
Run the dependency tree command: 'inspect dependencies for github.com/ipfs/go-libipfs'. 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-m974-xj4j-7qv5",
  "modified" : "2023-05-11T20:32:18Z",
  "published" : "2023-05-11T20:32:18Z",
  "aliases" : [ "CVE-2023-25568" ],
  "summary" : "Boxo bitswap/server: DOS unbounded persistent memory leak",
  "details" : "### Impact\nAn attacker is able allocate arbitrarily many bytes in the Bitswap server by sending many `WANT_BLOCK` and or `WANT_HAVE` requests which are queued in an unbounded queue, with allocations that persist even if the connection is closed.\nThis affects users accepting untrusted connections with the Bitswap server, this also affects users using the old API stubs at `github.com/ipfs/boxo/bitswap` because it transitively uses `github.com/ipfs/boxo/bitswap/server`.\n\nWe have [renamed go-libipfs to boxo](https://github.com/ipfs/boxo/issues/215); this document uses both terms interchangeably. The version numbers for both are applicable, as they share the same historical timeline.\n\n### Remediation\nApply one of:\n- Update `boxo` to [`v0.6.0`](https://github.com/ipfs/boxo/releases/tag/v0.6.0) or later\n- Update `boxo` to [`v0.4.1`](https://github.com/ipfs/boxo/releases/tag/v0.4.1)\n   Note that ***`v0.5.0` is NOT safe***, `v0.4.1` is a backport of the `v0.6.0` security fixes on top of `v0.4.0`.\n\n### Mitigations\n1. The server now limits how many wantlist entries per peer it knows.\n    The `MaxQueuedWantlistEntriesPerPeer` option allows configuring how many wantlist entries the server remembers; if a peer sends a wantlist bigger than this (including a sum of multiple delta updates) the server will truncate the wantlist to the match the limit.\n    This defaults to `1024` entries per peer.\n2. The server now properly clears state about peers when they disconnect.\n    Peer state is more lazily allocated (only when a wantlist is received in the first place) and is properly cleared when the `PeerDisconnected` callback is received.\n3. The server now ignores CIDs above some size.\n    Clients were able to send any CID as long as the total protobuf message were bellow the 4MiB limit. This is allowed to allocate lots of memory with very little entries.\n    This can be configured using the `MaxCidSize` option and defaults to `168 bytes`.\n4. The server now closes the connection if an inline CID is requested (either as `WANT_*` or `CANCEL`).\n    The attack were more effective if done with CIDs that are present in target's blockstore, this is because this will push longer-lasting jobs on some priority queue.\n    Since inline CID are literal data (instead of hashes of data), everyone always \"has\" any inline CID (since instead of loading the data from disk, it can be extracted from the CID). It makes no sense for anyone to ever ask you about an inline CID since they could also just parse it themselves. Thus, as a defensive measure, we kill the connection with peers that ask about an inline CID.\n\n### Vulnerable symbols\n- `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).MessageReceived`\n- `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).NotifyNewBlocks`\n- `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).findOrCreate`\n- `github.com/ipfs/go-libipfs/bitswap/server/internal/decision.(*Engine).PeerConnected`\n\n### Patches\n- https://github.com/ipfs/boxo/commit/9cb5cb54d40b57084d1221ba83b9e6bb3fcc3197 (mitigations 1 and 2)\n- https://github.com/ipfs/boxo/commit/62cbac40b96f49e39cd7fedc77ee6b56adce4916 (mitigations 3 and 4)\n- https://github.com/ipfs/boxo/commit/baa748b682fabb21a4c1f7628a8af348d4645974 (tests)\n\n### Workarounds\nIf you are using the stubs at `github.com/ipfs/go-libipfs/bitswap` and not taking advantage of the features provided by the server, refactoring your code to use the new split API will allow you to run in a client-only mode using: [`github.com/ipfs/boxo/bitswap/client`](https://pkg.go.dev/github.com/ipfs/boxo/bitswap/client).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/ipfs/go-libipfs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.5.0"
      }, {
        "fixed" : "0.6.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/ipfs/go-libipfs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.4.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/boxo/security/advisories/GHSA-m974-xj4j-7qv5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/go-libipfs/security/advisories/GHSA-m974-xj4j-7qv5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-25568"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/boxo/commit/62cbac40b96f49e39cd7fedc77ee6b56adce4916"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/boxo/commit/9cb5cb54d40b57084d1221ba83b9e6bb3fcc3197"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/boxo/commit/baa748b682fabb21a4c1f7628a8af348d4645974"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ipfs/boxo"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-11T20:32:18Z",
    "nvd_published_at" : "2023-05-10T14:15:32Z"
  }
}