Skip to content
Business logic Audit finding Intermediate

Zap contract’s redeem() function doesn’t check which token the user wants to receive

The redeem function in the Zap contract allows a user to specify any ERC20 token to receive, without checking that it is wBTC or renBTC. An attacker could redeem for an unintended token, potentially harming themselves.

Ruhum Follow

Originally disclosed on Code4rena

Submitted by Ruhum

Impact

In the redeem() function, the user can pass a token address. That’s the token they receive in return for the ibbtc they give back. Because of missing address checks the user can provide any possible ERC20 token here without the function reverting.

Although it’s not strictly specified in the code I expect that the user should only be able to redeem wBTC or renBTC tokens since they should also only be able to deposit those.

Proof of Concept

Zap.sol L216-L238

Tools Used

Manual Analysis

Recommended Mitigation Steps

Verify that the passed token address is either wBTC or renbtc

tabshaikh (BadgerDAO) disagreed with severity:

best practice to add wBTC or renbtc in require, disagree on the severity

GalloDaSballo (BadgerDAO) commented:

Agree with the finding since only user can rekt themselves I believe this to be a medium severity finding we’ll mitigate by adding a slippage check at the end of the function

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

A user could redeem for an unintended token, potentially losing funds, but only the user themselves is affected.

What the attacker needed

Access to the redeem function

The fix

The function should be fixed by verifying that the passed token address is either wBTC or renBTC, and adding a slippage check.

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 smart contract lets people swap one token for another. The redeem function is supposed to give back only certain tokens, but it doesn't check which token you ask for. So you could ask for a different token and the contract would allow it, which might cause you to lose money.

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 Ruhum

View all

55 more disclosed reports, best first.

More from BadgerDAO Zaps 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.