Bids cannot be created within timeBuffer of completion of a max duration auction
A bid placed within the final time buffer of a max-duration auction causes an arithmetic underflow when the contract tries to cap the extended duration, reverting the bid. This effectively ends the auction early and cuts off bidders who intended to bid near the end.
Anurag Jain Follow with TurnipBoy, obront and 10 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/18
Found by
csanuragjain, TurnipBoy, obront, rvierdiiev, peanuts, neila, 0xRajeev, Prefix, Jeiwan, yixxas, hansfriese, minhquanym, 0x4141
Summary
The auction mechanism is intended to watch for bids within timeBuffer of the end of the auction, and automatically increase the remaining duration to timeBuffer if such a bid comes in.
There is an error in the implementation that causes all bids within timeBuffer of the end of a max duration auction to revert, effectively ending the auction early and cutting off bidders who intended to wait until the end.
Vulnerability Detail
In the createBid() function in AuctionHouse.sol, the function checks if a bid is within the final timeBuffer of the auction:
if (firstBidTime + duration - block.timestamp < timeBuffer)
If so, it sets newDuration to equal the amount that will extend the auction to timeBuffer from now:
uint64 newDuration = uint256( duration + (block.timestamp + timeBuffer - firstBidTime) ).safeCastTo64();
If this newDuration doesn't extend beyond the maxDuration, this works great. However, if it does extend beyond maxDuration, the following code is used to update duration:
auctions[tokenId].duration = auctions[tokenId].maxDuration - firstBidTime;
This code is incorrect. maxDuration will be a duration for the contest (currently set to 3 days), whereas firstTimeBid is a timestamp for the start of the auction (current timestamps are > 1 billion).
Subtracting firstTimeBid from maxDuration will underflow, which will revert the function.
Impact
- Bidders who expected to wait until the end of the auction to vote will be cut off from voting, as the auction will revert their bids.
- Vaults whose collateral is up for auction will earn less than they otherwise would have.
Code Snippet
Tool used
Manual Review
Recommendation
Change this assignment to simply assign duration to maxDuration, as follows:
auctions[tokenId].duration = auctions[tokenId].maxDuration
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 code subtracts a timestamp (firstBidTime) from a duration (maxDuration) instead of assigning maxDuration directly, causing an underflow.
Impact
Bidders who wait until the final time buffer are unable to bid because their transactions revert, so the auction ends early and the vault may receive less for its collateral.
What the attacker needed
Auction reaches max duration; bid placed within final timeBuffer
The fix
The assignment should set duration directly to maxDuration without subtracting firstBidTime.
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.
An auction has a rule that if someone bids near the end, the auction is extended a little. But when the auction is already at its maximum allowed length, the code that tries to extend it makes a maths mistake: it subtracts a large timestamp from a small duration, which the programming language treats as an error and cancels the bid. So anyone trying to bid in the last moments is blocked, and the seller may get less money.
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.