User can free from liquidation fee if its escrow balance is less than the calculated liquidation fee
The liquidation fee is only paid if the user's escrow balance is at least the calculated fee; otherwise the fee is skipped entirely. An attacker could avoid paying the liquidation fee by ensuring their escrow balance is below the fee amount.
jayphbee Follow with catchup, corerouter and 2 others
Originally disclosed on Code4rena
Submitted by jayphbee, also found by catchup, corerouter, trustindistrust, and cccz
User can free from liquidation fee if its escrow balance less than the calculated liquidation fee.
Proof of Concept
If the liquidationFeeBps is enabled, the gov should receive the liquidation fee. But if user’s escrow balance is less than the calculated liquidation fee, gov got nothing.
https://github.com/code-423n4/2022-10-inverse/blob/main/src/Market.sol#L605-L610
if(liquidationFeeBps > 0) {
uint liquidationFee = repaidDebt * 1 ether / price * liquidationFeeBps / 10000;
if(escrow.balance() >= liquidationFee) {
escrow.pay(gov, liquidationFee);
}
}
Recommended Mitigation Steps
User should pay all the remaining escrow balance if the calculated liquidation fee is greater than its escrow balance.
if(liquidationFeeBps > 0) {
uint liquidationFee = repaidDebt * 1 ether / price * liquidationFeeBps / 10000;
if(escrow.balance() >= liquidationFee) {
escrow.pay(gov, liquidationFee);
} else {
escrow.pay(gov, escrow.balance());
}
}
This should amount to dust.
08xmt (Inverse) confirmed and commented:
Fixed in https://github.com/InverseFinance/FrontierV2/pull/15.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code only pays the liquidation fee when the escrow balance is sufficient, and does nothing otherwise, instead of paying whatever balance remains.
Impact
The protocol could lose the liquidation fee, though the judge noted this should amount to dust.
What the attacker needed
LiquidationFeeBps is enabled; user's escrow balance is less than the fee
The fix
The code was fixed to pay the remaining escrow balance to the governance address when the calculated fee exceeds the balance.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a loan is liquidated, a fee is supposed to go to the protocol. The code only takes the fee if the borrower has enough balance in their escrow account; if not, it takes nothing. So a borrower could keep their escrow balance low to avoid the fee.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.