Skip to content
Business logic Audit finding Advanced

Drain node staking account due to improper validation of SetCertTime internal transaction

A crafted internal SetCertTime transaction could skip full validation, including signature checks, because the internal-transaction check also accepted a nested flag. An attacker could repeatedly submit it so the victim node's staking account paid transaction fees until the balance drained.

periniondon630 Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#40007 [BC-Critical] Drain node staking account due to improper validation of SetCertTime internal transaction

Submitted on Feb 12th 2025 at 16:57:21 UTC by @periniondon630 for Audit Comp | Shardeum: Core III

Description

Brief/Intro

An attacker can bypass full validation of the SetCertTime transaction and drain the node's staking account balance.

Vulnerability Details

The validateTxnFields function, responsible for validating transactions, relies on the isSetCertTimeTx function to enforce full validation on SetCertTime internal transactions. However, an attacker can bypass this validation by exploiting a condition in isSetCertTimeTx:

TS
export function isSetCertTimeTx(tx): boolean {
  if (tx.isInternalTx && tx.internalTXType === InternalTXType.SetCertTime) {
    return true;
  }
  return false;
}

Bypassing the Validation Check

The applySetCertTime function is executed through applyInternalTx, which is triggered when isInternalTx returns true:

TS
export function isInternalTx(timestampedTx: any): boolean {
  if (timestampedTx && timestampedTx.raw) return false;
  if (timestampedTx && timestampedTx.isInternalTx) return true;
  if (timestampedTx && timestampedTx.tx && timestampedTx.tx.isInternalTx) return true;
  return false;
}

As seen in the last condition, isInternalTx can still return true even if tx.isInternalTx is false, as long as tx.tx.isInternalTx is true. This loophole allows an attacker to craft a SetCertTime transaction that:

  • Bypasses full validation, including signature verification of the proper nominee.
  • Is processed successfully even though it lacks legitimate authorization.

Impact: Draining the Staking Account

By repeatedly submitting the forged SetCertTime transaction, the attacker can:

  • Avoid proper validation while still being processed as an internal transaction.
  • Incur transaction fees with each execution, leading to a gradual depletion of the node’s staking account balance.

Since constant fees are applied every time this transaction is executed, the attacker can systematically drain the staking balance over multiple iterations.

References

https://github.com/shardeum/shardeum/blob/167e48478403918468410dd7562929653d5b9f6b/src/setup/validateTxnFields.ts#L79

Link to Proof of Concept

https://gist.github.com/periniondon630/d2090cae2e9888feff9c8b156bac406a

Proof of Concept

Proof of Concept (PoC)

To reproduce the exploit, follow these steps:

  1. Apply the Bug Bounty Patch
    • Apply the bug bounty patch for the attacker's node from the audit competition documentation.
  2. Start the Local Network
    • Launch a local test network and wait until it reaches the processing state.
  3. Stake the Nodes
    • Stake the nodes as required for normal network operation.
  4. Run the Exploit Script
    • Execute poc.js from the provided Gist, supplying:
      • The attacker's IP and port.
      • The victim's IP and port.
  5. Verify the Results
    • Observe the execution logs and check the staking account balance.
    • If successful, the victim's staking balance should be drained due to repeated transaction fees.

The original report as published on Immunefi, by periniondon630. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the internal-transaction check accepts a nested isInternalTx flag, so a transaction can be treated as internal and skip full validation even when its own flag is false.

Impact

Repeated forged transactions could drain the victim node's staking balance through accumulated fees; the text does not say whether any defence limited this.

What the attacker needed

Attacker runs a patched node; local test network; nodes staked

How it was found

  1. Apply the bug bounty patch for the attacker's node.
  2. Start a local test network and wait for the processing state.
  3. Stake the nodes as normal network operation requires.
  4. Run the exploit script with the attacker's and victim's IP and port.
  5. Check the logs and the victim's staking balance.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A node keeps a staking balance, and every transaction it processes costs a small fee. The code that decides whether a transaction is an 'internal' one could be fooled by a nested flag, so a forged transaction skipped the signature check that proves the sender is allowed. Repeating it made the victim node pay fees over and over until the balance was gone.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by periniondon630

View all

11 more disclosed reports, best first.

More from Shardeum: Core III

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.