This repository has been archived by the owner on Dec 17, 2023. It is now read-only.
0xHati - safeApprove should only be used to set an initial allowance #69
Labels
Non-Reward
This issue will not receive a payout
0xHati
medium
safeApprove should only be used to set an initial allowance
Summary
_loan
within FlashLoan.sol is usingsafeApprove
, this will revert when the FlashLoan contract already has an allowance for an asset and a spender and wants to increase it.OpenZeppelin/openzeppelin-contracts#2219
Vulnerability Detail
Let's look at the implementation of
safeApprove
:As the comments indicate, this call will revert when approving from non-zero to non-zero.
Now let's look at where it's used. We see that there's a check if
allowance < amount
then we callsafeApprove
. Let's say the market is 'A' and the first flashloan issued sets the max approve to IronBank for 'A'. With time the allowance will get lower and lower as more flashloans are used for that market. Whenallowance < amount
it will try callingsafeApprove
but it will revert and it won't be possible anymore to use a flashloan for that market.Impact
It won't be possible to use a flashloan anymore for a market when an initial allowance is set and
allowance < amount
Code Snippet
Link to code
See the
loan
fragment above.Tool used
Manual Review
Recommendation
Use
safeIncreaseAllowance
, just as IronBank uses it correctly everywhere except here.Duplicate of #420
The text was updated successfully, but these errors were encountered: