Skip to content
Smart contracts Audit finding Advanced

A malicious lien owner can exploit a reentrancy to steal LP funds

A reentrancy vulnerability in the auction end process allows a malicious lien owner to cancel the auction and take a new loan, whose lien is then deleted when control returns, enabling them to steal LP funds. The attacker can obtain a large loan without any outstanding lien, causing loss to liquidity providers.

0xRajeev Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/187

Found by

0xRajeev

Summary

A malicious lien owner can exploit a reentrancy in auctions to have their liens removed without making their payments and thus stealing LP funds.

Vulnerability Detail

A malicious lien owner can exploit a reentrancy from the callback to decreaseYIntercept() in endAuction() to call cancelAuction() and then take a new loan whose lien token is removed when control returns back to endAuction().

Impact

PoC: https://gist.github.com/lucyoa/901a7713fded73293b5e4f9452344c5a

Exploit scenario sequence:

  1. Strategist creates the public vault
  2. Liquidity provider puts 50 ETH into vault
  3. Malicious borrower takes a loan of 10 ETH by depositing NFT
  4. Borrower buys out their own lien via _buyoutLien by paying 10ETH + fee
  5. Borrower does not repay within lien duration to trigger liquidation
  6. Borrower (or someone else) triggers endAuction()
  7. Execution flow gets hijacked by borrower (lien token owner) inside call to decreaseYIntercept():
    1. Borrower cancels auction by paying reservePrice+initiatorFee (this would also go to borrower if setPayee is set before the auction as the owner of that Lien token)
    2. Borrower releases NFT to themselves
    3. Borrower now takes another loan of 50 ETH with the same NFT, vault and commitment
  8. Once control returns to AuctionHouse.endAuction, borrower's new loan's Lien token is deleted
  9. CollateralToken.endAuction releases borrower's NFT to borrower
  10. Malicious borrower steals 50 ETH from vault without any outstanding liens resulting in LP fund loss

Code Snippet

  1. https://github.com/sherlock-audit/2022-10-astaria/blob/main/lib/astaria-gpl/src/AuctionHouse.sol#L199
  2. https://github.com/sherlock-audit/2022-10-astaria/blob/main/lib/astaria-gpl/src/AuctionHouse.sol#L210-L224
  3. https://github.com/sherlock-audit/2022-10-astaria/blob/main/lib/astaria-gpl/src/AuctionHouse.sol#L202

Tool used

Manual Review

Recommendation

  1. Maintain a mapping of active public vaults.
  2. Account for malicious lien token owners via lien buyouts.
  3. Use reentrancy guards.

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

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 lack of reentrancy protection in endAuction allows an attacker to re-enter and manipulate state, causing a new lien to be deleted.

Impact

A malicious borrower could steal 50 ETH from the vault, causing loss to liquidity providers.

What the attacker needed

Malicious borrower with an NFT; Liquidity provider funds in vault; Auction triggered by non-repayment

The fix

The code should be fixed by using reentrancy guards, maintaining a mapping of active public vaults, and accounting for malicious lien token owners via lien buyouts.

How it was found

  1. Strategist creates the public vault
  2. Liquidity provider puts 50 ETH into vault
  3. Malicious borrower takes a loan of 10 ETH by depositing NFT
  4. Borrower buys out their own lien via `_buyoutLien` by paying 10ETH + fee
  5. Borrower does not repay within lien duration to trigger liquidation
  6. Borrower (or someone else) triggers `endAuction()`

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 an auction ends, the system calls a function that can trigger a callback to the attacker's contract. The attacker uses this callback to cancel the auction and take a new loan. When the original auction end continues, it mistakenly deletes the new loan's lien, letting the attacker keep the borrowed money without owing anything.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 0xRajeev

View all

61 more disclosed reports, best first.

More from Astaria

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.