# Repayer can brick lending functionality of `LenderCommitmentGroup_Smart` by repaying excess

Repaying more than principal on a LenderCommitmentGroup_Smart loan makes totalPrincipalTokensRepaid exceed totalPrincipalTokensLended, underflowing a view used before every lend and bricking lending.

- Payout: Audit contest
- Severity: medium
- Program: Teller
- Found by: OpaBatyo
- Disclosed: 2024-11-16
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-11-teller-finance-update-judging/issues/46
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-teller-finance-update%3AM-5
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** LenderCommitmentGroup_Smart lending pool contract
**Root cause:** getTotalPrincipalTokensOutstandingInActiveLoans computes totalPrincipalTokensLended - totalPrincipalTokensRepaid without guarding against excess repayment, so totalPrincipalTokensRepaid can exceed totalPrincipalTokensLended and underflow.
**Steps:**
1. Borrow 100 from the lender pool: totalPrincipalTokensLended=100, totalPrincipalTokensRepaid=0
2. Call `repayLoan(_bidId, 101)` on TellerV2, which allows any amount >= minimum
3. repayLoanCallback adds principalAmount to totalPrincipalTokensRepaid, making it 101 > 100
4. Any subsequent lend calls getTotalPrincipalTokensOutstandingInActiveLoans, which reverts on underflow
**How found:** Code reading of the subtraction in getTotalPrincipalTokensOutstandingInActiveLoans and noticing repayLoan permits arbitrary amounts above the minimum, so repaid can exceed lended.
**Exploitation:** Attacker takes a small loan and repays slightly more than principal; the excess pushes totalPrincipalTokensRepaid above totalPrincipalTokensLended, causing a permanent underflow revert in the view invoked before every lending, blocking all new loans in the pool.
**Insight:** When a pool tracks lended minus repaid as an invariant, check whether repay entrypoints cap the amount at outstanding principal; any uncapped overpayment can invert the invariant and DoS dependent view calls.

