Borrowers might lose their collateral before liquidation, because of LiquidationPool::distributeAssets
function's visibility being external, which can lead to premature distribution of assets to the holder as form of rewards and borrowers losing their collateral.
In a vault, the collateral assets provided by the borrower are being distributed among the stake holders in the form of rewards , after the vault becomes under-collateralized, leading to liquidation of the vault, and then borrowers lose their collateral they deposited.
Which means the assets should only be distributed to holders, once liquidation process is being executed.
Liquidation process can be only executed liquidator by calling LiquidationPoolManager::runLiquidation()
function as you can see below :
At the end we can see distributeAssets
function being called in order to distribute the collateral assets provided by the borrower to all the holders
Below is the given distributeAssets
function in detail:
Now we can see here that distributeAssets
function is external
, which means anyone can call this function, and while this function is called the rewards mapping are being updated for the holder with respect to the specific tokens present in the assets on the basis of their portion in the liquidation pool
And in the end , EUROs tokens are burned , so that no one can use them further.
AND ALSO THERE NO CHECKS OF AUTHORIZATION IN BETWEEN THE FUNCTION OR THE FUNCTIONS BEING CALLED.
The vulnerability lies in the visibility of this function i.e external, its arguments can be easily determined since everything is transparent on blockchain, and anyone can hence call this function, this can lead to premature unauthorized distribution of assets i.e rewards to the holders, since this was only meant to be during the liquidation event is being executed by the liquidator, but instead can be called before the event, and would lead to distribution of assets since the rewards mapping are getting updated in this function itself.
If distribution assets takes place before the liquidation event, then the borrower's won't be then able to take back their collateral and lose all their collateral in the smart vault and the borrowers further won't be able to borrow more even if their vault was not under-collateralized leading to a huge financial loss for them. This poses a risk for the borrowers for depositing their collateral.
Manual reviewing of codebase
To mitigate this vulnerability, the smart contract should implement access control to restrict the execution of the distributeAssets function to the authorized liquidator only, i.e using onlyLiquidator
modifier, here like being used in runLiquidation
function.
Just this small change would be enough for mitigating the potential risk.
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.