Skip to content

fix(sdk-coin-sol): report the real staking withdraw destination (SI-2414, partial) - #10184

Draft
abhijit0943 wants to merge 1 commit into
masterfrom
SI-2414-sol-staking-withdraw-topubkey
Draft

abhijit0943 wants to merge 1 commit into
masterfrom
SI-2414-sol-staking-withdraw-topubkey

Conversation

@abhijit0943

@abhijit0943 abhijit0943 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A Solana Stake Withdraw instruction pays an explicit destination (toPubkey) that need not be the withdraw authority. The parser dropped it, so explainTransaction / loadInputsAndOutputs reported 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: StakingWithdraw params carry the real toPubkey as toAddress.
  • stakingWithdrawBuilder.ts, solInstructionFactory.ts: optional toAddress (defaults to sender, survives initBuilder).
  • transaction.ts: inputs/outputs use toAddress ?? 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.
  • Rider-instruction allowlist: master already added the same default: throw in parseStakingWithdrawInstructions; this PR adopts master's wording and only adds tests for it.
  • Tests: instructionParamsFactory.staking.ts (destination kept; nonce/compute-budget/memo accepted), transaction.ts (rider cases, incl. withdraw + transfer + bare PrepareForRevoke memo: now typed Send and fails closed), StakingWithdrawBuilder.ts, new solStakingWithdrawVerify.ts. master's memo tests do not build that withdraw+transfer+bare-memo shape.

Verification

  • VERIFIED (this session, 2026-11-16, rebased tree, sdk-coin-sol mocha): 711 passing, 5 failing, 0 pending. The 5 are "before all" hooks needing the CI-only BITGOJS_TEST_PASSWORD (ctEnablementVerify, jitoWasmVerification, sol.ts, solSafeRecovery, solToken): could not run locally.
  • VERIFIED: claim-check (buildFromIntent claim, blockhash nonce): one Withdraw; recipient = wallet root = withdraw authority. The WASM parser has no destination field.
  • NOT RUN: lint, tsc/build, other modules, CI.

Not covered / follow-ups (SI-2414 stays open)

  1. No root-destination pin for StakingWithdraw in Sol.verifyTransaction (src/sol.ts:691). Outputs are compared only if txParams.recipients is 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.
  2. Allowlist risk: safe only if every producer emits just withdraw/nonce-advance/compute-budget/memo. Checked: WASM claim, blockhash variant (single Withdraw). NOT checked: durable-nonce and memo variants. Confirm against the WP WASM claim output before WP bumps this package.
  3. Test gap: solStakingWithdrawVerify.ts covers verifyTransaction with toPubkey != authority only WITH declared recipients; no case WITHOUT recipients and none asserting a root-destination rejection.
  4. wallet-platform: 4 tests deep-equal Withdraw instructionsData (test/api/v2/coins/sol.staking.ts:1065-1080, :2132, :2171, :2204) and need toAddress: rootAddress on the package bump. No production consumer found (audit searched BitGoJS, bitgo-microservices, staking-service, go-staking-service only).
  5. Claim-check evidence is one local sample, no CI/on-chain evidence.

Ticket: SI-2414

@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

SI-2414

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
abhijit0943 force-pushed the SI-2414-sol-staking-withdraw-topubkey branch from 2e31968 to e8f0956 Compare November 16, 2026 11:04
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Compatibility checks are failing on Node.js 27-nightly (experimental, non-blocking). This does not block merge, but it signals an incompatibility to fix before this release becomes supported.

View run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant