Skip to content

Commit 2e5ec2d

Browse files
Zk-nd3rclaude
andcommitted
cap RPC response size to prevent OOM from compromised Zebra backend
node.rs rpc_call() now reads bytes with 10MB cap before json parsing. Prior version called resp.json() with no size limit on untrusted RPC data. Found by self-hunt via BountyBlitz engine. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4fbb432 commit 2e5ec2d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/node.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ impl ZebraRpcBackend {
6262
.await
6363
.context("RPC request failed")?;
6464

65-
let json: serde_json::Value = resp.json().await.context("RPC response parse failed")?;
65+
// Size-capped RPC response: prevents OOM from malicious/compromised Zebra backend
66+
let bytes = resp.bytes().await.context("RPC response read failed")?;
67+
if bytes.len() > 10 * 1024 * 1024 {
68+
anyhow::bail!("RPC response too large: {} bytes", bytes.len());
69+
}
70+
let json: serde_json::Value = serde_json::from_slice(&bytes).context("RPC response parse failed")?;
6671

6772
if let Some(error) = json.get("error") {
6873
if !error.is_null() {

0 commit comments

Comments
 (0)