Skip to content
Business logic Write-up Intermediate

Mt Pelerin Double Transaction Bug Fix Review

The cancelOnHoldTransfers function failed to check whether a transfer had already been cancelled, so an attacker could pass an array containing the same transaction multiple times and receive the token amount repeatedly, draining the contract.

immunefi.com

Published on immunefi.com

On September 21, 2022, an anonymous whitehat reported a critical severity bug in Mt Pelerin’s bridge-protocol-v2 via Immunefi, which could have allowed an attacker to drain the contract of funds.

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

The function updated the transfer status to cancelled but did not verify the previous status before transferring tokens, allowing the same transfer to be processed repeatedly within one call.

Impact

An attacker could drain the contract of funds, though no user funds were lost because the bug was fixed quickly.

What the attacker needed

A transaction on hold for the attacker; ability to call the contract function

The fix

The vulnerability was fixed by adding a check that verifies the transfer status is on hold and not already cancelled.

How it was found

  1. Call cancelOnHoldTransfers with an array containing the same transaction ID repeated.
  2. The contract loops over the array and checks that the sender matches msg.sender.
  3. For each element, it sets the transfer decision to cancel and transfers the token amount to the sender.
  4. Because there is no check for prior cancellation, the same transfer is processed again and again, draining funds.

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 write-up has not been written yet. The Original tab links to the source.

A smart contract lets people cancel transfers that are on hold and get their tokens back. The code did not check if a transfer had already been cancelled, so someone could ask to cancel the same transfer many times in one call and get paid each time. This would empty the contract's funds.

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.

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.