What changed, and why it matters
This change makes the PSBT (Partially Signed Bitcoin Transaction) parser reject files or data that have extra bytes after the end of a valid PSBT. Previously, extra trailing data was silently ignored, which could let an attacker hide malicious content inside what looks like a legitimate PSBT, or cause two different byte strings to be treated as the same PSBT. The patch is only four lines and adds a check that the input is fully consumed after parsing.
Review the implementation of assertFullyConsumed to confirm it correctly detects unread bytes for both base64 and raw readers, and consider adding test vectors with trailing data. Downstream users should upgrade to ensure PSBT inputs are strictly validated.
Security signals we found
Parser no longer ignores trailing bytes
Could prevent smuggling of extra data inside PSBT containers
Could prevent canonicalization attacks where different byte sequences parse to the same structure
Patch is minimal and defensive
Evidence from the diff
The commit adds a call to assertFullyConsumed(r) in psbt.NewFromRawBytes immediately after the existing parse succeeds. This ensures that any bytes remaining after a well-formed PSBT are rejected. The helper assertFullyConsumed is not shown in the diff, but the change implies it was already available or added elsewhere. The issue is a strictness/correctness bug: trailing data could be used to smuggle payloads, create canonicalization issues, or confuse downstream tools that hash or compare raw PSBT bytes.
Changed components
psbt/psbt.goNewFromRawBytes parserInspect captured patch +4 / −0
diff --git a/psbt/psbt.go b/psbt/psbt.go
index 7548b52..8f47f28 100644
--- a/psbt/psbt.go
+++ b/psbt/psbt.go
@@ -324,6 +324,10 @@ func NewFromRawBytes(r io.Reader, b64 bool) (*Packet, error) {
return nil, err
}
+ if err := assertFullyConsumed(r); err != nil {
+ return nil, err
+ }
+
return &newPsbt, nil
}
Why this scored 49/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.