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

btc: validate prevtx input hash length

Public commit record

What the developer wrote

Authored by benma's agent

78/100 · Adequate
btc: validate prevtx input hash length

Previous transaction inputs were hashed without checking that their
previous output hashes were 32 bytes. This allowed malformed transaction
data to pass verification when the host supplied the matching transaction
hash.

Reject these inputs with InvalidInput before hashing their fields.
✓ 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 missing length check in the BitBox02 hardware wallet's Bitcoin transaction signing code. When verifying a previous transaction supplied by the host computer, the device was hashing the previous output hash without first confirming it was the expected 32 bytes. A malicious or buggy host could supply a shortened or lengthened hash that still matched a transaction hash the device itself computed, letting malformed data pass verification. The patch now rejects any hash that is not exactly 32 bytes before hashing it.

Recommended action

Treat this as a security-relevant hardening fix. Review whether other fields serialized into the prevtx hash (scriptSig, sequence, output value, scriptPubKey, locktime, sighash) have similar missing length checks, and audit the host protocol for any other variable-length fields that could be used to shape a matching hash. Ensure the fix is included in the next firmware release.

Security signals we found

01

Missing input-length validation in cryptographic hashing path

02

Host-supplied data trusted without strict length check

03

Potential bypass of previous-transaction verification via malformed prev_out_hash

04

Patch adds explicit 32-byte length check and unit tests for off-by-one/empty cases

Risk score

Why this scored 59/100

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