Borrower can cause a DoS by frontrunning a liquidation and repaying as low as 1 wei of the current debt
0xStalin Follow with J4de and rvierdiiev
Originally disclosed on Code4rena
Submitted by 0xStalin, also found by J4de and rvierdiiev.
Borrowers can cause DoS when the liquidator attempts to liquidate 100% of the borrower’s position. The borrower needs to frontrun the liquidation tx and repay a slight portion of the debt, paying as low as 1 wei will make the borrowBalance to be less than what it was when the liquidator sent the tx to liquidate the position.
Proof of Concept
If a liquidator intends to liquidate the entire position, but the borrower frontruns the liquidator’s transaction and repays an insignificant amount of the total debt, will cause the borrowBalance to be less than it was when the liquidator sent its transaction; thus, will cause the value of the maxClose variable to be less than the repayAmount that the liquidator set to liquidate the whole position, which will end up causing the tx to be reverted because of this validation
Example:
- There is a position of 100 WBNB to be liquidated, the liquidator sends the
repayAmountas whatever themaxClosewas at that point, the borrower realizes that 100% of its position will be liquidated and then frontruns the liquidation transaction by repaying an insignificant amount of the total borrow. - When the liquidation transaction is executed, the
maxClosewill be calculated based on the newborrowBalance, which will cause the calculation ofmaxCloseto be less than the totalrepayAmountthat was sent, and the transaction will be reverted even though the position is still in a liquidation state
Recommended Mitigation Steps
Instead of reverting the tx if the repayAmount is greater than maxClose, recalculate the final repayAmount to be paid during the execution of the liquidation and return this calculated value back to the function that called the preLiquidateHook().
function preLiquidateHook(
...
uint256 repayAmount,
...
+ ) external override returns(uint256 repayAmountFinal) {
...
...
- if (repayAmount > maxClose) {
- revert TooMuchRepay();
- }
+ repayAmountFinal = repayAmount > maxClose ? maxClose : repayAmount
Assessed type
DoS
chechu (Venus) disagreed with severity and commented:
Suggestion: Med
Front running attacks can be easily avoided by the liquidator, connecting to the right nodes and using private mempools. Moreover, the borrower will need to spend gas to defend their position against several liquidators.
0xean (judge) decreased severity to Medium and commented:
I think Med makes sense here, but will be open to warden comments during QA process.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity doS bug in Venus Prime. Code4rena made it public on 9 August 2023. Found in the 2023-05-venus audit contest (finding M-08), also found by 2 other wardens.
About DoS
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.