# Slashings will always fail in some cases

Karak's slashAssets passes zero transferAmount to handleSlashing which reverts on ZeroAmount, blocking finalizeSlashing for all vaults in a batch.

- Payout: Audit contest
- Severity: medium
- Program: Karak
- Found by: 0xCiphky
- Disclosed: 2024-10-07
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-karak-findings/issues/7
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-karak%3AM-05
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** Core.sol / Vault.sol slashing flow
**Root cause:** slashAssets computes transferAmount = min(totalAssets, requested) and unconditionally calls handleSlashing, which reverts on amount==0. A vault drained to zero (prior slash or completed redeem) makes the whole finalizeSlashing batch revert.
**Steps:**
1. Stake vaults to DSS; request full redeem on vault1 and skip 8 days.
2. DSS calls `core.requestSlashing` with slashPercentagesWad for all operator vaults.
3. Skip 1 day; call `vault1.finishRedeem(key)` so `vault1.totalAssets()==0`.
4. Skip past SLASHING_VETO_WINDOW; call `core.finalizeSlashing(queuedSlashing)`.
5. Observe revert `ZeroAmount()` from `handleSlashing`, blocking all vaults in the batch.
**How found:** Code reading of slashAssets min() logic combined with handleSlashing's `if (amount == 0) revert ZeroAmount()` check; reasoned about the 2-day veto window allowing balance to drop to zero via withdrawals or other DSS slashes.
**Exploitation:** Not an attacker-profit exploit; a liveness/DoS condition triggered by normal user withdrawal or a prior DSS slash draining a vault to zero before a queued slash finalizes.
**Escalation:** One zero-balance vault in a multi-vault slash request blocks slashing of all other vaults; operator must re-request and wait another 2-day veto window, and stale request risks double-slash if vault refills.
**Insight:** When a batch operation takes min(requested, available) and forwards the result to a callee that rejects zero, any per-item zero state becomes a batch-wide DoS. Audit min()/clamp patterns for downstream zero-amount reverts and batch atomicity.

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

**Foundry test proving finalizeSlashing reverts with ZeroAmount**

```
function test_slash_fails() public {
        // register operator to dss, deploy vaults, stake vaults to dss
        stake_vaults_to_dss();
        // check if operator is registered to dss
        assertEq(true, core.isOperatorRegisteredToDSS(operator, dss));
        // request full withdraw from vault 1
        vault1.approve(address(vault1), 1000);
        IVault(address(vault1)).startRedeem(1000, address(this));
        skip(8 days);
        // dss request slashing
        address[] memory operatorVaults = core.fetchVaultsStakedInDSS(operator, dss);
        uint96[] memory slashPercentagesWad = new uint96[](2);
        slashPercentagesWad[0] = uint96(10e18);
        slashPercentagesWad[1] = uint96(10e18);
        SlasherLib.SlashRequest memory slashingReq = SlasherLib.SlashRequest({
            operator: operator,
            slashPercentagesWad: slashPercentagesWad,
            vaults: operatorVaults
        });
        vm.startPrank(address(dss));
        SlasherLib.QueuedSlashing memory queuedSlashing = core.requestSlashing(slashingReq);
        vm.stopPrank();
        skip(1 days);
        // finalize withdraw from vault 1
        bytes32 expectedWithdrawalKey = keccak256(abi.encode(address(this), 0));
        IVault(address(vault1)).finishRedeem(expectedWithdrawalKey);
        // check vault 1 total assets
        assertEq(vault1.totalAssets(), 0);
        skip(1 days);
        // finalize slashing reverts blocking all slashing
        vm.expectRevert(ZeroAmount.selector);
        core.finalizeSlashing(queuedSlashing);
    }
```

