Repository navigation
fix(sdk-coin-sol): verify deserialized versioned tx message - #10219
Venkat-Annavazzala wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
99d0314 to
4f5d549
Compare
|
|
|
@claude review always |
|
Claude finished @Venkat-Annavazzala's task in 26s —— View job Review of #10219: verify deserialized versioned tx messageI read the The design is sound. Comparing the deserialized Suggestions
Positives
Open item
|
| const reserializedBytes = Buffer.from(deserializedTx.serialize()); | ||
| if (!reserializedBytes.equals(txBytes)) { | ||
| throw new Error('versioned transaction has non-canonical encoding or trailing bytes'); |
There was a problem hiding this comment.
🟣 pre-existing, not blocking: Pre-existing, security-relevant: a compromised Wallet Platform can still get TSS Solana wallets to co-sign a draining v0 transaction. The new strict check only inspects serializedTxHex. The MPCv2 signer at eddsaMPCv2.ts:605-609 signs signableHex, a separate server field nobody compares. Fix: tie the verified message to the signed bytes. Have eddsaMPCv2 pass signableHex. Then add a Sol assertSignableConsistency that requires it to equal deserializedTx.message.serialize(), as ecdsaMPCv2.ts:1004-1005 already does. This needs an sdk-core change beyond this PR.
A small fix can ride a push you are already making; otherwise a short reply is enough.
Why this was flagged
In the TSS sign path, eddsaMPCv2.ts:605 sets txOrMessageToSign = unsignedTx.signableHex and eddsaMPCv2.ts:608 makes bufferContent from it. That is what userDsg.initDsg signs at eddsaMPCv2.ts:629. But eddsaMPCv2.ts:610 passes only txHex: unsignedTx.serializedTxHex to verifyTransaction, which routes to verifyVersionedTransaction. Both fields come from the server separately. A compromised WP can return a benign serializedTxHex that passes the new header, key, ALT and instruction equality checks (sol.ts:902-913 and assertVersionedMessageMatchesData). It can pair it with a signableHex holding a System or SPL drain message, and the wallet signs the drain. The ECDSA paths guard this with assertSignableConsistency (ecdsaMPCv2.ts:1004-1005, ecdsa.ts:1079-1080). The EdDSA path has no such check, and Sol does not implement the method. The base branch has the same gap, so this is pre-existing. It leaves open the exact threat the PR description says it closes: WP substituting an arbitrary v0 transaction while client-side verification returns true.
Verification: In modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts:605 the code sets txOrMessageToSign = unsignedTx.signableHex. Line 629 signs those bytes. But lines 609-610 pass only serializedTxHex to verifyTransaction. Sol has no assertSignableConsistency method. The base branch already signs signableHex unchecked in the same place.
Ticket
CHALO-447 (Parent: WAL-1449)
Summary
Replaces the structural-only stub in Sol.verifyVersionedTransaction() with full wire deserialization, canonical encoding validation, fail-closed parameter guards, and exact MessageV0 equivalence verification against txParams.solVersionedTransactionData.
Root Cause
Previously, Sol.verifyVersionedTransaction() (modules/sdk-coin-sol/src/sol.ts) only checked that txParams.solVersionedTransactionData had non-empty fields and that a single byte in the raw transaction had bit 7 set ((versionByte & 0x80) !== 0). It never deserialized the raw transaction bytes or compared the message against user intent. A compromised Wallet Platform could substitute an arbitrary v0 transaction (e.g., a System Program or SPL Token transfer draining wallet funds) and client-side verification would still return true.
Changes
Design Note for Security Review (Why Exact MessageV0 Equivalence Instead of Instruction Allow-List / Offline ALT Resolution)