When Holders want to remove their staked tokens, they will make a call to LendingPool::decreasePosition
, and remove their tokens, and if the user removes their tokens completely, their position will be deleted, but the problem that arises with that is that any pending stakes that the holder has that has not being consolidated will be lost
When Users call decreasePosition
it checks if they have a pending stake that has not been consolidated, and it adds it to the position, but as you will see below it does not return that the user still has an unmatured pending stake left, it just proceeds
As see above if the date has not yet being 1 day it just skips the if statement
Now we will look at the decreasePosition
function below to understand how this vulnerability will happen
As described Before the Holder will remove their whole position, and now as the code snippet shows, if the position is empty the position is deleted which means that the holder position is no longer stored on the contract
But The User still has a pending stake that has not been added to their position, but the position of the holder is now deleted which means that when consolidatePendingStake
is called by any action, it will results into loss of funds of the staked tokens for the Holder as shown the snippet below
As shown Above once the stake is matured it tries to add the stakes to the deleted positions, but the position does not exists anymore, which means that no effect of the addition will be recorded on the state of the contract, Then after this the pending stake will be deleted which means loss of record for the holder which will result in the loss of funds
Loss of Funds For users that still has pending stakes left, after emptying their positions using decreasePosition
Manual Review
The Following addition should be added to the decreasePosition
function
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.