Skip to content
Race condition Audit finding Advanced

Same contract multi permits fundamentally cannot be solved via the chosen standards

Permit signatures for a token can be observed in the mempool and replayed by anyone, so when more than one permit is signed for the same token (for example granting then revoking an allowance), an attacker can front-run and execute them early, burning the approvals and resetting the allowance to zero. This makes the intended transaction revert, effectively blocking multi-permit flows.

GalloDaSballo Follow with KIntern_NA, carrotsmuggler and 2 others

Originally disclosed on Code4rena

Submitted by GalloDaSballo, also found by GalloDaSballo (1, 2), KIntern_NA, carrotsmuggler, bin2chen, and cccz

The finding is a direct follow up to: All cross-chain USDO and TOFT flows using approvals may be susceptible to permit-based DoS griefing from the Spearbit report.

Since permits are signatures, they will be available to anyone monitoring the chain. They will be usable by anyone, since the goal of permit is allowing some other msg.sender to broadcast the signature and have it work.

POC

Due to this, the current architecture is still subject to front-run exploits via the following:

  • Monitor the mempool for any sequence of permit signatures.
  • Execute all of the signatures before the transaction.

Any time, more than one permit is signed to the same token, for example, to Add Exact Allowance and Revoke it, front-running the calls will burn the approvals and reset the allowance down to 0.

The transaction, which may have worked had only one of the signatures been front-run, is unable to function as the last signature for revoking will be broadcasted right after the first one. This effectively means that the only architecture that could be used for Tapioca is single signature, with no revokes, which doesn’t seem to be the case at this time.

Mitigation

The only solution I have found at this time would be to use Permits to grant approvals (with try-catch) and not using permits to revoke approvals, as the revoke permit call could be front-run causing all xChain calls to revert.

If you wish to use exact approvals xChain(which I recommend), you’d have to solve for rounding errors when converting shares vs amounts. Due to this, you may recommend people to grant higher allowances, and then change all toft tokens to have a renounceAllowance function, which would re-set the allowance on behalf of the operator, enforcing a strict 0 -> X -> 0 allowance pattern while avoiding front-run griefs.

This would ensure that trusted Tapioca Operators receive allowances, and re-set them at the end of all of their operations, which gives a stronger security guarantee. We built something similar for eBTC, with PositionMangers here.

Assessed type

MEV

cryptotechmaker (Tapioca) confirmed and commented via duplicate Issue #83:

PR here.


The original report as published on Code4rena, by GalloDaSballo. 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

Likely the design relies on multiple permits for the same token, but permits are publicly replayable, so an attacker can consume them out of order before the intended transaction.

Impact

Any transaction relying on more than one permit for the same token could be front-run and made to revert, so only single-signature flows without revokes remain usable.

What the attacker needed

Attacker can watch the mempool; more than one permit signed per token

The fix

The reporter suggests using permits only to grant approvals (with try-catch) and not to revoke them, or adding a renounceAllowance function so operators reset allowances themselves in a strict zero-to-X-to-zero pattern; a PR was linked by the project.

How it was found

  1. Monitor the mempool for any sequence of permit signatures.
  2. Execute all of the signatures before the transaction.

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 permit is a signed message that lets someone else submit a token approval on your behalf, so anyone watching the network can see and submit it first. If you sign two permits for the same token, such as one to allow spending and one to revoke it, an attacker can submit both before your own transaction runs. Your transaction then fails because the allowance has already been reset.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by GalloDaSballo

View all

30 more disclosed reports, best first.

More from Tapioca Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.