Skip to content

fix(psbt): reject trailing byte when parsing - #541

Closed
KY-U wants to merge 1 commit into
ElementsProject:masterfrom
KY-U:2027-08-fail-psbt-on-trailing-bytes
Closed

fix(psbt): reject trailing byte when parsing#541
KY-U wants to merge 1 commit into
ElementsProject:masterfrom
KY-U:2027-08-fail-psbt-on-trailing-bytes

Conversation

@KY-U

@KY-U KY-U commented Aug 6, 2026

Copy link
Copy Markdown

wally_psbt_from_bytes() currently does not validate that the input buffer has been completely consumed. Since this API has no streaming or consumed-length interface, callers cannot distinguish the parsed PSBT from an unconsumed suffix.

Rejecting unread bytes makes the contract unambiguous, as the caller will have certainty that the provided bytes correspond exactly to a valid PSBT.

This PR adds that validation and regression cases to the invalid PSBT test vectors.

Require wally_psbt_from_bytes to consume the complete input buffer.

Add PSBT v0 and v2 regression test cases with a trailing byte.
@jgriffiths

Copy link
Copy Markdown
Contributor

Thanks for contributing!

I've included this in #542 which will be merged shortly, gated behind a parsing flag WALLY_PSBT_PARSE_FLAG_COMPLETE to prevent back compact issues for parsing from bytes.

@jgriffiths jgriffiths closed this Aug 9, 2026
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.

2 participants