-
Notifications
You must be signed in to change notification settings - Fork 2
shealtielanz - Must Approve Zero
First
#136
Comments
Escalate for 10 USDC |
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
The if statement will only be entered 1 time. Therefore it won't happen the approval from non-zero to x value. Invalid |
Escalations have been resolved successfully! Escalation status:
|
shealtielanz
medium
Must Approve
Zero
FirstLine of Issue
Summary
In the
flashloan
contract, if a certain condition is true, it approves theironBank
contract to an unlimited amount oftokens
, without considering that the inputtoken
could revert if it isn't approved tozero
first.Vulnerability Detail
Take a look at the _loan function in the flashloan contract. Link here
Here it just approves the
IronBank
to the desired amount, without considering tokens that revert with approving tozero
first, and alsosafeApprove
function is depreciated in real time,safeIncreaseAllowance
orsafeDecreaseAllowance
should be used, due to race conditions and more.Impact
Some tokens (like USDT) do not work when changing the allowance from an existing
non-zero
allowance value. They must first be approved byzero
and then the actual allowance must be approved, meaning if called with such token the_loan
function will alwaysrevert
.Code Snippet
Tool used
Manual Review
,A Little Research
Recommendation
While approving to zero is the most used and standard way, it has been depreciated so I would advise the developers to use the
safeIncreaseAllowance
orsafeDecreaseAllowance
function as it mitigates this issue.A better way would be:
But the more standard way would be:
Duplicate of #420
The text was updated successfully, but these errors were encountered: