An attacker can impose financial losses on other stakers by validating their validators prior to executing a slash. #37
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
insufficient quality report
This report is not of sufficient quality
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary recommendation
🤖_106_group
AI based duplicate group recommendation
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L168-L204
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L497-L505
https://github.com/code-423n4/2024-07-karak/blob/main/src/NativeVault.sol#L299-L318
Vulnerability details
Impact
An attacker can impose financial losses on other stakers by validating their validators prior to executing a slash.
Proof of Concept
The
validateWithdrawalCredentials()
function lacks a caller check, allowing anyone to invoke it and validate other stakers' validators. This vulnerability can be exploited by attackers to cause financial losses to other stakers.Consider the following scenario:
NativeVault
:totalAssets
: 64 ETH (Alice: 32 ETH, Bob: 32 ETH)totalSupply
: s + s = 2s (Alice's balance is s, and Bob's balance is s, too.)validateWithdrawalCredentials()
function to validate Alice's validator. This alters the state during the_increaseBalance()
function callL203
:totalAssets
: 93 ETHtotalSupply
: 3s (Alice: 2s, Bob: s)As a result, Alice's assets are calculated as
93 ETH * 2s / 3s = 62 ETH
, meaning she is slashed by 2 ETH(0.5 ETH more than expected).In the above scenario, the calculations differ slightly from the actual values because the
NativeVault
inherits fromERC4626
, which uses the exchange rate formula(totalAssets + 1) / (totalSupply + 1)
. However, the discrepancy is minimal and does not significantly impact the reported loss to Alice.Tools Used
Manual review
Recommended Mitigation Steps
It is recommended to restrict access to the
validateWithdrawalCredentials()
function, allowing only the owner of the validator or specific individuals with designated roles to call it.Assessed type
Other
The text was updated successfully, but these errors were encountered: