Shardeum validator bypass loop breaking increme
The eth_getBlockHashes endpoint parses fromBlock and toBlock query parameters into integers without checking they are within the safe integer range, so a very large negative toBlock causes the loop to run indefinitely. An attacker could hang a node, causing it to be kicked out of the network and potentially preventing transaction confirmation.
- Disclosed after under an hour
33483 - [BC - Critical] shardeum validator bypass loop breaking increme...
Submitted on Jul 22nd 2024 at 01:49:42 UTC by @ZhouWu for Boost | Shardeum: Core
Report ID: #33483
Report type: Blockchain/DLT
Report severity: Critical
Target: https://github.com/shardeum/shardeum/tree/dev
Impacts:
- Shutdown of greater than or equal to 30% of network processing nodes without brute force actions, but does not shut down the network
- Network not being able to confirm new transactions (total network shutdown)
Description
Description
In shardeum endpoint eth_getBlockHashes handler, it takes in fromBlock and toBlock as query params. later down the line it would parse into an integer using parseInt(). The number is then use to control the for loop. The number is not checked if it is within safe integer range of v8 engine, which would cause the for loop to run indefinitely.
Proof of Concept
https://[target_node_ip:port]/eth_getBlockHashes?fromBlock=1000&toBlock=-9999999999999999
see impacted area here
parseInt(-9999999999999999)
// will be
-10000000000000000
With this set of input the loop will be like this for (let i = -10000000000000000; i <= "-9999999999999999"; i++), Please use debugger to examine more.
Since -10000000000000000 value is over the safe ranges of v8 integer loop i++ incremental will always yeild the same value. Thus, loop breaking condion will never satsify and hand the node indefinitely.
Impact
This'll cause the node to hang for at least a cycle or more eventually being kicked out of network, practically DoS-ing the node.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the endpoint fails to validate that the parsed block numbers are within JavaScript's safe integer range before using them as loop bounds.
Impact
The node could hang for at least a cycle or more and eventually be kicked out of the network, effectively causing a denial of service on that node and potentially preventing the network from confirming new transactions.
What the attacker needed
Network access to the node endpoint
How it was found
- Send a request to the eth_getBlockHashes endpoint with fromBlock set to a normal value and toBlock set to a very large negative number.
- Observe that the loop counter cannot increment beyond the safe integer range, so the loop never terminates and the node hangs.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A web service has an endpoint that takes two numbers from the URL and uses them to count through a range. If one number is extremely large, the counting never stops because the counter cannot increase past a certain point. This makes the server hang and stop responding.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.