Skip to content

Batch signing shares reference UTxOs across all transactions #483

Description

@solidsnakedev

Summary

signTxsWithAutoFetch collects reference inputs from every transaction in the batch, fetches them into one combined referenceUtxos list, and passes that same list to each transaction's signing call. computeRequiredKeyHashesSync then derives native-script key hashes from those reference UTxOs regardless of which transaction they belong to, so a native script referenced by one transaction can cause an unrelated transaction in the batch to be signed. The single-transaction path (signWithAutoFetch) scopes reference UTxOs to that transaction's own inputs, so the batch path is inconsistent with it. In legitimate use this only adds an unneeded witness; the only harmful case requires batch-signing an attacker-supplied transaction (blind-signing). Correctness / defense-in-depth, no fund loss.

Affected

packages/evolution/src/sdk/client/internal/Signing.ts

  • signTxsWithAutoFetch (L204-256): merges allRefInputs across all txs (L221-240), fetches once, passes the combined referenceUtxos to signTxs for every tx (L255)
  • computeRequiredKeyHashesSync (L72-81): adds native-script key hashes from referenceUtxos with no per-tx scoping
  • contrast: signWithAutoFetch (single tx, L258-296) scopes referenceUtxos to that tx's own referenceInputs

Fix

Scope reference UTxOs per transaction in the batch path: fetch each transaction's own reference inputs and pass only those to its signing call, matching the single-transaction path.

Regression test

  • given: batch [tx1, tx2] where tx1 has no reference to a wallet native script and tx2 has a referenceInput to a native script containing the wallet key hash
  • before fix: tx1's witness set includes the wallet vkey witness (contaminated by tx2)
  • after fix: tx1's witness set does not include it
    Must FAIL on main today and PASS after the fix.

Reference

Reported informally (batch reference-UTxO cross-contamination). Harm requires blind-signing attacker-supplied transactions; primarily a consistency fix with the single-tx path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternal-reviewFrom external review batch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions