# validateOffer() reentry to manipulate exchangeRate

validateOffer books outstanding loan value before pool assets transfer, inflating exchangeRate; a malicious validator callback redeems shares at the inflated rate for extra assets.

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

**Target:** Pool.validateOffer / MultiSourceLoan.emitLoan share accounting
**Root cause:** validateOffer increases _outstandingValues (raising totalAssets) before the principal is transferred out of the pool, so exchangeRate is temporarily inflated while totalSupply is unchanged.
**Steps:**
1. Set up pool with _getUndeployedAssets()=1000, _getTotalOutstandingValue()=1000, totalSupply=2000, exchangeRate 1:1.
2. Alice calls MultiSourceLoan.emitLoan() with offer.lender=pool, principalAmount=500, offer.validators=CustomContract.
3. emitLoan -> Pool.validateOffer() books _outstandingValues=1500, totalAssets=2500, exchangeRate=1.25:1.
4. emitLoan -> _checkValidators() -> CustomContract.validateOffer() callback calls pool.redeem(shares) at inflated 1.25:1 rate.
5. emitLoan then safeTransferFrom moves 500 out, restoring exchangeRate; attacker keeps extra assets.
**How found:** Code reading of validateOffer: noticed _outstandingValues is booked before assets.balanceOf decreases, and that _checkValidators runs a user-controlled callback in that window, making exchangeRate manipulable.
**Exploitation:** Attacker supplies a malicious validator contract in the offer; during the validator callback inside emitLoan, before the pool balance is transferred, they redeem pool shares at the temporarily inflated exchangeRate, extracting more underlying assets than entitled.
**Insight:** In vault/share-accounting protocols, look for state updates that raise totalAssets before the corresponding asset outflow, and any user-controlled callback (validators, hooks) executing inside that window to redeem at the inflated rate.

