PoolAction::updateLeverJoin
wrongly updates assetsIn
array, leading to PositionAction4626::_onIncreaseLever
to always revert
#241
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-06
primary issue
Highest quality submission among a set of duplicates
🤖_128_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/PoolAction.sol#L181-L223
Vulnerability details
Impact
Users can use
PositionAction4626
to interact with the corresponding vault using their opened positions.PositionAction4626
allows users to deposit/withdraw/leverage their positions,increaseLever
enables users to increase their positions' collateral and debt, for the most part, it's the same as forPositionAction20
. Where users swap the lent borrow tokens for collateral tokens, and then deposit them into the position.The only change is that
PositionAction4626
allows users on top of that to join a Balancer pool with the swapped tokens. This is done inPositionAction4626::_onIncreaseLever
.The main part that we care about is
PoolAction::updateLeverJoin
which adds the upfront amount to the amounts in. The way Balancer works is that it accepts an array of "amounts in", according to the tokens array where indices should match, BUT it should skip the BPT token, this is where the function messes up.This is mainly done in the following loop:
The goal of the above loop is to add the upfront amount to the corresponding
amountIn
. The protocol passes thepoolToken
as the collaterals 4626's underlying token, which is not always true, and in most cases, it won't match any of the tokens array. Because of this, the above for loop will be wrongly updating and overriding theassetsIn
array.This blocks users from increasing the leverage of their positions where the collateral is an
ERC4626
token.Proof of Concept
In the below POC, we pass the following:
but because of what's mentioned above and the wrong "skipping" logic, the
tokensIn
comes out as:Tools Used
Manual review
Recommended Mitigation Steps
Set the
poolToken
according to the Balancer's vault and PoolId, something to:Assessed type
DoS
The text was updated successfully, but these errors were encountered: