Skip to content
Business logic Audit finding Advanced

LienToken : Lender and liquidator can collude to block auction and seize collateral

A lender can transfer their lien token to an address that causes ERC20 transfers to revert, such as a USDC blocklisted address, preventing the borrower from making payments and blocking all auction bids. The lender and liquidator can then collude to settle the loan for zero payment and seize the borrower's collateral.

horsefacts Follow with peakbolt and KIntern_NA

Originally disclosed on Code4rena

Submitted by horsefacts, also found by peakbolt and KIntern_NA

https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L849 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L642-L643

If a lender offers a loan denominated in an ERC20 token that blocks transfers to certain addresses (for example, the USDT and USDC blocklist), they may collude with a liquidator (or act as the liquidator themselves) to prevent loan payments, block all bids in the liquidation auction, and seize the borrower’s collateral by transferring a LienToken to a blocked address.

LienTokens act as bearer assets: if a lender transfers their lien token to another address, the lien’s new payee will be the ownerOf the token:

LienToken#_getPayee

  function _getPayee(LienStorage storage s, uint256 lienId)
    internal
    view
    returns (address)
  {
    return
      s.lienMeta[lienId].payee != address(0)
        ? s.lienMeta[lienId].payee
        : ownerOf(lienId);
  }

The payee address returned by _getPayee is used as the recipient address of loan repayments via makePayment:

LienToken#_payment

    s.TRANSFER_PROXY.tokenTransferFrom(stack.lien.token, payer, payee, amount);

…as well as post-liquidation payments from the clearinghouse via payDebtViaClearingHouse:

LienToken#_paymentAH

    if (payment > 0)
      s.TRANSFER_PROXY.tokenTransferFrom(token, payer, payee, payment);

If an adversary tranfers their LienToken to an address that causes these attempted transfers to revert, like an address on the USDC blocklist, the borrower will be unable to make payments on their lien, the loan will eventually qualify for liquidation, and all bids in the Seaport auction will revert when they attempt to send payment to the blocklisted address.

Following the failed auction, the liquidator can call CollateralToken#liquidatorNFTClaim, which calls ClearingHouse#settleLiquidatorNFTClaim and settles the loan for zero payment, claiming the “liquidated” collateral token for free:

ClearingHouse#settleLiquidatorNFTClaim

  function settleLiquidatorNFTClaim() external {
    IAstariaRouter ASTARIA_ROUTER = IAstariaRouter(_getArgAddress(0));

    require(msg.sender == address(ASTARIA_ROUTER.COLLATERAL_TOKEN()));
    ClearingHouseStorage storage s = _getStorage();
    ASTARIA_ROUTER.LIEN_TOKEN().payDebtViaClearingHouse(
      address(0),
      COLLATERAL_ID(),
      0,
      s.auctionStack.stack
    );
  }

The lender will lose the amount of their lien, but can seize the borrower’s collateral, worth more than their individual lien. Malicious lenders may offer small loans with attractive terms to lure unsuspecting borrowers. Note also that the lender and liquidator can be one and the same—they don’t need to be different parties to pull off this attack! A clever borrower could potentially perform this attack as well, by acting as borrower, lender, and liquidator, and buying out one of their own liens by using loaned funds.

(The failed auction liquidation logic above strikes me as a little odd as well: consider whether the liquidator should instead be required to pay a minimum amount covering the bad debt in order to claim the collateral token, rather than claiming it for free).

Impact

  • Malicious lender/liquidator loses amount of their lien, but keeps collateral NFT.
  • Additional liens in the stack cannot be repaid. These other lenders take on bad debt and lose the amount of their liens.
  • Borrower loses their collateral NFT, keeps full amount of their liens.

Recommendation

This may be difficult to mitigate. Transferring a lien to a blocklisted address is one mechanism for this attack using USDT and USDC, but there are other ways arbitrary ERC20s might revert. Two potential options:

  • Maintain an allowlist of supported ERC20s and limit it to well behaved tokens—WETH, DAI, etc.
  • Do not “push” payments to payees on loan payment or auction settlement, but handle this in two steps—first receiving payment from the borrower or Seaport auction and storing it in escrow, then allowing lien owners to “pull” the escrowed payment.

Test Case

See warden’s original submission for full details.

SantiagoGregory (Astaria) confirmed

Picodes (judge) increased the severity to High


The original report as published on Code4rena, by horsefacts. 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 contract pushes payments to the lien owner without checking whether the transfer will succeed, so a reverting transfer blocks repayment and auction settlement.

Impact

The lender loses the lien amount but seizes the borrower's collateral, and other lenders in the stack may also lose their funds; the attack requires a token that can block transfers, such as USDC or USDT.

What the attacker needed

Lender offers loan in a token that can block addresses; Lender transfers lien to a blocked address; Liquidator colludes or is the same as lender

The fix

The protocol should either allowlist well-behaved ERC20 tokens or change payments to a pull model where funds are escrowed and lien owners withdraw them, so a reverting transfer cannot block repayment or auction settlement.

How it was found

  1. Lender offers a loan in an ERC20 token that can block transfers to certain addresses.
  2. Lender transfers the LienToken to a blocked address.
  3. Borrower attempts to make a payment, but the transfer to the blocked payee reverts.
  4. Loan qualifies for liquidation, and all auction bids revert when trying to pay the blocked address.
  5. Liquidator calls CollateralToken#liquidatorNFTClaim, which settles the loan for zero payment and claims the collateral.

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.

A lender gives a loan and receives a token representing the right to be repaid. If the lender sends that token to an address that the loan token (like USDC) refuses to send money to, the borrower cannot repay and the auction cannot pay the lender. The lender and a liquidator can then work together to take the borrower's collateral for free.

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 horsefacts

View all

8 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.