PositionAction4626::increaseLever
will always revert
#245
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
edited-by-warden
M-05
primary issue
Highest quality submission among a set of duplicates
🤖_01_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-loopfi/blob/main/src/proxy/PositionAction4626.sol#L129
Vulnerability details
Impact
Users can use
PositionAction::increaseLever
to increase their positions' leverage, i.e. increasing both the collateral and debt, by taking a flash loan and doing some swaps. At the end of the process, after swapping "borrow" tokens to underlying tokens they should be returned to the vault under the position's "name".For ERC20 collateral positions, this is happening in
PositionAction20::_onIncreaseLever
(that gets called inPositionAction::onFlashLoan
) which approves the vault to spend some amount and then returns the amount to be later sent using the following inPositionAction::onFlashLoan
:However, for ERC4626 collateral positions,
PositionAction4626::_onIncreaseLever
is both approving the amount and depositing it into the vault underaddress(this)
which IS NOT the position's proxy butPositionAction4626
contract as it is the flash loan callback function and isn't delegated likeincreaseLever
. When_onIncreaseLever
finishes, it'll try to deposit the collateral AGAIN in the vault using https://github.com/code-423n4/2024-07-loopfi/blob/main/src/proxy/PositionAction.sol#L416-L422, which will for sure revert, as the approval was spent and no funds are left to make the deposit.This will cause
PositionAction4626::increaseLever
to always revert and never work, blocking users from leveraging their positions.Proof of Concept
Tools Used
Manual review
Recommended Mitigation Steps
In
PositionAction4626::_onIncreaseLever
, replace:with:
return addCollateralAmount;
Assessed type
DoS
The text was updated successfully, but these errors were encountered: