Skip to content

fix(xdr): bound decode limits to prevent memory-exhaustion DoS - #126

Merged
Ayinkx merged 1 commit into
mainfrom
fix/xdr-decode-limits
Oct 3, 2026
Merged

Ayinkx merged 1 commit into
mainfrom
fix/xdr-decode-limits

Conversation

@Ayinkx

@Ayinkx Ayinkx commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Problem

The Fuzz workflow is failing on main. The decode_scval target found an OOM (memory-exhaustion denial of service) in devkit-xdr:

cargo fuzz run decode_scval fuzz/artifacts/decode_scval/oom-acb2aaa1... Error: Fuzz target exited with exit status: 71

Root cause

crates/devkit-xdr/src/lib.rs decoded untrusted XDR with Limits::none(), which sets depth and len to their maximum values — i.e. no limits. In stellar-xdr, variable-length types call consume_len(len) and then allocate �ec![0u8; len]. With no limit, a crafted length prefix requests an enormous allocation.

Fix

Apply bounded reader limits:

  • depth: 128 (stack safety)
  • len: 16 MiB (bounds total bytes read; a declared length that would exceed this is rejected before allocation)

Tests

ejects_oversized_scval_from_fuzzer_without_exhausting_memory: replays the exact fuzzer input; asserts a structured decode error and no unbounded allocation.

  • limits_are_bounded: guards against a regression back to unbounded limits.

Full gate passes: cargo fmt --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo test --workspace.

Fixes the failing Fuzz workflow on main.

@Ayinkx
Ayinkx merged commit 14f48b3 into main Oct 3, 2026
5 checks passed
@Ayinkx
Ayinkx deleted the fix/xdr-decode-limits branch October 3, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant