Rounding error vulnerability in liquidate() when calculating bonusCollateral value.
PoC:
uint256 bonusCollateral = (tokenAmountFromDebtCovered * LIQUIDATION_BONUS) / LIQUIDATION_PRECISION;
tokenAmountFromDebtCovered = 9
LIQUIDATION_BONUS = 10
LIQUIDATION_PRECISION = 100
So:
bonusCollateral = (tokenAmountFromDebtCovered * LIQUIDATION_BONUS) / LIQUIDATION_PRECISION
= (9 * 10) / 100
= 0.99
= 0 (after rounding)
When calculating:
uint256 totalCollateralToRedeem = tokenAmountFromDebtCovered + bonusCollateral;
bonusCollateral will be zero, which will cause the updated values of the following to be incorrect:
s_collateralDeposited
IERC20(tokenCollateralAddress).transfer(to, amountCollateral)
VSC, manual.
Implement rounding error mitigation, for example fixed-point math libraries, or manually implement fixed-point math calculations.
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.