fix(sdk-coin-stx): verify recipient and amount in native STX verifyTransaction#9244
Draft
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Draft
fix(sdk-coin-stx): verify recipient and amount in native STX verifyTransaction#9244bitgo-ai-agent-dev[bot] wants to merge 1 commit into
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Conversation
Contributor
eac74de to
cce41e6
Compare
cce41e6 to
7f6a910
Compare
…ansaction Previously, Stx.verifyTransaction was a near no-op: it only checked that the recipient count was <= 1. A compromised prebuild could redirect native STX sends to any address or alter the amount, and local verification would still pass. Port the full decode-and-compare pattern from Sip10Token.verifyTransaction into Stx.verifyTransaction. The new implementation: - Decodes the prebuild txHex via explainTransaction - Compares the decoded recipient address (stripping memoId) and amount against txParams.recipients[0] - Compares the memo (from txParams.memo or embedded in the recipient address) against the decoded transaction memo - Validates that the total output amount matches the declared total This closes the gap where the SIP10 token path already had full recipient validation but native STX did not, matching the pattern described in CSHLD-839. Ticket: CSHLD-839 Session-Id: 7de30368-fc1b-4b09-9d2e-55be78e462dc Task-Id: 2203e736-35f2-4e2f-8cde-6cdbd0d3e2b6
7f6a910 to
6d7a890
Compare
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.
What
Stx.verifyTransactionpreviously returnedtrueafter checking only that the recipient count was ≤ 1 — no address or amount comparison was performed.Sip10Token.verifyTransaction:txHexviaexplainTransactiontxParams.recipientstxParams.memoor embedded in recipient address) against the decoded transaction memogetMemoIdAndBaseAddressFromAddressimport from existing utilslodashimport (already a listed dependency) for_.isEqualWhy
verifyTransactionwould still returntruewithout detecting the mismatch.Test plan
cd modules/sdk-coin-stx && mocha)truetxHexin prebuild throws an errorsdk-coin-stxwith no new errorsTicket: CSHLD-839