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.
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:
- Strategist creates the public vault
- Liquidity provider puts 50 ETH into vault
- Malicious borrower takes a loan of 10 ETH by depositing NFT
- Borrower buys out their own lien via
_buyoutLienby paying 10ETH + fee - Borrower does not repay within lien duration to trigger liquidation
- Borrower (or someone else) triggers
endAuction() - Execution flow gets hijacked by borrower (lien token owner) inside call to
decreaseYIntercept():- Borrower cancels auction by paying
reservePrice+initiatorFee(this would also go to borrower ifsetPayeeis set before the auction as the owner of that Lien token) - Borrower releases NFT to themselves
- Borrower now takes another loan of 50 ETH with the same NFT, vault and commitment
- Borrower cancels auction by paying
- Once control returns to
AuctionHouse.endAuction, borrower's new loan's Lien token is deleted CollateralToken.endAuctionreleases borrower's NFT to borrower- Malicious borrower steals 50 ETH from vault without any outstanding liens resulting in LP fund loss
Code Snippet
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/lib/astaria-gpl/src/AuctionHouse.sol#L199
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/lib/astaria-gpl/src/AuctionHouse.sol#L210-L224
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/lib/astaria-gpl/src/AuctionHouse.sol#L202
Tool used
Manual Review
Recommendation
- Maintain a mapping of active public vaults.
- Account for malicious lien token owners via lien buyouts.
- Use reentrancy guards.
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
- Strategist creates the public vault
- Liquidity provider puts 50 ETH into vault
- Malicious borrower takes a loan of 10 ETH by depositing NFT
- Borrower buys out their own lien via `_buyoutLien` by paying 10ETH + fee
- Borrower does not repay within lien duration to trigger liquidation
- 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.