#39511 [BC-Critical] malicious node can drain balance of other node s nominator evm address
#39511 [BC-Critical] Malicious node can drain balance of other node's nominator evm address
Submitted on Jan 31st 2025 at 14:27:20 UTC by @ZhouWu for Audit Comp | Shardeum: Core III
Report ID: #39511
Report Type: Blockchain/DLT
Report severity: Critical
Target: https://github.com/shardeum/shardeum/tree/bugbounty
Impacts:
Direct loss of funds
Bypassing Penalties
Bypassing Staking Requirements
Description
Description
In shardeum there is an internal transaction type called setCertTime Tx, which persumably does what it say, it is possibily used to extend the time of a stake certification. The transaction looks like this.
{
isInternalTx: true,
internalTXType: 5,
nominee: <nodepubkey>,
timestamp: Date.now(),
nominator: <nominatorForThatNode>,
duration: 10
sign: {
sig: <signature>,
owner: <nodepubkey>
}
};In the legitimate scenario, the nominator is the staker's evm address of node operator and nominee is node publickey and the node belong to node operator. When transaciton is applied a small amount of SHM is deducted from nominator which is staker's evm address. The problem arises in the shardeum code's failure to check the if the nominee submmitted in tx is actually nominated by the nominator when it was first staked. This mean that malicious actors can put nominee address to be his own nodepubkey and put nominator address to be other staker's address then submiting the tx. Since the tx deduct small amount of SHM from nominator, the attacker can keep submitting the tx and deducting SHM from other staker's address. This is a serious vulnerability as it can be used to drain SHM from other stakers with no cost and penalty for attacker
Proof of Concept
Proof of Concept
In a actual network node will already be staked their own operators. But since we're running the whole network locally we'll have to simulate legit network.
Please apply this patch to legit
shardeumrepo to act as legit network. Note that we needed to add genesis address to stake ourselves for legit nodes. But in live network nodes are already staked before the attack. In a live network with actual live attack this genesis is not needed.
Please apply this patch to malicious
shardeumnode inshardeumrepo.
Please launch the legit network with legit
shardeumrepo to about 10 nodes.Please launch the malicious node by doing
node dist/src/index.jsin maliciousshardeumrepo.Please wait all the nodes go active. At least 10 node should go active.
Let's stake the nodes to simulate live network conditions.
Create a new directory host our exploit and staking tool.
mkdir poc && cd pocCreate a new file
stake.jsand paste the following code.
create a
package.jsonfile and paste the following code.
create a
exploit.jsfile and paste the following code.
Install the dependencies by running
npm installNow we can simulate real world condition by staking the victim node and the attacker node. !Optional you can stake all the node if you want. Make sure you have rpc server running at port 8080 too.
Run the
stake.jsfile by runningnode stake.js <nodepubkey>.Stake the victim node and malicious node
node stake.js <victimnodepubkey>andnode stake.js <maliciousnodepubkey>You can now run the exploit by doing
node exploit.js path/to/malicious/shardeum/repo/secrets.json <victimnodeip> <victimnodeport>. This will drain the victim node's balance. Examplenode exploit.js path/to/secrets.json 0.0.0.0 9001. We're using malicious node keypar in secrets.json to submit the setCertTime Tx. 18 You should be able to see output similar to following. Each transaction drain 0.01 SHM to the victim node operator evm address. In our exploit we are sending 100 transactions. with 2tps so within 1minute we're able to drain 1 SHM from victim node operator. In a live network with many node with more TPS can drain more SHM faster.
You can also cross check that vitim node's nominator balance has been drained by checking from rpc server.
Impact
A malicious actor can drain the SHM from EVM address that are not of his own leading to loss of funds without any penalies or cost to the attacker. The attack will continued to work even if malicious node is deactivated or dead.
Was this helpful?