Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attacker can DOS a new user in Native Restaking #74

Open
howlbot-integration bot opened this issue Aug 1, 2024 · 2 comments
Open

Attacker can DOS a new user in Native Restaking #74

howlbot-integration bot opened this issue Aug 1, 2024 · 2 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-59 grade-b Q-05 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_23_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality

Comments

@howlbot-integration
Copy link

Lines of code

https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/NativeVault.sol#L184-L187
https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/NativeVault.sol#L218-L219

Vulnerability details

Impact

An attacker (any user) can 1 time DOS a new user when he is trying to add validators to his native node.

Proof of Concept

After a user creates a native node, and proceeds to call the validateWithdrawalCredentials() function, any user can frontrun this transaction and call the validateExpiredSnapshot() function. Since the lastSnapshotTimestamp = 0 for the user's nativenode, the following check in the validateExpiredSnapshot() function would pass:
(https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/NativeVault.sol#L218-L219)

if (node.lastSnapshotTimestamp + Constants.SNAPSHOT_EXPIRY > block.timestamp)
{
revert SnapshotNotExpired();
}

This would set the node's currentSnapshotTimestamp as block.timestamp and would cause the validateWithdrawalCredentials() function to revert because of this check:
(https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/NativeVault.sol#L184-L187)

if (
beaconStateRootProof.timestamp < node.lastSnapshotTimestamp || beaconStateRootProof.timestamp < node.currentSnapshotTimestamp
)
revert BeaconTimestampTooOld();

So an attacker can DOS the user the first time he is trying to add validators to his node.

Tools Used

Manual

Recommended Mitigation Steps

Add the following checks in the validateExpiredSnapshot() function at line 217:
if (node.lastSnapshotTimestamp == 0) revert NewlyCreatedNode();

Assessed type

DoS

@howlbot-integration howlbot-integration bot added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value 🤖_23_group AI based duplicate group recommendation bug Something isn't working duplicate-59 sufficient quality report This report is of sufficient quality labels Aug 1, 2024
howlbot-integration bot added a commit that referenced this issue Aug 1, 2024
@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Aug 5, 2024
@c4-judge
Copy link
Contributor

c4-judge commented Aug 5, 2024

MiloTruck changed the severity to QA (Quality Assurance)

@c4-judge
Copy link
Contributor

MiloTruck marked the issue as grade-b

@C4-Staff C4-Staff reopened this Aug 21, 2024
@C4-Staff C4-Staff added the Q-05 label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-59 grade-b Q-05 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_23_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

2 participants