Skip to content
Business logic Audit finding Intermediate

Recovery transaction can be replayed after a cancellation

The recovery transaction could be replayed after a cancellation because the nonce was not incremented during cancellation. An attacker could re-initiate a cancelled recovery by replaying the original signed transaction.

adriro Follow with bin2chen

Originally disclosed on Code4rena

Submitted by adriro, also found by bin2chen

The recovery transaction can be replayed after a cancellation of the recovery procedure, reinstating the recovery mechanism.

The Ambire wallet provides a recovery mechanism in which a privilege can recover access to the wallet if they lose their keys. The process contains three parts; all of them considered in the execute() function:

  1. A transaction including a signature with SIGMODE_RECOVER mode enqueues the transaction to be executed after the defined timelock. This action should include a signature by one of the defined recovery keys to be valid.

  2. This can be followed by two paths; the cancellation of the process or the execution of the recovery:

    • If the timelock passes, then anyone can complete the execution of the originally submitted bundle.
    • A signed cancellation can be submitted to abort the recovery process, which clears the state of scheduledRecoveries.

Since nonces are only incremented when the bundle is executed, the call that triggers the recovery procedure can be replayed as long as the nonce stays the same.

This means that the recovery process can be re-initiated after a cancellation is issued by replaying the original call that initiated the procedure.

Note: this also works for cancellations. If the submitted recovery bundle is the same, then a cancellation can be replayed if the recovery process is initiated again while under the same nonce value.

Proof of Concept

  1. Recovery process is initiated using a transaction with SIGMODE_RECOVER signature mode.
  2. Procedure is canceled by executing a signed call with SIGMODE_CANCEL signature mode.
  3. Recovery can be re-initiated by replaying the transaction from step 1.

Recommendation

Increment the nonce during a cancellation. This will stop the nonce, preventing any previous signature from being replayed.

...
  if (isCancellation) {
    delete scheduledRecoveries[hash];
+   nonce = currentNonce + 1;
    emit LogRecoveryCancelled(hash, recoveryInfoHash, recoveryKey, block.timestamp);
  } else {
    scheduledRecoveries[hash] = block.timestamp + recoveryInfo.timelock;
    emit LogRecoveryScheduled(hash, recoveryInfoHash, recoveryKey, currentNonce, block.timestamp, txns);
  }
  return;
  ...

Ivshti (Ambire) commented:

Excellent finding.

Ivshti (Ambire) commented:

Solved.

Ambire mitigated:

Increment the nonce to prevent replaying recovery transactions.

Status: Not fully mitigated. Full details in reports from adriro, carlitox477, and rbserver, and also included in the Mitigation Review section below.


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

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

The nonce is only incremented when a bundle is executed, not when a recovery is cancelled, so the original signed recovery transaction remains valid and can be replayed.

What the attacker needed

A signed recovery transaction exists; the recovery is cancelled; attacker can replay the original transaction

The fix

The nonce should be incremented during a cancellation to prevent replay of previous signatures; the project attempted a fix but it was not fully mitigated.

How it was found

  1. Initiate the recovery process using a transaction with SIGMODE_RECOVER signature mode.
  2. Cancel the procedure by executing a signed call with SIGMODE_CANCEL signature mode.
  3. Re-initiate the recovery by replaying the transaction from step 1.

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 wallet has a recovery feature: if you lose your keys, a trusted person can help you regain access after a waiting period. You can cancel a pending recovery, but the cancellation did not change a counter (called a nonce) that prevents the same signed request from being used again. So someone could simply resend the original recovery request and restart the process you just cancelled.

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 adriro

View all

57 more disclosed reports, best first.

More from Ambire Wallet - Invitational

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.