Open c4-bot-3 opened 2 months ago
MiloTruck marked the issue as primary issue
MiloTruck marked the issue as satisfactory
MiloTruck marked the issue as selected for report
MiloTruck marked the issue as new finding
This was identified internally and fixed but the pr was not merged in yet so it didn't make it to the mitigation review: https://github.com/karak-network/karak-restaking/pull/439/files
Lines of code
https://github.com/karak-network/karak-arena-mitigations/blob/475cfd73744cabe239720feec4a227a739910119/src/NativeVault.sol#L509-L517
Vulnerability details
Bug description
Consider a scenario where both Alice and Bob each have 32 ETH restaked into the NativeVault. NativeVault's
totalAssets
equals 64 ETH. A slashing event occurs in the vault, resulting in the NativeVault being slashed by 2 ETH, reducingtotalAssets
to 62 ETH.NativeVault.sol#L312
Now 32 shares of both users amount to
32 * 62 / 64 = 31 ETH
, meaning that both Alice and Bob lost 1 ETH due to the slashing. After a slashing event has occurred in the NativeVault, Alice's validator looses all of its funds. Snapshot is started for Alice to reduce her assets by 32 ETH.validateSnapshotProofs()
will calculatebalanceDeltaWei
as -32, subsequently calling_updateSnapshot()
function.NativeVault.sol#L151-L159
_updateSnapshot()
calls_updateBalance()
, where_decreaseBalance()
function is invoked._decreaseBalance()
will burn all of Alice's shares and reducetotalAssets
of the NativeVault by 32 ETH.NativeVault.sol#L511-L515
After transaction has been completed,
totalAssets
are reduced to 30 ETH, leaving Bob only being able to withdraw 30 ETH, even though he should be able to withdraw 31.Impact
Loss of funds for a user.
Recommended Mitigation
_decreaseBalance()
function should calculate the amount of assets to slash based on the amount of shares of a user.Assessed type
Other