#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

  1. 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.

  2. Please apply this patch to legit shardeum repo 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.

  1. Please apply this patch to malicious shardeum node in shardeum repo.

  1. Please launch the legit network with legit shardeum repo to about 10 nodes.

  2. Please launch the malicious node by doing node dist/src/index.js in malicious shardeum repo.

  3. Please wait all the nodes go active. At least 10 node should go active.

  4. Let's stake the nodes to simulate live network conditions.

  5. Create a new directory host our exploit and staking tool. mkdir poc && cd poc

  6. Create a new file stake.js and paste the following code.

  1. create a package.json file and paste the following code.

  1. create a exploit.js file and paste the following code.

  1. Install the dependencies by running npm install

  2. Now 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.

  3. Run the stake.js file by running node stake.js <nodepubkey>.

  4. Stake the victim node and malicious node node stake.js <victimnodepubkey> and node stake.js <maliciousnodepubkey>

  5. 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. Example node 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.

  1. 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?