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.
Originally disclosed on Immunefi
- 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
- Report ID: #40007
- Report Type: Blockchain/DLT
- Report severity: Critical
- Target: https://github.com/shardeum/shardeum/tree/bugbounty
- Impacts:
- Direct loss of funds
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:
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:
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
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:
- Apply the Bug Bounty Patch
- Apply the bug bounty patch for the attacker's node from the audit competition documentation.
- Start the Local Network
- Launch a local test network and wait until it reaches the processing state.
- Stake the Nodes
- Stake the nodes as required for normal network operation.
- Run the Exploit Script
- Execute
poc.jsfrom the provided Gist, supplying:- The attacker's IP and port.
- The victim's IP and port.
- Execute
- 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.
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
- Apply the bug bounty patch for the attacker's node.
- Start a local test network and wait for the processing state.
- Stake the nodes as normal network operation requires.
- Run the exploit script with the attacker's and victim's IP and port.
- 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.