AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 41 Bitcoin

Cover every OP_RETURN push encoding in the parser tests

Public commit record

What the developer wrote

Authored by okaybro

83/100 · Strong
Cover every OP_RETURN push encoding in the parser tests

Every existing OP_RETURN vector hand-built OP_PUSHDATA1, which is exactly the one
encoding the parser assumed, so the mis-slice never showed up. The regtest psbt
behind test_parse_op_return_content carries 2b 6a 4c 28 43 68 61 6e ... and the
screenshot generator concatenated OP_PUSHDATA1 by hand.

Add fixture helpers that build an OP_RETURN scriptPubKey with the minimal push by
default, and that can force a specific OP_PUSHDATA* so the non-minimal encodings
a coordinator is free to produce are testable too. Note in the helper that the
scriptPubKey and value have to be set on the OutputScope: PSBT.tx rebuilds the
transaction from the scopes on every access, so assigning through psbt.tx.vout[i]
is silently discarded and leaves a test asserting against the fixture it meant to
replace.

The new tests cover the direct-push/OP_PUSHDATA1 boundary at 75/76, OP_PUSHDATA2
and OP_PUSHDATA4, a non-minimal encoding, several pushes in one script, a bare
OP_RETURN, an empty scriptPubKey, a truncated length field, an over-long declared
length, and a leading opcode that is not a data push.

Co-authored-by: ruipereira1 <159703278+ruipereira1@users.noreply.github.com>
Co-authored-by: kwsantiago <44934418+kwsantiago@users.noreply.github.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit adds tests for how SeedSigner reads small text messages embedded in Bitcoin transactions via OP_RETURN outputs. The tests reveal that the existing parser only handled one specific encoding (OP_PUSHDATA1) and would misread or slice incorrectly when Bitcoin Core used the more common direct-push encoding for short messages. The commit does not change the parser itself; it only expands test coverage and adds helper functions to build OP_RETURN outputs safely. Because the parser bug is demonstrated but not fixed here, the change is primarily a test-hardening patch.

Recommended action

Review and patch PSBTParser._parse_op_return_payload to correctly parse all valid Bitcoin push encodings (direct push 0x01-0x4b, OP_PUSHDATA1/2/4), handle multiple pushes, bare OP_RETURN, and malformed/truncated scripts without crashing or mis-slicing. Then run the new tests to confirm the fix and keep the expanded test coverage.

Security signals we found

01

Parser assumed a single push encoding (OP_PUSHDATA1) while Bitcoin Core emits direct-push for payloads <=75 bytes

02

New tests demonstrate boundary cases (75/76 bytes), OP_PUSHDATA2/4, non-minimal encodings, multiple pushes, malformed/truncated length fields, and non-data-push leading opcodes

03

Helper comments warn that assigning through psbt.tx.vout[i] is silently discarded, which previously let tests assert against stale fixtures

04

No production code change in this commit; the parser bug is exposed but not fixed

05

OP_RETURN parsing affects what the user sees on screen, not what the transaction signs

Risk score

Why this scored 41/100

Our methodology →
Potential impact 8/30
Exploitability 7/25
Stealth signal 6/15
Affected reach 9/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.