Bidders might lose funds due to possible racing condition between settleWithBuyout and placeBid
The settleWithBuyout and placeBid functions can both be called at the same timestamp, allowing a bidder to place a bid that is then ignored when settleWithBuyout executes, causing the bidder to lose their funds.
Submitted by oakcobalt, also found by oakcobalt
In AuctionWithBuyoutLoanLiquidator.sol, settleWithBuyout and placeBid are allowed at an overlapping timestamp (_auction.startTime + _timeForMainLenderToBuy). This allows settleWithBuyout and placeBid to be settled at the same block.
When placeBid tx settles at _auction.startTime + _timeForMainLenderToBuy before settleWithBuyout tx, the bidder will lose their funds. Because settleWithBuyout will always assume no bids are placed, it will directly transfer out the collateral NFT token and delete the auction data from storage.
function settleWithBuyout(
address _nftAddress,
uint256 _tokenId,
Auction calldata _auction,
IMultiSourceLoan.Loan calldata _loan
) external nonReentrant {
...
uint256 timeLimit = _auction.startTime + _timeForMainLenderToBuy;
|> if (timeLimit < block.timestamp) {
revert OptionToBuyExpiredError(timeLimit);
}
...
function _placeBidChecks(address _nftAddress, uint256 _tokenId, Auction memory _auction, uint256 _bid)
internal
view
override
{
...
uint256 timeLimit = _auction.startTime + _timeForMainLenderToBuy;
|> if (timeLimit > block.timestamp) {
revert OptionToBuyStilValidError(timeLimit);
}
Recommended Mitigation Steps
Consider to only allow buyout strictly before the timeLimit if (timeLimit <= block.timestamp) {//revert.
Strict to
>=.
Status: Mitigation confirmed. Full details in reports from oakcobalt, minhquanym and bin2chen.
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 time check in settleWithBuyout uses a strict less-than comparison, while placeBid uses a strict greater-than comparison, so both allow the exact boundary timestamp.
Impact
A bidder could lose their bid funds if their transaction is settled just before the buyout settlement at the overlapping timestamp.
What the attacker needed
Auction reaches the exact boundary timestamp; Bidder places bid at that timestamp; Buyout settles after the bid in the same block
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 this auction contract, there is a time window where two different actions are allowed at the exact same moment. If a bidder places a bid at that moment, but the seller's buyout action happens first, the bidder's money is taken but they get nothing because the auction is closed and the collateral is transferred away.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.