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

Match policy types exactly and refuse an unsupported one

Public commit record

What the developer wrote

Authored by kdmukai

83/100 · Strong
Match policy types exactly and refuse an unsupported one

The rebuild chain in _parse_outputs matched single sig and taproot by
substring ("pkh" in type, "p2tr" in type) and had no else. embit reports
a script type it does not recognize as None, and _get_policy passes that
through, so a psbt whose inputs and outputs were both unrecognized passed
the shape gate and died in the substring test with a bare TypeError. The
guard meant for an unhandled type sat inside the scriptPubKey match,
where an empty rebuild cannot arrive.

The arms now name their types exactly, matching _build_singlesig_script,
and the chain ends in a catch-all else that raises RuntimeError with the
unsupported type in the message. The unreachable inner guard is removed.
A test drives a p2pk psbt into the catch-all.
✓ 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 fixes a bug in how SeedSigner parses Bitcoin transaction outputs. Previously, the code guessed script types using partial string matches (like checking if 'pkh' appears anywhere in the type name) and had no fallback for unknown types. A specially crafted transaction using an unsupported script type could slip past the safety checks and crash the device with a confusing error, or potentially be misclassified as change. The patch now matches script types exactly and explicitly rejects any unsupported type with a clear error message.

Recommended action

Review and merge the patch. Ensure the new exact-match policy type handling covers all supported wallet configurations. Consider adding additional tests for other unsupported script types and verifying that the RuntimeError is handled appropriately by upstream UI code to avoid user confusion.

Security signals we found

01

CWE-20: Improper Input Validation - substring matching allowed ambiguous/unsupported script type handling

02

CWE-248: Uncaught Exception - unsupported script types caused bare TypeError instead of controlled failure

03

CWE-754: Improper Check for Unusual or Exceptional Conditions - missing else branch for unsupported policy types

04

Defense in depth: explicit allowlist of supported script types with catch-all rejection

05

Crash/DoS vector: malformed PSBT could cause unhandled exception during transaction parsing

Risk score

Why this scored 60/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 8/15
Affected reach 10/15
Confidence 8/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.