Description
sign_fee_bump and compute_inner_tx_hash in crates/wallet-core/src/signer.rs both parse caller-supplied base64 XDR (req.inner_xdr / inner_xdr). Current tests cover empty string, non-base64 garbage, and a fee-bump-as-inner-xdr case, but there is no systematic corpus of truncated/bit-flipped/oversized valid-looking XDR, which is exactly the kind of input a malicious or buggy integration would send.
Requirements and Context
- Build a small corpus of mutated XDR strings derived from a valid signed payment envelope: truncated at several byte offsets, with random single-byte flips at structurally significant offsets (envelope-type discriminant, operation-count field), and one that decodes as valid base64 but invalid XDR structure.
- Every case must return
Err(WalletError::InvalidXdr) from both compute_inner_tx_hash and sign_fee_bump — never panic, never silently succeed with garbage.
Suggested Execution
Branch: test/wallet-core/malformed-xdr-corpus
Implement Changes
- Add a
mod malformed_xdr_corpus (or extend the existing tests module) in crates/wallet-core/src/signer.rs with a small table-driven test iterating the mutated cases.
- Reuse
make_inner_xdr/sealed_vector_seed already present in the test module to generate the base valid XDR before mutating it.
Test and Commit
truncated_xdr_variants_are_rejected (table-driven over several truncation offsets).
bit_flipped_xdr_variants_are_rejected (table-driven over a few structurally-significant offsets).
compute_inner_tx_hash_rejects_same_corpus (run the same corpus through compute_inner_tx_hash).
- Run
cargo test -p octo-wallet-core locally before committing.
Example Commit Message
test(wallet-core): add a malformed-XDR corpus for the fee-bump parse path
Adds table-driven truncation/bit-flip test cases against sign_fee_bump and
compute_inner_tx_hash to prove the XDR parser never panics or silently
accepts garbage, beyond the handful of ad-hoc invalid-input cases already
present.
Guidelines
- Keep the corpus small and deterministic (no randomness) so failures are reproducible — this is a regression-guard test, not a fuzzer.
- If you find an input that panics instead of returning
Err, do not fix it in this PR — open a follow-up bug issue and mark the corresponding test #[ignore] with a comment linking it.
- Reference this issue with
Closes #<issue-number> in the PR description.
Description
sign_fee_bumpandcompute_inner_tx_hashincrates/wallet-core/src/signer.rsboth parse caller-supplied base64 XDR (req.inner_xdr/inner_xdr). Current tests cover empty string, non-base64 garbage, and a fee-bump-as-inner-xdr case, but there is no systematic corpus of truncated/bit-flipped/oversized valid-looking XDR, which is exactly the kind of input a malicious or buggy integration would send.Requirements and Context
Err(WalletError::InvalidXdr)from bothcompute_inner_tx_hashandsign_fee_bump— never panic, never silently succeed with garbage.Suggested Execution
Branch:
test/wallet-core/malformed-xdr-corpusImplement Changes
mod malformed_xdr_corpus(or extend the existingtestsmodule) incrates/wallet-core/src/signer.rswith a small table-driven test iterating the mutated cases.make_inner_xdr/sealed_vector_seedalready present in the test module to generate the base valid XDR before mutating it.Test and Commit
truncated_xdr_variants_are_rejected(table-driven over several truncation offsets).bit_flipped_xdr_variants_are_rejected(table-driven over a few structurally-significant offsets).compute_inner_tx_hash_rejects_same_corpus(run the same corpus throughcompute_inner_tx_hash).cargo test -p octo-wallet-corelocally before committing.Example Commit Message
Guidelines
Err, do not fix it in this PR — open a follow-up bug issue and mark the corresponding test#[ignore]with a comment linking it.Closes #<issue-number>in the PR description.