Skip to content
Business logic Audit finding Intermediate

ERC5095 redeem/withdraw does not update allowances

The ERC5095 redeem and withdraw functions check that the caller has sufficient allowance but never reduce that allowance after burning tokens. An approved account can therefore repeatedly redeem the holder's tokens, draining their funds.

kenzo Follow

Originally disclosed on Code4rena

Submitted by kenzo, also found by 0x29A, cccz, csanuragjain, GimelSec, kirk-baird, Lambda, sashiketh, shenwilly, and StErMi_

ERC5095’s redeem/withdraw allows an ERC20-approved account to redeem user’s tokens, but does not update the allowance after burning.

Impact

User Mal can burn more tokens than Alice allowed him to. He can set himself to be the receiver of the underlying, therefore Alice will lose funds.

Proof of Concept

withdraw and redeem functions check that the msg.sender has enough approvals to redeem the tokens:

            require(_allowance[holder][msg.sender] >= underlyingAmount, 'not enough approvals');

But they do not update the allowances. They then call authRedeem, which also does not update the allowances. Therefore, an approved user could “re-use his approval” again and again and redeem whole of approver’s funds to himself.

Recommended Mitigation Steps

Update the allowances upon spending.

sourabhmarathe (Illuminate) confirmed and commented:

While we did not actually intend to audit the 5095 itself, as 5095 itself is not yet final, we did describe its purpose in our codebase in the initial readme, and didn’t specify that it was not in scope.

With that context, we will leave it up to the judges whether or not to accept issues related to the ERC5095 token.


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

Impact

An approved account could repeatedly redeem the holder's tokens to itself, causing the holder to lose funds.

What the attacker needed

Victim approves attacker to spend tokens

The fix

The contract should reduce the allowance when tokens are spent.

How it was found

  1. Alice approves Mal to spend her tokens.
  2. Mal calls redeem or withdraw, passing himself as the receiver.
  3. The contract checks Mal's allowance but does not reduce it.
  4. Mal repeats the call to redeem more of Alice's tokens.

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.

In many token contracts, a user can let another person spend tokens on their behalf up to a set limit, called an allowance. Here, the contract checks the limit but forgets to subtract what was spent, so the approved person can keep spending as if nothing was used.

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 kenzo

View all

53 more disclosed reports, best first.

More from Illuminate contest

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.