Stakers unfairly forfeit their unattributed node balance included in the slashed assets. #29
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-102
🤖_primary
AI based primary recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L425-L446
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L482
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L448-L474
Vulnerability details
Impact
Stakers may lose unattributed node balance included in the slashed assets.
Proof of Concept
Assuming slashing occurs while a staker has an unattributed node balance (or some Ether is withdrawn to nodeAddress after slashing), the slashed assets will be transferred from
nodeAddress
toslashStore
at L436. This may include some unattributed node balance, as slashedWithdrawable is only restricted tonode.nodeAddress.balance
at L433.https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L425-L446
The unattributed node balance included in the slashed assets signifies an additional loss of Ether for the staker due to the following two factors:
Slashing has already reduced the total assets of the NativeVault and
node.totalRestakedETH
is also decreased in L439.The unattributed node balance included in the slashed assets is not added to the
totalDeltaWei
at L482, because thenodeBalanceWei
is calculated at L459 after thenodeAddress.balance
is already decreased at L456.https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L482
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L448-L474
As a result, the staker unfairly forfeits his unallocated node balance included in the slashed assets.
Suppose the following scenario:
The state of node N is:
totalRestakedETH is 32 ether,
nodeAddress.balance is 1ether,
withdrawableCreditedNodeETH is 0.
(The unattributed node balance is 1-0=1 ether)
slashedAssets
in L430 is calculated as 1 ether. So all the unattributed node balance is included in the slashed assets.1 ether is transferred from his nodeAddress to slashStore.
Another 1 ether is lost, since the
totalRestakedETH
andconvertToAssets(balanceOf(nodeOwner))
is decreased from 32 ether to 31 ethers.Now, Alice can withdraw as most 31 ethers, which is less than the expected value 32 ethers.
Tools Used
Manual review
Recommended Mitigation Steps
There are two recommendations.
Recommendation 1:
The node balance change should be calculated before calling
_transferToSlashStore()
.Recommendation 2:
slashedWithdrawable
can be limited not to be greater thannode.withdrawableCreditedNodeETH
.Assessed type
Other
The text was updated successfully, but these errors were encountered: