# Lender DoS if all asset is borrowed or realized

Cap's realizeRestakerInterest calls distributeRewards even when realizedInterest is 0, reverting with InsufficientReward and DoSing repay/borrow/liquidation when all assets are borrowed.

- Payout: Audit contest
- Severity: medium
- Program: Cap
- Found by: Bigsam
- Disclosed: 2025-07-07
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-07-cap-judging/issues/150
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-07-cap%3AM-3
- 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:** LendingPool BorrowLogic / Delegation reward distribution
**Root cause:** realizeRestakerInterest lacks a zero check on realizedInterest, so it calls IVault.borrow(0) and IDelegation.distributeRewards with no rewards held, reverting in Symbiotic DefaultStakerRewards with InsufficientReward.
**Steps:**
1. Borrow all USDC from lender so realizedInterest becomes 0 on realization
2. Time travel 90 days to accrue interest
3. Call `lender.repay(address(usdc), 5000e6, user_agent)`
4. Observe revert `InsufficientReward()` from distributeRewards
**How found:** Code reading of realizeRestakerInterest: noticed distributeRewards is called unconditionally even when realizedInterest==0, then traced to Symbiotic's InsufficientReward check.
**Exploitation:** Attacker frontruns time-sensitive operations (repay, liquidation) by triggering realizeRestakerInterest when realizedInterest is 0, or drains vault balance via realization to brick incoming operations.
**Escalation:** One agent can brick another agent's repay or block liquidations; frontrunning realization drains vault balance to DoS borrow/repay/liquidation.
**Insight:** When a library calls an external reward distributor, check whether zero-amount paths still invoke it; reward contracts often revert on zero rewards, turning a benign no-op into a DoS on all callers of that path.

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

**Foundry PoC test showing repay DoS**

```
function test_submissionValidity() public {
        _setAssetOraclePrice(address(weth), 2000e8);
        vm.startPrank(user_agent);
        // borrows all USDC
        lender.borrow(address(usdc), 12000e6, user_agent);

        _timeTravel(90 days);
        usdc.approve(address(lender), 5000e6);
        // repay is DoSed
        vm.expectRevert(abi.encodeWithSignature("InsufficientReward()"));
        lender.repay(address(usdc), 5000e6, user_agent);
        vm.stopPrank();
    }
```

