This repository has been archived by the owner on Dec 17, 2023. It is now read-only.
kutugu - SafeApprove require allowance is zero #13
Labels
Non-Reward
This issue will not receive a payout
kutugu
medium
SafeApprove require allowance is zero
Summary
SafeApprove require allowance is zero, should use
forceApprove
instead ofsafeApprove
.Vulnerability Detail
For flashLoan, when repay contract will approve ironBank.
It starts with allowance of 0, which is less than repay amount, so it will approve ironBank
type(uint256).max
.Over a long period of flashloan, allowance is gradually reduced until it is eventually less than the repay amount, but greater than 0. Note that flashloan only limits tokens to market ERC20 tokens(any vanilla ERC20s), it does not specify
transferFrom
won't reduce an allowance oftype(uint256).max
.When
safeApprove
is called again, due to the fact that allowance is not 0, the call will revert, and this token cannot be loaned thereafter, so it can be considered as permanent dos.Of course since
type(uint256).max
is a huge number which is fine for most tokens for a long time. But note again that thetotalSupply
of market tokens can be large, which has no limit.Impact
Medium. If allowance is reduced to less than repay amount, flashloan this market token is not available.
Code Snippet
https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/flashLoan/FlashLoan.sol#L108
Tool used
Manual Review
Recommendation
use
forceApprove
instead ofsafeApprove
.Duplicate of #420
The text was updated successfully, but these errors were encountered: