# FixedTermLoanHooks allow Borrower to update Annual Interest before end of the "Fixed Term Period"

FixedTermLoanHooks omitted a term-end check in onSetAnnualInterestAndReserveRatioBips, letting the borrower drop APR to 0% while lenders are locked in until term end.

- Payout: Audit contest
- Severity: medium
- Program: Wildcat
- Found by: Infect3d
- Disclosed: 2024-10-24
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-08-wildcat-findings/issues/77
- Library page: https://bugbountylibrary.com/r/c4%3A2024-08-wildcat%3AM-02
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** FixedTermLoanHooks hook contract (onSetAnnualInterestAndReserveRatioBips)
**Root cause:** onSetAnnualInterestAndReserveRatioBips delegates to super without checking market.fixedTermEndTime, unlike onQueueWithdrawal which reverts WithdrawBeforeTermEnd before term end.
**Steps:**
1. Deploy market with MockFixedTermLoanHooks, fixedTermEndTime = block.timestamp + 365 days
2. Confirm onQueueWithdrawal reverts with WithdrawBeforeTermEnd
3. Call hooks.onSetAnnualInterestAndReserveRatioBips(0, 0, state, "") as borrower
4. Observe APR set to 0% despite fixed term still active
**How found:** Code-reading comparison: noticed onQueueWithdrawal enforces fixedTermEndTime but the sibling hook onSetAnnualInterestAndReserveRatioBips only calls super, missing the same guard; docs state APR cannot change during fixed term.
**Exploitation:** Borrower calls setAnnualInterestAndReserveRatioBips with annualInterestBips=0 during the fixed term; lenders cannot ragequit because withdrawals revert until fixedTermEndTime, so they accrue 0% instead of the agreed APR.
**Insight:** When a hook template enforces a time-lock in one callback (withdrawals), audit every sibling callback that mutates lender-relevant terms (interest, reserve ratio) for the same guard—missing-guard bugs cluster across hook functions.

## Proof of concept (copied exactly from the original report)

**Test proving APR can be reduced before term end**

```
function testAudit_SetAnnualInterestBeforeTermEnd() external {
        DeployMarketInputs memory inputs;

    	// "deploying" a market with MockFixedTermLoanHooks
    	inputs.hooks = EmptyHooksConfig.setHooksAddress(address(hooks));
    	hooks.onCreateMarket(
    		address(this),				// deployer
    		address(1),				// dummy market address
    		inputs,					// ...
    		abi.encode(block.timestamp + 365 days, 0) // fixedTermEndTime: 1 year, minimumDeposit: 0
    	);

    	vm.prank(address(1));
    	MarketState memory state;
    	// as the fixedTermEndTime isn't past yet, it's not possible to withdraw
    	vm.expectRevert(FixedTermLoanHooks.WithdrawBeforeTermEnd.selector);
    	hooks.onQueueWithdrawal(address(1), 0, 1, state, '');

    	// but it is still possible to reduce the APR to zero
    	hooks.onSetAnnualInterestAndReserveRatioBips(0, 0, state, "");
      }
```

