CVE-2023-34450: Github.com/cometbft/cometbft CometBFT PeerState JSON Serialization Deadlock Vulnerability

MODERATE
Advisory Identifier: GHSA-mvj3-qrqh-cjvr
CVSS 5.3
CWE-770 CWE-401
Published
Advisory Summary

CVE-2023-34450 is a MODERATE (CVSS 5.3) cometbft peerstate json serialization deadlock vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Github.com/cometbft/cometbft libraries in the Go ecosystem. The issue involves cometbft peerstate json serialization deadlock. Remediation is available by upgrading affected packages to version 0.34.29, 0.37.2.

CVE-2023-34450 at a Glance

CVE Identifier CVE-2023-34450
GHSA Identifier GHSA-mvj3-qrqh-cjvr
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Github.com/cometbft/cometbft
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:N/A:L).

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 None (I:N)
Availability Low (A:L)

How to Fix CVE-2023-34450

To remediate this vulnerability, upgrade all affected Github.com/cometbft/cometbft 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/cometbft/cometbft fixed: 0.34.29
Upgrade github.com/cometbft/cometbft to 0.34.29
github.com/cometbft/cometbft fixed: 0.37.2
Upgrade github.com/cometbft/cometbft to 0.37.2
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/cometbft/cometbft

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-34450, inspect your project dependencies for Github.com/cometbft/cometbft:

inspect dependencies for github.com/cometbft/cometbft

Analyze the terminal output to locate any version of Github.com/cometbft/cometbft in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.34.29), 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-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Github.com/cometbft/cometbft, 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 internal modification to the way struct `PeerState` is serialized to JSON introduced a deadlock when new function MarshallJSON is called. This function can be called from two places: 1. Via logs * Setting the `consensus` logging module to "debug" level (should not happen in production), and * Setting the log output format to JSON 2. Via RPC `dump_consensus_state` Case 1 above, which should not be hit in production, will eventually hit the deadlock in most goroutines, effectively halting the node. In case 2, only the data structures related to the first peer will be deadlocked, together with the thread(s) dealing with the RPC request(s). This means that only one of the channels of communication to the node's peers will be blocked. Eventually the peer will timeout and excluded from the list (typically after 2 minutes). The goroutines involved in the deadlock will not be garbage collected, but they will not interfere with the system after the peer is excluded. The theoretical worst case for case 2, is a network with only two validator nodes. In this case, each of the nodes only has one `PeerState` struct. If `dump_consensus_state` is called in either node (or both), the chain will halt until the peer connections time out, after which the nodes will reconnect (with different `PeerState` structs) and the chain will progress again. Then, the same process can be repeated. As the number of nodes in a network increases, and thus, the number of peer struct each node maintains, the possibility of reproducing the perturbation visible with 2 nodes decreases. Only the first `PeerState` struct will deadlock, and not the others (RPC `dump_consensus_state` accesses them in a for loop, so the deadlock at the first iteration causes the rest of the iterations of that "for" loop to never be reached). This regression was introduced in versions `v0.34.28` and `v0.37.1`, and will be fixed in `v0.34.29` and `v0.37.2`. ### Patches The PR containing the fix is [here](https://github.com/cometbft/cometbft/pull/865), and the corresponding issue is [here](https://github.com/cometbft/cometbft/pull/863) ### Workarounds For case 1 (hitting the deadlock via logs) * either don't set the log output to "json", leave at "plain", * or don't set the consensus logging module to "debug", leave it at "info" or higher. For case 2 (hitting the deadlock via RPC `dump_consensus_state`) * do not expose `dump_consensus_state` RPC endpoint to the public internet (e.g., via rules in your nginx setup) ### References * [Issue](https://github.com/cometbft/cometbft/pull/863) that introduced the deadlock * [Issue](https://github.com/cometbft/cometbft/pull/524) reporting the bug via logs

CVE-2023-34450 Affected Github.com/cometbft/cometbft Versions

2 component(s)
Fixed Versions:
0.34.290.37.2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/cometbft/cometbft
Go
≥ 0.34.28
< 0.34.29
All 1 versions
0.34.28
0.34.29
github.com/cometbft/cometbft
Go
≥ 0.37.1
< 0.37.2
All 1 versions
0.37.1
0.37.2

References

Frequently Asked Questions

What is CVE-2023-34450?
CVE-2023-34450 is a security vulnerability in Github.com/cometbft/cometbft involving CometBFT PeerState JSON serialization deadlock under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Github.com/cometbft/cometbft versions are affected?
Affected versions include releases prior to 0.34.29, 0.37.2 across affected packages: github.com/cometbft/cometbft.
What version fixes CVE-2023-34450?
Upgrading to 0.34.29, 0.37.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/cometbft/cometbft affected?
Yes, github.com/cometbft/cometbft is affected in releases prior to 0.34.29, 0.37.2. Upgrade your dependency to 0.34.29, 0.37.2 or later.
What is the CVSS score of CVE-2023-34450?
CVE-2023-34450 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2023-34450?
CVE-2023-34450 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check Go dependencies for CVE-2023-34450?
Run the dependency tree command: 'inspect dependencies for github.com/cometbft/cometbft'. 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-mvj3-qrqh-cjvr",
  "modified" : "2023-07-18T19:15:58Z",
  "published" : "2023-07-05T21:33:48Z",
  "aliases" : [ "CVE-2023-34450" ],
  "summary" : "CometBFT PeerState JSON serialization deadlock",
  "details" : "### Impact\nAn internal modification to the way struct `PeerState` is serialized to JSON introduced a deadlock when new function MarshallJSON is called. This function can be called from two places:\n\n1. Via logs\n    * Setting the `consensus` logging module to \"debug\" level (should not happen in production), and\n    * Setting the log output format to JSON\n2. Via RPC `dump_consensus_state` \n\nCase 1 above, which should not be hit in production, will eventually hit the deadlock in most goroutines, effectively halting the node.\n\nIn case 2, only the data structures related to the first peer will be deadlocked, together with the thread(s) dealing with the RPC request(s). This means that only one of the channels of communication to the node's peers will be blocked. Eventually the peer will timeout and excluded from the list (typically after 2 minutes). The goroutines involved in the deadlock will not be garbage collected, but they will not interfere with the system after the peer is excluded.\n\nThe theoretical worst case for case 2, is a network with only two validator nodes. In this case, each of the nodes only has one `PeerState` struct. If `dump_consensus_state` is called in either node (or both), the chain will halt until the peer connections time out, after which the nodes will reconnect (with different `PeerState` structs) and the chain will progress again. Then, the same process can be repeated.\n\nAs the number of nodes in a network increases, and thus, the number of peer struct each node maintains, the possibility of reproducing the perturbation visible with 2 nodes decreases. Only the first `PeerState` struct will deadlock, and not the others (RPC `dump_consensus_state` accesses them in a for loop, so the deadlock at the first iteration causes the rest of the iterations of that \"for\" loop to never be reached).\n\nThis regression was introduced in versions `v0.34.28` and `v0.37.1`, and will be fixed in `v0.34.29` and `v0.37.2`.\n\n### Patches\nThe PR containing the fix is [here](https://github.com/cometbft/cometbft/pull/865), and the corresponding issue is [here](https://github.com/cometbft/cometbft/pull/863)\n\n### Workarounds\nFor case 1 (hitting the deadlock via logs)\n* either don't set the log output to \"json\", leave at \"plain\",\n* or don't set the consensus logging module to \"debug\", leave it at \"info\" or higher.\n\nFor case 2 (hitting the deadlock via RPC `dump_consensus_state`)\n* do not expose `dump_consensus_state` RPC endpoint to the public internet (e.g., via rules in your nginx setup)\n\n### References\n\n* [Issue](https://github.com/cometbft/cometbft/pull/863) that introduced the deadlock\n* [Issue](https://github.com/cometbft/cometbft/pull/524) reporting the bug via logs\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/cometbft/cometbft"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.34.28"
      }, {
        "fixed" : "0.34.29"
      } ]
    } ],
    "versions" : [ "0.34.28" ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/cometbft/cometbft"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.37.1"
      }, {
        "fixed" : "0.37.2"
      } ]
    } ],
    "versions" : [ "0.37.1" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cometbft/cometbft/security/advisories/GHSA-mvj3-qrqh-cjvr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-34450"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cometbft/cometbft/pull/524"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cometbft/cometbft/pull/863"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cometbft/cometbft/pull/865"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cometbft/cometbft"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-401", "CWE-770" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-07-05T21:33:48Z",
    "nvd_published_at" : "2023-07-03T17:15:09Z"
  }
}