#39994 [BC-Critical] Tricking nodes into signing nearly-arbitrary data

Submitted on Feb 12th 2025 at 12:06:28 UTC by @Blockian for Audit Comp | Shardeum: Core III

  • Report ID: #39994

  • 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:34484 and 33632 As stated by you, all past reports expect those stated explicitly are in-scope.

Impact

Can be used to trick nodes into signing nearly arbitrary data, and then used to kick nodes out of the network, to add nodes to the network, to change global state, and so on.

Root Cause

The root cause it the fact that the logic of signing staking certificates doesn't validate other fields in the object. Another cause (that isn't the root cause but a critical part of the exploit) is that endpoints that expect signed data don't validate that the signed data doesn't contain unexpected fields.

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.

Deep Dive

  • The binary_sign_app_data endpoint handler calls signAppData without validation

  • signAppData calls signAsNode without validating anything besides the data that is related to the staking node (stake, nominee, nominator, certExp)

  • The remove-by-app handler calls verifyRemoveCertificate

  • verifyRemoveCertificate only validates fields related to node removal (nodePublicKey and cycle)

Suggested Fix

A few changes need to be made:

  1. Every place that calls signAsNode should remove all unnecessary fields

  2. Every place that checks a signature should remove all unnecessary fields

Severity

  • This allows to kick nodes from the network and so is critical as evident by many past reports

  • This also allows changing global state which is also critical

Proof of Concept

Proof of Concept

  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?