Skip to content
DoS Audit finding Intermediate

Remote process crash (OOM) via post‑serialization size check and large batch aggregation in JSON‑RPC

The JSON-RPC server builds and serialises the whole response, including entire batches, in memory before checking the response size cap, and it allows very large batches by default. An unauthenticated client could send a crafted request or batch that makes the process allocate many gigabytes and be killed by the OOM killer, denying service to honest users.

RadiantLabs Follow with Almanax and johnyfwesh

Originally disclosed on Code4rena

Submitted by RadiantLabs, also found by Almanax and johnyfwesh

The JSON‑RPC server fully materializes and serializes responses before enforcing the response size cap, and it aggregates entire batches into memory before a final serialization pass. This creates a multiplicative memory footprint that an unauthenticated client can exploit to exhaust memory and crash the process under default settings.

  • Batch aggregation: rpc_handler() runs each request concurrently via futures::future::join_all(...), collects (id, Result<Box<RawValue>, JsonRpcError>) pairs, and converts them into a Vec<Response>. Each Response already contains a pre-serialized Box<RawValue> for the per‑item result.
  • Post‑serialization size check: After the batch is fully constructed, the server calls serde_json::value::to_raw_value(&response) to serialize the entire ResponseWrapper into a second large RawValue, and only then checks its size: see response_raw_value and the subsequent length check in rpc_handler(). This duplicates memory usage at the worst possible time (the entire batch), so the size cap rejects only after the peak allocation.
  • Amplification surface: eth_getLogs produces large outputs and lacks per‑endpoint concurrency gating. The RPC wrapper simply fetches and returns Vec<MonadLog> in monad_eth_getLogs(). While eth_call/eth_estimateGas have a permit‑based limiter, there is no equivalent guard for eth_getLogs in the eth_getLogs wrapper.
  • Defaults exacerbate the issue: the CLI defaults permit very large batches and a relatively high response size cap (batch_request_limit = 5000, max_response_size = 25_000_000) in Cli. With N=5000 and per‑item results of even ~200 KB, the batch holds ~1 GB of per‑item RawValue buffers before creating the final batch RawValue. With ~1.5 MB per item (wide eth_getLogs filters), this easily reaches many GB, resulting in OOM or severe swapping/CPU thrash before the size cap is applied.

The same late size check also applies to ResponseWrapper::Single. Combined with costly response builders like monad_eth_feeHistory(), a single request can allocate very large structures (e.g., reward matrices sized by block_count × len(reward_percentiles)) and only then be rejected after serialization.

Worst‑case outcome: A single crafted request or one batch forces the server to build large in‑memory results and then serialize the entire wrapper. Memory balloons and the process is terminated by the OOM killer or becomes unresponsive, denying service to honest users. This is an implementation‑specific weakness, not a generic network flood, and is exploitable on default config.

Recommended mitigation steps

Option A (preferred): stream responses with budgeting

  • Replace final serde_json::value::to_raw_value(&response) with a streaming JSON encoder for ResponseWrapper that writes to the HTTP body while tracking a byte budget.
  • Abort emission early with an error once the per‑request or aggregate batch budget is exceeded.
  • This avoids constructing a second massive RawValue.

Option B (quick hardening/defense in depth): cap batch and pre‑reject oversized batches

View detailed Proof of Concept


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

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 response size limit is enforced only after the full response or batch has been serialised into memory, and large batches are permitted by default, so peak memory use is not bounded.

Impact

A single crafted request or batch could exhaust memory and cause the process to be terminated or become unresponsive, denying service to honest users; the text notes this is exploitable on default config.

What the attacker needed

No authentication needed; default server configuration

The fix

It should be fixed by streaming responses with a byte budget that aborts early, and by capping or pre-rejecting oversized batches.

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 JSON-RPC server answers requests from programs, and it can handle many requests bundled together as a batch. This server builds every answer in memory first and only afterwards checks whether the answer is too big, so a large batch can use a huge amount of memory before any limit applies. If memory runs out, the operating system kills the process and the service stops working for everyone.

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 RadiantLabs

View all

17 more disclosed reports, best first.

More from Monad

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.