Repository navigation
fix(sdk-coin-sol): report the real staking withdraw destination (SI-2414, partial) - #10184
Draft
abhijit0943 wants to merge 1 commit into
Draft
abhijit0943 wants to merge 1 commit into
abhijit0943 wants to merge 1 commit into
Conversation
Contributor
A Solana Stake Withdraw instruction pays lamports to an explicit destination (toPubkey) that is not required to be the withdraw authority signing the transaction. Parsing dropped it and explainTransaction/loadInputsAndOutputs reported the authority, so a prebuild paying a third party explained and verified as paying the wallet root. StakingWithdraw params now carry the real toPubkey as toAddress and explanations use it; the builder accepts an optional toAddress that survives initBuilder. The tsol/WASM path, which uses @bitgo/wasm-solana and has no toPubkey, resolves the destination from the same transaction bytes, cross-checks it against the wasm parse and throws instead of guessing when they disagree or when account keys are not resolvable. A staking withdraw transaction may only carry the withdraw plus its nonce advance, compute-budget instructions and memo; any other instruction now makes parsing throw instead of being silently ignored. TICKET: SI-2414
abhijit0943
force-pushed
the
SI-2414-sol-staking-withdraw-topubkey
branch
from
November 16, 2026 11:04
2e31968 to
e8f0956
Compare
Contributor
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A Solana Stake Withdraw instruction pays an explicit destination (
toPubkey) that need not be the withdraw authority. The parser dropped it, soexplainTransaction/loadInputsAndOutputsreported the authority, and a prebuild paying a third party was explained as paying the wallet root. Explanations now report the real destination. This PR does NOT close SI-2414; see "Not covered".What changed (modules/sdk-coin-sol, 10 files, rebased on master ae28836)
iface.ts,instructionParamsFactory.ts:StakingWithdrawparams carry the realtoPubkeyastoAddress.stakingWithdrawBuilder.ts,solInstructionFactory.ts: optionaltoAddress(defaults to sender, survivesinitBuilder).transaction.ts: inputs/outputs usetoAddress ?? fromAddress.explainTransactionWasm.ts: tsol/WASM path recovers the destination from the tx bytes (the WASM parser has none), cross-checks the WASM parse, throws on mismatch.default: throwinparseStakingWithdrawInstructions; this PR adopts master's wording and only adds tests for it.instructionParamsFactory.staking.ts(destination kept; nonce/compute-budget/memo accepted),transaction.ts(rider cases, incl. withdraw + transfer + barePrepareForRevokememo: now typed Send and fails closed),StakingWithdrawBuilder.ts, newsolStakingWithdrawVerify.ts. master's memo tests do not build that withdraw+transfer+bare-memo shape.Verification
mocha):711 passing,5 failing, 0 pending. The 5 are "before all" hooks needing the CI-onlyBITGOJS_TEST_PASSWORD(ctEnablementVerify, jitoWasmVerification, sol.ts, solSafeRecovery, solToken): could not run locally.buildFromIntentclaim, blockhash nonce): one Withdraw; recipient = wallet root = withdraw authority. The WASM parser has no destination field.Not covered / follow-ups (SI-2414 stays open)
StakingWithdrawinSol.verifyTransaction(src/sol.ts:691). Outputs are compared only iftxParams.recipientsis defined (:773). Master's new checks (CustomTx:736, Marinade unstake root source:747-751) do not cover StakingWithdraw. The audit infers staking claim intents carry no recipients, so the corrected output may never be compared.solStakingWithdrawVerify.tscoversverifyTransactionwithtoPubkey != authorityonly WITH declared recipients; no case WITHOUT recipients and none asserting a root-destination rejection.instructionsData(test/api/v2/coins/sol.staking.ts:1065-1080,:2132,:2171,:2204) and needtoAddress: rootAddresson the package bump. No production consumer found (audit searched BitGoJS, bitgo-microservices, staking-service, go-staking-service only).Ticket: SI-2414