# _baseLoanChecks() check errors for expire

Off-by-one in Gondi's loan expiry check lets a borrower re-borrow a liquidated loan at the exact expiry timestamp, clearing state and bricking auction settlement.

- Payout: Audit contest
- Severity: high
- Program: Gondi
- Found by: bin2chen
- Disclosed: 2024-07-25
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-04-gondi-findings/issues/26
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-gondi%3AH-15
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:business-logic

**Target:** MultiSourceLoan / LoanLiquidator smart contracts
**Root cause:** _baseLoanChecks uses strict `<` for expiry while _liquidateLoan uses `>` for not-due, so both pass when block.timestamp == startTime + duration, leaving the loan valid after liquidation.
**Steps:**
1. At block.timestamp == loan.startTime + loan.duration, call `liquidateLoan(loanId=1)`; passes since expirationTime > block.timestamp is false; auction starts but `_loans[1]` not yet cleared.
2. Call `addNewTranche(loanId=1)`; `_baseLoanChecks` passes (expiry `<` false), deletes `_loans[1]` and writes `_loans[2] = newLoan.hash()`.
3. When bidding ends, `loanLiquidated(loanId=1)` reverts because `_loans[1]` was cleared.
**How found:** Code-reading comparison of the two boundary checks: `_baseLoanChecks` uses `<` while `_liquidateLoan` uses `>`, revealing the equality timestamp satisfies both.
**Exploitation:** Borrower times a transaction to the exact expiry second: liquidate their own loan to start the auction, then immediately addNewTranche on the same loanId to overwrite/clear loan state, so auction settlement reverts and the NFT/funds are locked.
**Insight:** When two functions gate the same lifecycle boundary (expiry vs not-due), diff their comparison operators; an equality timestamp that satisfies both is a classic state-machine gap enabling re-entry into a supposedly closed state.

