Skip to content

BTC: invalid output multisig quorum can lock change to an unsatisfiable script #618

Description

@BitHighlander

Summary

The Bitcoin signing path validates 1 <= m <= n <= 15 for multisig inputs, but not for multisig outputs. A host can submit a PAYTOMULTISIG internal/change output with m > n; the firmware derives the output and signs a transaction paying to an impossible quorum.

Found while auditing PR #604 at exact head 1d446ccbc9cf32a6e499990e65bcf7b358f1325b (release/7.14.3-bitcoin-only against fork develop).

Evidence

  • lib/firmware/signing.c:845-857 correctly rejects invalid input quorums.
  • lib/firmware/signing.c:907-967 validates output field/script compatibility but never validates multisig.m, pubkeys_count, or m <= n.
  • lib/firmware/transaction.c:617-645 and :648-680 accept m and n independently in 1..15, then compile/hash OP_m <keys> OP_n OP_CHECKMULTISIG; neither rejects m > n.
  • lib/firmware/transaction.c:527-553 deliberately skips the internal-transfer address/path screen for PAYTOMULTISIG, so the invalid change destination is not independently disclosed as an address.

Impact

High — loss of funds. A malicious or compromised host can label the output as internal change and obtain a valid signature for a transaction whose change is locked to an unsatisfiable multisig quorum.

Acceptance criteria

  • Reject every multisig output unless has_m && 1 <= m <= pubkeys_count <= 15.
  • Enforce the same invariant inside both multisig compiler functions as defense in depth.
  • Add native and device-level negative tests for m=0, n=0, m>n, and values above 15 on both external and internal outputs.
  • Prove no serialized transaction or signature is returned after rejection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions