# DOS of RSKJ server

Malformed RLP packet makes bytesToLength return -5, causing an infinite loop in decode2 that hangs the RSKJ UDP discovery server and eventually OOMs it.

- Payout: $5,000
- Severity: high
- Program: Rootstock Labs
- Found by: spacewasp
- Disclosed: 2025-06-13
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/2105808
- Library page: https://bugbountylibrary.com/r/h1%3A2105808
- Tags: area:web3 domain:network domain:web3 impact:dos kind:bounty platform:hackerone sev:high tech:java technique:fuzzing technique:source-review vuln:dos

**Target:** RSKJ node UDPv6 discovery port 5050 (RLP decoder)
**Root cause:** RLP.bytesToLength returns -5 for a crafted length prefix; the caller treats the resulting length as 0 but leaves the read position unchanged, so decode2 loops forever on the same bytes.
**Steps:**
1. Run rskj-core-5.0.0-FINGERROOT-all.jar with `-Drpc.providers.web.ws.enabled=true`; UDPv6 port 5050 opens
2. Craft an RLP message whose length prefix makes `bytesToLength` return -5
3. Send the single UDP packet to port 5050 from a python3 + pysha3 client
4. Observe the UDPServer stuck processing that one packet; other nodes' packets are never handled
5. After minutes the JVM crashes with OutOfMemoryError
**How found:** Code review of RLP.java: noticed bytesToLength can return a negative value (-5) that is accepted as legal, while the position pointer is not advanced, implying an infinite loop.
**Exploitation:** Attacker sends one malformed RLP discovery packet to UDP port 5050; the decoder spins on it indefinitely, blocking all other peer traffic and consuming memory until the node OOMs.
**Escalation:** Notes decode2 is used broadly, so other RLP entry points may be similarly reachable.
**Insight:** When a length/offset parser can return negative values, check whether the caller advances its read cursor on the error path; a zero-length result with an unchanged position is an infinite-loop DoS in any RLP/binary decoder.

## Proof of concept (copied exactly from the original report)

**Server start command exposing UDP port 5050**

```
java -classpath rskj-core-5.0.0-FINGERROOT-all.jar -Drpc.providers.web.cors=* -Drpc.providers.web.ws.enabled=true co.rsk.Start
```

