Bidder might lose funds due to possible racing condition between settleWithBuyout and placeBid.
Proof of Concept
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.
Lines of code
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/AuctionWithBuyoutLoanLiquidator.sol#L129 https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/AuctionWithBuyoutLoanLiquidator.sol#L64
Vulnerability details
Impact
Bidder might lose funds due to possible racing condition between settleWithBuyout and placeBid.
Proof of Concept
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
beforesettleWithBuyout
tx, the bidder will lose their funds. BecausesettleWithBuyout
will always assume no bids are placed, it will directly transfer out the collateral NFT token and delete the auction data from storage.(https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/AuctionWithBuyoutLoanLiquidator.sol#L63C1-L66C10)
(https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/AuctionWithBuyoutLoanLiquidator.sol#L129)
Tools Used
Manual
Recommended Mitigation Steps
Consider only allow buyout strictly before the timeLimit
if (timeLimit <= block.timestamp) {//revert
.Assessed type
Other