Repository navigation
fix(xdr): bound decode limits to prevent memory-exhaustion DoS - #126
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: 71Root 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:
Tests
ejects_oversized_scval_from_fuzzer_without_exhausting_memory: replays the exact fuzzer input; asserts a structured decode error and no unbounded allocation.
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.