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.
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:
-
A transaction including a signature with
SIGMODE_RECOVERmode 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. -
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
- Recovery process is initiated using a transaction with
SIGMODE_RECOVERsignature mode. - Procedure is canceled by executing a signed call with
SIGMODE_CANCELsignature mode. - 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;
...
Excellent finding.
Solved.
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.
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
- Initiate the recovery process using a transaction with SIGMODE_RECOVER signature mode.
- Cancel the procedure by executing a signed call with SIGMODE_CANCEL signature mode.
- 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.