#39814 [W&A-Low] Prevent new validators from joining the network by a DOS of the archiver

Submitted on Feb 8th 2025 at 03:37:15 UTC by @Franfran for Audit Comp | Shardeum: Ancillaries III

  • Report ID: #39814

  • Report Type: Websites and Applications

  • Report severity: Low

  • Target: https://github.com/shardeum/archive-server/tree/itn4

  • Impacts:

    • Taking down the application/website

    • Temporarily disabling user to access target site, such as:

  • Locking up the victim from login

  • Cookie bombing, etc.

    • RPC API crash affecting projects with greater than or equal to 25% of the market capitalization on top of the respective layer

Description

Brief/Intro

The /get_account_data_archiver endpoint exposed by public archivers can be taken down by a couple of validators (10 to be exact). This is crucial for syncing to the network and will prevent validators from participating in the network in restore mode.

Vulnerability Details

The primary reason of this issue is because of the following coding mistake in the function validateAccountDataRequest function:

If a validator makes a successful request to the /get_account_data_archiver endpoint, it will be included in the servingValidators map. This seems to be a kind of rate-limiting strategy because this endpoint may be quite expensive to respond to for the archiver. The issue is that while the account gets correctly added to this map, it is implicitly whitelisted forever given that it keeps spamming this endpoint, since it is already in the servingValidators map and that the last queried time will be overwritten every time: Making this DOS attack easy to carry and predictable because it doesn't require to hammer endpoints.

So if the validator calls this endpoint frequently enough, it will never be cleared from the map: Finally, if the amount of validators being in this map exceeds the maxValidatorsToServe (which is 10 by default), any new validator will be denied with the error response "Archiver is busy serving other validators at the moment!".

Impact Details

Because no other validator can call the /get_account_data_archiver endpoint, nodes which are just firing up will be prevented from syncing to the network if the network is in restore mode. To understand why, let's walk backwards the call to this endpoint in the @shardeum/core repo.

The URL is built here. Then, it is used to call the getAccountDataFromArchiver function. The call would likely not throw if the archiver is up, but the success flag will be set to false and will contain the expected error message Archiver is busy serving other validators at the moment!. Meaning that we go in this branch. In the case of the POC, we only have up one archiver so when calling the retryWithNextArchiver function, we never go in the throw branch but instead keep calling this function in a loop, which might be undesired behavior since the code seem to mean that it should retry a limited amount of times before failing on a fatal error.

So, if the network is currently in restore mode, it only takes 10 validators by default to take down the /get_account_data_archiver of every archiver in the network and make the syncing from archivers impossible.

References

Links attached when applicable.

Proof of Concept

Proof of Concept

Prerequisites

Choose a directory on your system. Clone these repos under the same root:

shardeum/shardeum

shardeum/core

shardeum/archiver

For each repo, install their dependencies and follow their prerequisites (compilation).

Diffs

shardeum/shardeum

shardeum/core

Make sure that the network starts and stays in restore mode.

shardeum/archiver

To make our job easier, disable the rate limit and make it such as the 10 validators would be constantly spamming this endpoint. We will do it separately.

Running the network

Make sure that your 10 instance are online!

Check logs and look again until the network started syncing.

Wait about 15 minutes until the syncing process started, check the logs again

You should observe that the logs keep spamming with

These logs seem to be never ending, the code loops and the validator will never be able to sync the network.

DOS of the archiver

Since we know that the attack works while the archiver is in a DOS state, let's now DOS it!

shardeum/core

shardeum/archiver

New validators should not be able to call this endpoint and it will return an error since it's being spammed by the first 5 validators.

Last updated

Was this helpful?