Skip to content

psbt: reject trailing final witness data#2567

Open
starius wants to merge 2 commits into
btcsuite:masterfrom
starius:psbt-trailing2
Open

psbt: reject trailing final witness data#2567
starius wants to merge 2 commits into
btcsuite:masterfrom
starius:psbt-trailing2

Conversation

@starius

@starius starius commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Change Description

Follow-up for #2558

Found one more case where an input with trailing bytes was accepted: final witness data in psbt.Extract.

Steps to Test

go test -run TestExtractRejectsTrailingFinalScriptWitnessData -count=1 -v

then revert the fix commit and make sure it is failing:

=== RUN   TestExtractRejectsTrailingFinalScriptWitnessData
      psbt_test.go:827:
                Error Trace:    /tmp/btcd-bip322-revert-msg/psbt/psbt_test.go:827
                Error:          Target error should be in err chain:
                                expected: "Invalid PSBT serialization format"
                                in chain:
                Test:           TestExtractRejectsTrailingFinalScriptWitnessData
  --- FAIL: TestExtractRejectsTrailingFinalScriptWitnessData (0.00s)

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@guggero guggero left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the fix! LGTM 🎉

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