Skip to content
Business logic Audit finding Intermediate

Users can liquidate themselves before others, allowing them to take 13% above their borrowers

The canLiquidate function allowed a borrower to liquidate their own loan before it was publicly liquidatable, letting them collect the 13% liquidation fee. This meant the borrower could keep the loaned funds and gain a bonus while lenders suffered a loss.

obront Follow with caventa

Originally disclosed on Code4rena

Submitted by obront, also found by caventa

https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/AstariaRouter.sol#L611-L619

The canLiquidate() function allows liquidations to take place if either (a) the loan is over and still exists or (b) the caller owns the collateral.

In the second case, due to the liquidation fee (currently 13%), this can give a borrower an unfair position to be able to reclaim a percentage of the liquidation that should be going to their lenders.

Proof of Concept

  • A borrower puts up a piece of collateral and takes a loan of 10 WETH
  • The collateral depreciates in value and they decide to keep the 10 WETH
  • Right before the loans expire, the borrower can call liquidate() themselves
  • This sets them as the liquidator and gives them the first 13% return on the auction
  • While the lenders are left at a loss, the borrower gets to keep the 10 WETH and get a 1.3 WETH bonus

Recommended Mitigation Steps

Don’t allow users to liquidate their own loans until they are liquidatable by the public.

SantiagoGregory (Astaria) confirmed


The original report as published on Code4rena, by obront. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Likely the canLiquidate function allowed liquidation when the caller owned the collateral, without checking that the loan was actually overdue or that the caller was not the borrower.

Impact

The borrower could keep the loaned funds and gain a 13% bonus, while lenders were left at a loss.

What the attacker needed

A borrower with an active loan; collateral value drops; borrower acts before loan expiry

The fix

The project should prevent users from liquidating their own loans until the loans are liquidatable by the public.

How it was found

  1. A borrower puts up collateral and takes a loan of 10 WETH.
  2. The collateral loses value and the borrower decides to keep the 10 WETH.
  3. Right before the loan expires, the borrower calls liquidate() on their own loan.
  4. The borrower becomes the liquidator and receives the first 13% of the auction proceeds.

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.

In a lending system, if a borrower cannot repay, anyone can liquidate the loan by selling the collateral and taking a fee. Here, the borrower could trigger that liquidation on their own loan early, so they got the fee instead of an outside liquidator, while lenders lost out.

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.

More by obront

View all

46 more disclosed reports, best first.

More from Astaria contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.