#40005 [BC-Critical] removal of node out of network via remove by app gossip and signature

#40005 [BC-Critical] Removal of node out of network via remove by app gossip and signature duplications

Submitted on Feb 12th 2025 at 16:25:22 UTC by @ZhouWu for Audit Comp | Shardeum: Core III

  • Report ID: #40005

  • Report Type: Blockchain/DLT

  • Report severity: Critical

  • Target: https://github.com/shardeum/shardus-core/tree/bugbounty

  • Impacts:

    • Network not being able to confirm new transactions (total network shutdown)

    • Direct loss of funds

Description

Description

In shardeum tech stack, crypto-utils lib is responsible for signing the payloads. The vulnearbility exist within the lib for the failure to sanitize and strictly control the signatures. The problem is a single singer with same payload can produced multiple different signature and still satisfy the crypto.verify(). This can result in a bypass of various multi signature mechnism. This the demostration for how it happen.

const crypto = require("@shardus/crypto-utils")
const Utils = require("@shardus/types").Utils

crypto.init("69fa4195670576c0160d660c3be36556ff8d504725be8a59b5a96509e0c994bc")
crypto.setCustomStringifier(Utils.safeStringify)

const changeNthLetterCase = (str, n) => {
  const arr = str.split('')
  arr[n] = arr[n].toUpperCase()
  return arr.join('')
}
const keypair = crypto.generateKeypair()

const payload = { foo: "bar" }

const signature1 = crypto.signObj(payload, keypair.secretKey, keypair.publicKey)
signature1.sign.sig += "z"


console.log(crypto.verifyObj(payload, signature1.sign, keypair.publicKey)) // false

The above code demostrate even though we have mutated the siganture, the crypto.verifyObj() still return true.

The implication for this shardeum is mechnism called remove by app, which allow the removal of node x given a collective group of nodes agree to it with their signatures. The problem is that now due to the crypto lib vulnearbility above a single node can not forge multiple different signature to cloak as multiple nodes. This can result in a single node removing another node without the consent of the collective group.

Proof of Concept

POC

  1. Launch a legitimate group of node with this patch.

  1. Apply following patch to malicious core repo

  1. Apply following patch to malicious shardeum repo

  1. Launch the malicious node by linking core and shardeum repo together

  2. Wait for network to go active AS WELL AS the malicious node

  3. During the first quarter of a cycle please make http GET to the malicious node's endpoint /kill/:publickey to kill a node. For example if the victim node is 0x1234 then call /kill/0x1234 to remove the node from the network. If it doesn't work please time the attack again in next cycle.

Impact

Removal of nodes - total network shutdown

Was this helpful?