# mergeTranches()/refinancePartial() lack of nonReentrant

mergeTranches/refinancePartial lack nonReentrant, letting a malicious offer validator reenter and create two loans both claiming the same NFT collateral.

- 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/27
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-gondi%3AH-14
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:business-logic vuln:reentrancy

**Target:** MultiSourceLoan Solidity contract (mergeTranches/refinancePartial)
**Root cause:** mergeTranches() and refinancePartial() mutate _loans[] without nonReentrant, and offer validation invokes an attacker-controlled validator contract mid-execution.
**Steps:**
1. Attacker sets _loans[1] with NFT=1 and crafts LoanExecutionData whose OfferValidator[0].validator is an attacker contract.
2. Call refinanceFromLoanExecutionData(_loans[1], data) -> _processOffersFromExecutionData -> _validateOfferExecution -> _checkValidators -> attacker.validateOffer().
3. Inside validateOffer(), reenter MultiSourceLoan.mergeTranches(_loans[1]) which passes (no nonReentrant), creating _loans[3] with NFT=1.
4. Return to refinanceFromLoanExecutionData, which writes _loans[2] also containing NFT=1.
5. Now _loans[2] and _loans[3] both reference NFT=1 with attacker as lender.
6. repayLoan(_loans[2]) to recover NFT, borrow others' funds against it (_loans[100]), then repayLoan(_loans[3]) to recover NFT again.
**How found:** Code reading: noticed mergeTranches/refinancePartial lack nonReentrant while offer validation calls an external validator contract, giving a reentrancy window over _loans[].
**Exploitation:** Attacker-controlled offer validator reenters mergeTranches during refinance, producing two loans backed by the same NFT; attacker repays one to reclaim the NFT, reuses it to borrow third-party funds, then repays the second loan to reclaim the NFT again.
**Escalation:** Duplicate collateral enables borrowing other users' funds against an NFT already redeemed, extracting lender capital.
**Insight:** In lending protocols, any external call during loan mutation (e.g. offer validator callbacks) is a reentrancy vector; check whether collateral-owning loan records can be duplicated before deletion.

