Repository navigation
fix(sdk-coin-sol): add CustomTx instruction verification in verifyTransaction - #10178
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.
|
|
1178e0e to
c84deb8
Compare
|
@claude review |
|
Claude finished @harman-bitgo's task in 24s —— View job Review of #10178: CustomTx instruction verificationI read the 1. The Exploit 1 check is skipped when
I'd tighten this in one of two ways:
At minimum, the test 2. The PR description doesn't match the code on ComputeBudget The summary says compute budget instructions are stripped before comparison. The code doesn't strip them. The doc comment says they are "treated as user-supplied". If the server adds a priority-fee Please check whether the prebuild path ever adds compute-budget instructions. Then either strip them (ideally only at the head) or fix the description. 3. Stripping is position-independent and uses
4. Data decoding is ambiguous, but it matches the builder The decode order (base64, then hex, then utf8) matches 5. Tests
Verdict: Exploit 2 is solid. For Exploit 1, I'd resolve items 1 and 2 before merging, because the first leaves a bypass and the second could break legitimate flows. |
…nsaction Sol.verifyTransaction had no verification path for CustomTx prebuilds, leaving solInstructions unbound to signed content. A malicious prebuild could substitute arbitrary instructions (token drains, Approve delegates) or launder Transfer instructions via the WalletConnectDefiCustomTx memo into CustomTx classification, bypassing all output-based checks. Two exploits are fixed: - Exploit 1 (intent substitution): when txParams.solInstructions is set, verifyCustomTxInstructions now strips server-added wrappers (nonce advance, compute budget, WalletConnectDefiCustomTx memo) and compares the remaining instructions byte-for-byte against the user's intent — programId, keys, and data. Any mismatch throws. - Exploit 2 (consolidation hijack): CustomTx transactions are now rejected outright when consolidateId is set. Consolidation must never produce a CustomTx; a prebuild that does has been tampered with. Fixes CHALO-2055. References: CHALO-2055 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c84deb8 to
146fafb
Compare
|
Thanks for the thorough review — all points addressed in the latest push. 1. Exploit 1 bypass when `solInstructions` is absent Addressed in two ways:
The stronger fix (throw when `txParams.type` doesn't indicate a CustomTx intent) would break the 578 existing production transactions that get `CustomTx` classification via the fallback path without `solInstructions`. Keeping the gap deliberate and documented is the right call for now. 2. ComputeBudget in PR description Fixed. The description now explicitly states ComputeBudget is NOT stripped — the server never auto-adds it for `CustomTx` (confirmed from `transactionBuilder.ts`: `computeUnitLimitData` is only added when `_computeUnitLimit !== undefined`, which is never set in the `CustomInstructionBuilder` path). If ComputeBudget is present, the user included it in `solInstructions` and it must match exactly. 3. Position-independent stripping Rewrote from `filter` to position-based slicing:
Kept `includes` for the memo (rather than exact match) since `utils.ts` uses the same `includes` for classification — position-based gating handles the false-positive concern. 4. Data decoding ambiguity Agreed on the shared helper. Filed as a follow-up — extracting it now would touch `solInstructionFactory.ts` and `utils.ts` and is out of scope for a security fix. 5. Missing tests Added 5 new tests (11 total):
|
Summary
Test plan
should pass when solInstructions match the prebuild exactlyshould fail when the prebuild contains a substituted instruction (Exploit 1)should fail when the prebuild has more instructions than solInstructionsshould fail when the prebuild instruction data is tamperedshould reject a CustomTx consolidation (Exploit 2)should pass when no solInstructions are provided (non-customtx-intent path)— gap documentedshould pass when prebuild has durable nonce advance and WalletConnectDefiCustomTx memo— position-based strippingshould fail when a second AdvanceNonceAccount is injected— pins position-based fixshould NOT strip a user-supplied memo at a non-last positionshould fail when a key isSigner flag is tamperedshould fail when a key isWritable flag is tamperedFixes CHALO-2055.
🤖 Generated with Claude Code