Bidder can cheat auction by placing bid much higher than reserve price when there are still open liens against a token
When a token has open liens, the auction contract only charges the bidder the lien amount but records the full bid as the current bid. An attacker can place a very high bid to lock the auction or profit from the refund difference when outbid.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/107
Found by
TurnipBoy
Summary
When a token still has open liens against it only the value of the liens will be paid by the bidder but their current bid will be set to the full value of the bid. This can be abused in one of two ways. The bidder could place a massive bid like 500 ETH that will never be outbid or they could place a bid they know will outbid and profit the difference when they're sent a refund.
Vulnerability Detail
uint256[] memory liens = LIEN_TOKEN.getLiens(tokenId);
uint256 totalLienAmount = 0;
if (liens.length > 0) {
for (uint256 i = 0; i < liens.length; ++i) {
uint256 payment;
uint256 lienId = liens[i];
ILienToken.Lien memory lien = LIEN_TOKEN.getLien(lienId);
if (transferAmount >= lien.amount) {
payment = lien.amount;
transferAmount -= payment;
} else {
payment = transferAmount;
transferAmount = 0;
}
if (payment > 0) {
LIEN_TOKEN.makePayment(tokenId, payment, lien.position, payer);
}
}
} else {
//@audit-issue logic skipped if liens.length > 0
TRANSFER_PROXY.tokenTransferFrom(
weth,
payer,
COLLATERAL_TOKEN.ownerOf(tokenId),
transferAmount
);
}
We can examine the payment logic inside _handleIncomingPayment and see that if there are still open liens against then only the amount of WETH to pay back the liens will be taken from the payer, since the else portion of the logic will be skipped.
uint256 vaultPayment = (amount - currentBid);
if (firstBidTime == 0) {
auctions[tokenId].firstBidTime = block.timestamp.safeCastTo64();
} else if (lastBidder != address(0)) {
uint256 lastBidderRefund = amount - vaultPayment;
_handleOutGoingPayment(lastBidder, lastBidderRefund);
}
_handleIncomingPayment(tokenId, vaultPayment, address(msg.sender));
auctions[tokenId].currentBid = amount;
auctions[tokenId].bidder = address(msg.sender);
In createBid, auctions[tokenId].currentBid is set to amount after the last bidder is refunded and the excess is paid against liens. We can walk through an example to illustrate this:
Assume a token with a single lien of amount 10 WETH and an auction is opened for that token. Now a user places a bid for 20 WETH. They are the first bidder so lastBidder = address(0) and currentBid = 0. _handleIncomingPayment will be called with a value of 20 WETH since there is no lastBidder to refund. Inside _handleIncomingPayment the lien information is read showing 1 lien against the token. Since transferAmount >= lien.amount, payment = lien.amount. A payment will be made by the bidder against the lien for 10 WETH. After the payment _handleIncomingPayment will return only having taken 10 WETH from the bidder. In the next line currentBid is set to 20 WETH but the bidder has only paid 10 WETH. Now if they are outbid, the new bidder will have to refund then 20 WETH even though they initially only paid 10 WETH.
Impact
Bidder can steal funds due to _handleIncomingPayment not taking enough WETH
Code Snippet
Tool used
Manual Review
Recommendation
In _handleIncomingPayment, all residual transfer amount should be sent to COLLATERAL_TOKEN.ownerOf(tokenId).
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 contract records the full bid amount as the current bid but only transfers the amount needed to cover existing liens, leaving the remainder unpaid.
What the attacker needed
Token with open liens; auction is active; attacker can place a bid
The fix
The contract should send any residual transfer amount to the owner of the collateral token.
How it was found
- A token with an open lien is put up for auction.
- A bidder places a bid larger than the lien amount.
- The contract pays only the lien amount from the bidder and records the full bid as the current bid.
- When outbid, the previous bidder receives a refund of the full bid amount, which is more than they paid.
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 an auction, the highest bid is recorded, and if someone outbids you, you get your money back. Here, the system only took part of the bid amount from the bidder but still recorded the full bid. So a bidder could bid a huge amount without paying it all, and later receive a refund larger than what they actually paid.
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.