Denial of Service (DoS) Affecting github.com/cometbft/cometbft/consensus package, versions >=0.34.28 <0.34.29 >=0.37.1 <0.37.2
Threat Intelligence
Do your applications use this vulnerable package?
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applications- Snyk ID SNYK-GOLANG-GITHUBCOMCOMETBFTCOMETBFTCONSENSUS-5752410
- published 4 Jul 2023
- disclosed 4 Jul 2023
- credit mmsqe
Introduced: 4 Jul 2023
CVE-2023-34450 Open this link in a new tabHow to fix?
Upgrade github.com/cometbft/cometbft/consensus
to version 0.34.29, 0.37.2 or higher.
Overview
github.com/cometbft/cometbft/consensus is a Byzantine Fault Tolerant (BFT) middleware that takes a state transition machine - written in any programming language - and securely replicates it on many machines.
Affected versions of this package are vulnerable to Denial of Service (DoS) due to the way the struct PeerState
is serialized to JSON. An attacker can trigger a deadlock in the MarshallJSON
function via logs or RPC. If the consensus
logging module is set to "debug" level (should not happen in production), and the log output format in use is JSON, the attacker can bring down the node.
Using the dump_consensus_state
RPC, the attacker can cause one communication channel to the target node to be blocked. The theoretical worst case for this attack vector 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 two 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).
Workaround
To avoid triggering a deadlock via logs, either use "plain" rather than "json" output format, or use a lower logging level than "debug", such as "info".
Details
Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.
Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.
One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.
When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.
Two common types of DoS vulnerabilities:
High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.
Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm
ws
package