#40000 [BC-Critical] Improper input validation in fixDeserializedWrappedEVMAccount leads to DOS and total network shutdown

Submitted on Feb 12th 2025 at 13:48:37 UTC by @Blockian for Audit Comp | Shardeum: Core IIIarrow-up-right

  • Report ID: #40000

  • Report Type: Blockchain/DLT

  • Report severity: Critical

  • Target: https://github.com/shardeum/shardeum/tree/bugbounty

  • Impacts:

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

Description

Note

This is the same bug that was already submitted in past contests, but was incorrectly fixed:34484arrow-up-right and 33941arrow-up-right As stated by you, all past reports expect those stated explicitly are in-scope.

Impact

Can be used to crash nodes.

Root Cause

The fixDeserializedWrappedEVMAccount functionarrow-up-right, which is commonly used throughout shardeum repositorie, does not perform validation on the passed data. It is possible to pass an "Array-like" object as the storageRoot,codeHash,codeByte,value, fields, which is accepted by Uint8Array.from used by the fixWrappedEVMAccountBuffersarrow-up-right/ fixAccountFieldsarrow-up-right functions called from fixDeserializedWrappedEVMAccount.

Attack Flow

  • A malicious user legitimately calls the binary/repair_oos_accounts handler, but with a malicious account data.

  • The account data is not validated before being passed to fixDeserializedWrappedEVMAccount, and causes the node to crash

Deep Dive

Trigger flow

  • binary_repair_oos_accounts handlerarrow-up-right accepts a payload

  • It then iterates its repairInstructions and extracts data from each instruction

Crash flow

Attack Flow

  • A malicious user asks a node to sign a staking certificate, also containing fields related to "remove-by-app" or "set-global".

  • The user then uses that certificate to remove a node or change the global account config, successfully passing signature validation.

Suggested Fix

Before calling Array.from validate the type is not an object, everywhere in the code.

Severity

  • This is a total network shutdown which is critical.

  • In addition, this is the same as the past reports which were critical.

Proof of Concept

Proof of Concept

The POC is a combination of the [[#Trigger flow]] from [[#Deep Dive]] to show calculateAccountHash can be reached by a malicious node, with a POC that shows calculateAccountHash can be used to crash.

  1. Apply the following changes to shardeum:

  1. Apply the following changes to core:

  1. Run a 10 nodes network (shardus start 10)

  2. Run a json-rpc-server

  3. Run the following attack script:

Was this helpful?