IntersectMBO / IntersectMBO/evolution-sdk

Batch signing shares reference UTxOs across all transactions

Open
#483 0 comments 0 reactions 0 assignees View on GitHub
bug external-review
Dominant language
TypeScript
Stars
22
Forks
30
Avg merge
5h 29m
Merged PRs (30d)
12

Description

## 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.

Contributor guide

Open the contributing guide

Research direction

Start in packages/evolution/src/sdk/client/internal/Signing.ts, comparing signTxsWithAutoFetch (L204-256) with signWithAutoFetch (L258-296) and the referenceUtxos handling in computeRequiredKeyHashesSync (L72-81). Add the described regression test for a two-transaction batch, confirming it fails on main before the fix and passes when each transaction uses only its own reference inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.