IntersectMBO / IntersectMBO/evolution-sdk

Batch signing shares reference UTxOs across all transactions

Aperta
#483 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug external-review
Lingua principale
TypeScript
Stelle
22
Fork
30
Merge medio
5h 29m
PR unite (30g)
12

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
security
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
72/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.