Skip to content

Add claim_with_proof Merkle proof length cap #227

Description

@kilodesodiq-arch

Problem Statement. claim_with_proof walks the proof vector linearly with no upper
bound. A malicious user could submit a 1-million-element proof as a JSON-encoded
Vec<String> that the contract will iterate.

Why it matters. Resource DoS on Soroban is bound by wasm CPU; not bounding the proof
length is a free lever for an attacker.

Technical Context. verify_merkle_proof_for_claimant runs in loop { current = hash_pair(...) }. The claim_with_proof accepts any Vec<String>. There is no
MAX_PROOF_LENGTH config field today.

Expected Outcome. New Error::ProofTooLarge returned when proof.len() > config.max_proof_length.

Acceptance Criteria.

  • Test passes a 256-element proof → returns ProofTooLarge.
  • Test passes a 4-element valid proof → status == Claimed.
  • Default cap is 32; configurable via set_config to a max of 64.

Implementation Notes. Use the existing claim_with_proof entry point; add a config
load at the top of the function.

Files or modules likely to be affected. src/lib.rs, tests/aid_escrow_tests.rs.

Difficulty. Easy
Estimated effort. S



Backlog item #19 from `docs/maintainer-issue-backlog.md.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions