Incorrect Slashing Mechanism Leading to Unintended Penalties for Unaffected Users #228
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
insufficient quality report
This report is not of sufficient quality
🤖_11_group
AI based duplicate group recommendation
Lines of code
https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/NativeVault.sol#L430
https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/NativeVault.sol#L299-L318
Vulnerability details
The current slashing mechanism does not decrease user shares proportionally to the slashed assets, which is crucial because of the
convertToAssets()
calculations, and this leads to unintended penalties for users who are not affected by the slashing event. This can result in users being unfairly penalized, impacting their staking rewards.Impact
This vulnerability results in:
Proof of Concept
Let's suppose there are 3 stakers in the vault, and three users have staked ETH with the following details:
User 1: 32 ETH
User 2: 32 ETH
User 3: 32 ETH
Total Restaked ETH: 96 ETH
Total Assets: 96 ETH
Shares: 32, 32, 32
Total Shares: 96
User 1 gets slashed by 4 ETH.
The system updates the total assets but not the shares:
Total Restaked ETH: 32, 32, 32
Total Assets: 92 ETH
Shares: 32, 32, 32
Total Shares: 96
User 2, who has not been slashed, calculates their effective assets: function
_transferToSlashStore()
:This will be 32 - 32 * 92 / 96 = 32 - 30 = 2, so the
slashedAssets
is equal to 2, which then will be slashed from the contract:Root Cause
The slashing function reduces the total assets but does not proportionally adjust the shares of the users. This imbalance causes unaffected users to experience a reduction in their effective assets during snapshots.
Tools Used
Manual review.
Recommended Mitigation Steps
Modify the slashing function to reduce the shares of the affected user proportionally to the slashed amount.
Assessed type
Other
The text was updated successfully, but these errors were encountered: