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.
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
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
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.