Skip to content
Business logic Audit finding Advanced

Reusing old transaction receipt to rollback account balance

The binary_repair_oos_accounts handler does not verify whether a transaction receipt has already been applied, allowing an attacker to reuse an old receipt to roll back an account balance to a previous value. The updated balance is then accepted across the network.

periniondon630 Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#35707 [BC-Critical] Reusing old transaction receipt to rollback account balance

Submitted on Oct 4th 2024 at 04:43:18 UTC by @periniondon630 for Audit Comp | Shardeum: Core II

Description

Brief/Intro

Absence of transaction timestamp verification in the binary_repair_oos_accounts handler allows an attacker to reuse of old receipt to rollback account balance to a previous value.

Vulnerability Details

The binary_repair_oos_accounts P2P handler does not verify whether a transaction receipt has already been applied in the past. The timestamp is only checked in accountData, which is not signed by the consensus group. This oversight allows an attacker to use any old receipt for the same account to revert the account balance to its previous state after that receipt was initially applied. Consequently, the old receipt will be successfully pass verification, and the account update will be successfully propagated across the network.

Impact Details

An attacker can set the account balance to any previous value from old transaction receipts. The updated balance will be accepted as valid across the entire network.

References

https://github.com/shardeum/shardus-core/blob/23e06ded6744d8521cff9d749c1f1dd482c5fcb6/src/state-manager/AccountPatcher.ts#L490

Link to Proof of Concept

https://gist.github.com/periniondon630/39dc63dc1124e2975fd6efea732e4bbf

Proof of Concept

Apply the patch from the gist to the attacker's node, wait for it to become active, and then send two transactions from the same account (as shown in `poc.js` from the documentation). Also apply server_genesis.patch from documentation to shardeum repository. To launch the attack, run:

```bash curl http://ATTACKER\\_IP:ATTACKER\\_PORT/attack?accountId=e0291324263d7ec15fa3494bfdc1e902d8bd5d3d000000000000000000000000 ```

The exploit will roll back the account balance from the state after the second transaction to the balance after the first transaction by reusing the receipt from the first transaction. Run the attack only after you see the tx_removed message for both transactions in the output log.

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 handler checks a timestamp in unsigned account data instead of verifying whether the receipt was already applied.

Impact

An attacker could set the account balance to any previous value from old transaction receipts, and the updated balance would be accepted as valid across the entire network.

What the attacker needed

Attacker runs a node; node must become active; two transactions from same account

How it was found

  1. Apply the patch from the gist to the attacker's node and wait for it to become active.
  2. Send two transactions from the same account.
  3. Run the attack endpoint after seeing tx_removed messages for both transactions.

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 transaction receipt is a record that a transaction happened. The system failed to check if a receipt was already used, so an attacker could replay an old receipt to undo a later transaction and set the account balance back to what it was before. This could let them effectively reverse payments or changes they made.

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 II

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.