# A DoS on snapshots due to a rounding error in calculations

ERC4626 rounding lets convertToAssets exceed node.totalRestakedETH, underflowing _transferToSlashStore and permanently DoSing NativeVault snapshots and withdrawals.

- Payout: Audit contest
- Severity: high
- Program: Karak
- Found by: KupiaSec
- Disclosed: 2024-10-07
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-07-karak-findings/issues/36
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-karak%3AH-03
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos vuln:precision-loss

**Target:** NativeVault.sol _transferToSlashStore / startSnapshot (ERC4626 vault)
**Root cause:** ERC4626 rounds in protocol's favor, so convertToAssets(balanceOf(nodeOwner)) can drift above node.totalRestakedETH after slashing plus dust donations; the unchecked subtraction at L430 underflows and reverts.
**Steps:**
1. Set up NativeVault with Bob's node holding 32 ETH; startSnapshot so totalRestakedETH=32e18.
2. Slash 2 ETH via core.slashAssets; totalAssets=30e18, totalSupply=32e18.
3. Bob calls startSnapshot to sweep slashed ETH; totalRestakedETH=30e18.
4. Attacker creates node, sends 15 wei (via payable cancelOwnershipHandover or direct transfer), calls startSnapshot; totalAssets=30e18+15.
5. Attacker creates second node, sends 15 wei, calls startSnapshot; totalAssets=30e18+30, totalSupply=32e18+30.
6. Now convertToAssets(Bob's shares)=30e18+1 > totalRestakedETH=30e18; Bob's startSnapshot reverts on underflow at L430.
**How found:** Code review of _transferToSlashStore's unchecked subtraction; recognized ERC4626 rounds in protocol's favor so share price only increases absent slashing, and donations via payable cancelOwnershipHandover let anyone inflate totalAssets by arbitrary wei amounts.
**Exploitation:** Attacker repeatedly creates nodes and donates dust wei to inflate totalAssets/totalSupply ratio, pushing convertToAssets above a victim node's totalRestakedETH; victim's startSnapshot then reverts permanently, blocking snapshot and potentially withdrawals.
**Escalation:** Dust donations are cheap and repeatable, so the DoS can be maintained indefinitely against any node owner, and since startSnapshot gates withdrawals, funds can be locked.
**Insight:** In ERC4626 vaults, any unchecked subtraction of convertToAssets(shares) from a stored per-user asset figure is a DoS candidate: dust donations (even via payable Ownable functions) can nudge the share price up by 1 wei and underflow the subtraction.

