# Bidders might lose funds due to possible racing condition between settleWithBuyout and placeBid

Overlapping timestamp boundary lets placeBid and settleWithBuyout both settle in the same block, so a bidder's funds are taken while the auction is deleted and collateral transferred out.

- Payout: Audit contest
- Severity: medium
- Program: Gondi
- Found by: oakcobalt
- Disclosed: 2024-07-25
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-gondi-findings/issues/6
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-gondi%3AM-19
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:solidity technique:race-window vuln:business-logic vuln:race-condition

**Target:** AuctionWithBuyoutLoanLiquidator.sol auction settlement contract
**Root cause:** settleWithBuyout reverts only when timeLimit < block.timestamp while _placeBidChecks reverts only when timeLimit > block.timestamp, so at exactly timeLimit both pass; settleWithBuyout assumes no bids and deletes auction data.
**Steps:**
1. Note both checks use timeLimit = _auction.startTime + _timeForMainLenderToBuy.
2. settleWithBuyout: `if (timeLimit < block.timestamp) revert` — passes at block.timestamp == timeLimit.
3. _placeBidChecks: `if (timeLimit > block.timestamp) revert` — also passes at block.timestamp == timeLimit.
4. Submit placeBid tx at exactly timeLimit; it settles first, bidder pays.
5. settleWithBuyout tx in same block then runs, deletes auction data and transfers collateral NFT out, ignoring the bid.
**How found:** Code reading of the two boundary comparisons in settleWithBuyout and _placeBidChecks, noticing the strict inequalities leave the exact timeLimit timestamp valid for both actions.
**Exploitation:** Attacker/keeper orders txs so placeBid lands at the boundary timestamp before settleWithBuyout; bidder's bid funds are captured but auction is settled as if no bid existed, collateral leaves and bidder loses funds.
**Insight:** When two mutually exclusive actions gate on the same deadline, check the boundary operator on each side: `<` vs `>` leaves the exact timestamp open to both, enabling same-block ordering races.

## Proof of concept (copied exactly from the original report)

**settleWithBuyout timeLimit check allowing equal timestamp**

```
uint256 timeLimit = _auction.startTime + _timeForMainLenderToBuy;
 |>       if (timeLimit < block.timestamp) {
            revert OptionToBuyExpiredError(timeLimit);
        }
```

**placeBid timeLimit check allowing equal timestamp**

```
uint256 timeLimit = _auction.startTime + _timeForMainLenderToBuy;
|>        if (timeLimit > block.timestamp) {
            revert OptionToBuyStilValidError(timeLimit);
        }
```

