# Penalty rate is used for pre-maturity date as well

Fraxlend's _addInterest applies the post-maturity penalty rate retroactively to the entire interval since the last accrual, overcharging borrowers who didn't call addInterest before maturity.

- Payout: Contest reward
- Severity: medium
- Program: Frax Finance
- Credited: 0xA5DF
- Disclosed: 2023-01-13
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-08-frax-findings/issues/111
- Library page: https://bugbountylibrary.com/r/c4%3A2022-08-frax%3AM-01
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** FraxlendPair interest accrual (_addInterest)
**Root cause:** When _addInterest() runs after maturity, it applies the penalty rate to the whole elapsed period since the last accrual, including time before maturity when only the normal rate should apply.
**Steps:**
1. Deploy FraxlendPair with maturity = now + 30 days and borrow.
2. Scenario A: warp 29 days, then 2 more days past maturity, call `pair.addInterest()`.
3. Scenario B: warp 29 days, call `pair.addInterest()`, then warp 2 days past maturity, call `pair.addInterest()`.
4. Compare `pair.toBorrowAmount(userBorrowShares(borrower), false)`; scenario A debt ~50% higher (2135e18 vs 1541e18).
**How found:** Reasoned about how _addInterest computes the rate for the elapsed interval when called after maturity, then built a two-scenario forge test comparing debt with and without an addInterest call just before maturity.
**Exploitation:** Borrower who is late repaying (or whose addInterest wasn't called near maturity) is charged penalty rate over the entire pre-maturity interval, inflating debt beyond intended interest.
**Insight:** For lending protocols with time-based penalty/late-fee rates, check whether accrual splits the interval at the maturity boundary; a single post-maturity accrual call can retroactively apply the penalty to pre-maturity time.
