Skip to content
DoS Audit finding Intermediate

SyncStateDataGlobals will not work, effectively DoS'ing nodes

The archiver's account lookup builds a SQL IN clause with a single placeholder, so a request containing more than one account ID fails. A restoring node that asks for several accounts at once therefore cannot sync, which can deny service to that node.

br0nz3p1ck4x3 Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#39109 [W&A-Insight] syncStateDataGlobals will not work, effectively DoS'ing nodes

Submitted on Jan 22nd 2025 at 12:40:06 UTC by @br0nz3p1ck4x3 for Audit Comp | Shardeum: Ancillaries III

Description

Description

Inside src/state-manager/ArchiverSyncTracker::syncStateDataGlobals(), we find the following function that is being executed:

TypeScript
          const getAccountDataByListFromArchiver = async (payload) => {
            const dataSourceArchiver = this.archiverDataSourceHelper.dataSourceArchiver
            const accountDataByListArchiverUrl = `http://${dataSourceArchiver.ip}:${dataSourceArchiver.port}/get_account_data_by_list_archiver`
            try {
              const result = await http.post(accountDataByListArchiverUrl, payload, false, 10000)
              console.log('getAccountDataByListFromArchiver result', result)
              return result
            } catch (error) {
              console.error('getAccountDataByListFromArchiver error', error)
              return null
            }
          }

          const result = await getAccountDataByListFromArchiver(signedMessage)

A POST call is made to the archiver. The payload of this call will be an array of accountIds.

The problem is, if the length of this array is more than 1, this call will return an error.

Root Cause Analysis

The root cause is the following line in the archiver repo:AccountDataProvider.ts#L269

TypeScript
    const sql = `SELECT * FROM accounts WHERE accountId IN (?)`;

When using (?), SQLite expects a single value, not an array. To properly handle an array of values with an IN clause, you need to create the correct number of parameter placeholders based on the array length.

Impact

When the node is restoring and trying to sync, it will not be able to sync when fetching more than one accountIds, leading to an effective Denial of Service of the restoring node.

Recommendation

Change the query such that it accommodates for multiple values inside the array. If you don't want to use multiple values, consider not using an array but a normal, constant value.

Link to Proof of Concept

https://gist.github.com/bronzepickaxe/fdbf068728a5262e8611624619370df1

Proof of Concept

Proof of Concept

Check the gist here:

The original report as published on Immunefi, by br0nz3p1ck4x3. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The SQL query uses a single placeholder for an IN clause, but the code passes an array of account IDs, which SQLite does not expand into multiple placeholders.

Impact

A restoring node that requests more than one account ID cannot sync, effectively denying service to that node.

What the attacker needed

Node is restoring and syncing; request contains more than one account ID

The fix

The query should be changed to create the correct number of placeholders for the array length, or to use a single constant value instead of an array.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A node that is catching up asks an archiver for details about several accounts in one request. The archiver's database query was written to accept only one account at a time, so the request fails. The node cannot finish syncing and stays out of service.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by br0nz3p1ck4x3

View all

34 more disclosed reports, best first.

More from Shardeum: Ancillaries III

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.