Submitted by 0xAlix2, also found by NexusAudits
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, its the same as for PositionAction20, 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 in PositionAction4626::_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 the poolToken as the collaterals 4626s underlying token, which is not always true. In most cases, it wont match any of the tokens array. Because of this, the above for loop will be wrongly updating and overriding the assetsIn array.
This blocks users from increasing the leverage of their positions where the collateral is an ERC4626 token.
In the below POC, we pass the following:
However, because of whats mentioned above and the wrong skipping logic, the tokensIn comes out as:
Set the poolToken according to the Balancers vault and PoolId, something to:
DoS
amarcu (LoopFi) confirmed
