# There is no way to liquidate a position if it breaches maxDebtPerCollateralToken value creating bad debt.

LendingTerm loans can exceed maxDebtPerCollateralToken via interest accrual yet remain uncallable, blocking liquidation and creating bad debt.

- Payout: Contest reward
- Severity: medium
- Program: Ethereum Credit Guild
- Credited: sl1
- Disclosed: 2024-02-22
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-12-ethereumcreditguild-findings/issues/1057
- Library page: https://bugbountylibrary.com/r/c4%3A2023-12-ethereumcreditguild%3AM-07
- Tags: domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:liquidation

**Target:** LendingTerm.sol borrow/partialRepay/call liquidation flow
**Root cause:** _call() only permits liquidation on term deprecation or missed partialRepay deadline; no health check on debtPerCollateralToken, so a loan breaching maxDebtPerCollateralToken via accrued interest cannot be liquidated.
**Steps:**
1. Deploy term with interestRate 15%, minPartialRepayPercent 10%, maxDebtPerCollateralToken 2000e18.
2. Borrow 30_000e18 CREDIT against 15e18 collateral (debtPerCollateral == 2000).
3. Warp 3 years; loanDebt becomes 39_000e18.
4. Call `term.partialRepay(loanId, loanDebt * minPartialRepayPercent / 1e18)` — allowed even after missed deadline.
5. New debtPerCollateral = 2080 > max; `term.call(loanId)` reverts 'LendingTerm: cannot call'.
6. Run via `forge test --match-test testBreakMaxDebtPerCollateralToken -vv`.
**How found:** Read _borrow's maxBorrow check vs _call's narrow liquidation conditions; noticed partialRepay only enforces minPartialRepayPercent, so interest can push debtPerCollateral above max without triggering callability.
**Exploitation:** Borrower lets interest accrue past maxDebtPerCollateralToken and only repays minPartialRepayPercent; position stays uncallable, forcing GUILD to offboard the whole term to liquidate, harming lenders and risking bad debt.
**Escalation:** Offboarding the entire term force-closes all positions, increasing loss probability and cutting lender interest.
**Insight:** Compare the invariant enforced at position-open (_borrow maxBorrow) against the conditions that permit liquidation (_call); if the open-time bound can be violated later by interest accrual without a corresponding liquidation trigger, positions become unliquidatable.
