The _withdrawFromVault
function in the LendingPool contract is responsible for rebalancing liquidity by withdrawing assets from curveVault. However, the function incorrectly sets msg.sender
as the owner of the shares instead of address(this).
This function is executed in different paths:
1- withdraw > _rebalanceLiquidity > _withdrawFromVault
2- deposit > _rebalanceLiquidity > _withdrawFromVault
3- borrow > _rebalanceLiquidity > _withdrawFromVault
A user calls withdraw(amount) to retrieve assets from LendingPool.
The function _ensureLiquidity(amount) is called to verify if there is enough liquidity.
If availableLiquidity < amount, it triggers _withdrawFromVault(requiredAmount).
Inside _withdrawFromVault, the contract calls:
curveVault.withdraw(amount, address(this), msg.sender, 0, new address[](0));
The curveVault.withdraw function has the following signature:
In this call:
receiver = address(this) (LendingPool)
owner = msg.sender (user)
As a result, the function attempts to withdraw assets of the user (msg.sender) instead of withdrawing assets owned by LendingPool (address(this)).
It also should send assets to reserveRTokenAddress
instead of address(this) or LendingPool
User transaction of withdraw/deposit/borrow reverts or user loses some of his assets in curveVault
vscode
correct format of _withdrawFromVault :
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.