This vulnerability arises when we try to liquidate a badUser that has fallen below 110% collateralization(For example: badUser’s collateral is $1099 worth of WETH and badUsers dscMinted is 1000 tokens.) where they are still profitable for a liquidator. This issue causes the s_collateralDeposited[from][tokenCollateralAddress] -= amountCollateral computation in _redeemCollateral function to result in an underflow. As a result, liquidation of the badUser’s position would not be possible, posing a risk to the stability and health of the system.
When the liquidator calls the liquidate function on a badUser that has fallen below 110% collateralization for example: badUser’s collateral is $1099 worth of WETH and badUsers dscMinted is 1000 tokens (which still makes it profitable for liquidator since it is over 100% collateralization.) the liquidate function will call _redeemCollateral function with the totalCollateralToRedeem parameter that is computed with tokenAmountFromDebtCovered + bonusCollateral which will be equal to $1100 worth of WETH. This would cause s_collateralDeposited[from][tokenCollateralAddress] -= amountCollateral
to revert with an underflow error since s_collateralDeposited[from][tokenCollateralAddress]
of badUser is $1099 worth of WETH, making it impossible to liquidate a badUser that is still profitable to liquidate for the liquidator.
Test used for this vulnerability is as follows:
This will cause the following error: [FAIL. Reason: Arithmetic over/underflow]
When token prices decline significantly, this vulnerability might prevent the system from protecting itself against defaulting users since it is not possible to liquidate , increasing the risk of financial losses and potential instability. The normal liquidation limit would be when the token is 100% collateralized since under 100% would not make liquidation profitable for the liquidator but due to this issue users that go under 110% collateralization can not be liquidated and the system would lose stability since bad users will not get liquidated.
Foundry and manual reviewing.
There should be an if statement implemented to the liquidate function that will redeem all collateral the bad user has to the person that liquidates them instead of the 10% bonus in case their collateral value goes below totalCollateralToRedeem.
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.