PositionAction.sol#decreaseLever with EXACT_OUT primary swaps would always brick if swapFee is non-zero. #7
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
duplicate-27
🤖_14_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
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-10-loopfi/blob/main/src/proxy/PositionAction.sol#L377
Vulnerability details
Impact
PositionAction.sol#decreaseLever with EXACT_OUT primary swaps would always brick if swapFee is non-zero.
Bug Description
Note: This is based on the 2024-07 Loopfi contest code-423n4/2024-07-loopfi-findings#191 issue. This protocol team applied a fix, but the fix is incomplete.
When performing decreaseLever, if the primary swap is EXACT_OUT, this means we are swapping collateral token an exact amount of debt token.
However, the output amount
leverParams.primarySwap.amount
is always equal to the flashLoan amount. This means we can only repay the original flashloan amount. But if fees is non-zero, the repayment will always fail.Note that the team made the change where
fee
is approved inonCreditFlashLoan
, but since the amount of tokens doesn't include fees, it would still not work.Proof of Concept
N/A
Tools Used
Manual Review
Recommended Mitigation Steps
Also add swapFees to EXACT_OUT swap output, preferrably inside the
onCreditFlashLoan()
function.Assessed type
DoS
The text was updated successfully, but these errors were encountered: