# loan.hash() does not contain protocolFee

Gondi's loan.hash() omits protocolFee, so callers can pass an arbitrary protocolFee to repayLoan/refinance and skip fees or corrupt LoanManager accounting.

- Payout: Audit contest
- Severity: medium
- Program: Gondi
- Found by: bin2chen
- Disclosed: 2024-07-25
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-gondi-findings/issues/15
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-gondi%3AM-17
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:fee-bypass

**Target:** MultiSourceLoan / LoanManager Solidity contracts
**Root cause:** The struct hash used to validate loans in _baseLoanChecks does not include the protocolFee field, so a loan with a modified protocolFee still hashes to the stored loanId.
**Steps:**
1. Read hash() in MultiSourceLoan: abi.encode omits _loan.protocolFee while struct Loan contains it.
2. Observe _baseLoanChecks compares _loan.hash() to stored _loans[_loanId], so protocolFee is unauthenticated.
3. Call repayLoan with loan.protocolFee=0 (or refinancePartial/refinanceFull with wrong fee) to avoid paying protocol fees.
4. Result: fee bypass and LoanManager accounting mismatch.
**How found:** Code reading of the hash() function against the Loan struct fields, noticing protocolFee present in struct but absent from the abi.encode in hash(), then tracing where hash() is used for validation.
**Exploitation:** Borrower submits repayLoan/refinance with a crafted Loan struct whose protocolFee is zeroed or altered; hash check passes since protocolFee is not hashed, so fees are skipped and accounting diverges.
**Insight:** When a struct is hashed for integrity checks, diff every struct field against the abi.encode list; fields added later (like fees) are commonly omitted, letting callers mutate them past the hash check.

