Skip to content

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
masterfrom
cshld-839-stx-verify-transaction
Draft

fix(sdk-coin-stx): verify recipient and amount in native STX verifyTransaction#9244
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
masterfrom
cshld-839-stx-verify-transaction

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown

What

  • Stx.verifyTransaction previously returned true after checking only that the recipient count was ≤ 1 — no address or amount comparison was performed.
  • Added full decode-and-compare logic ported from Sip10Token.verifyTransaction:
    • Decodes the prebuild txHex via explainTransaction
    • Compares the decoded recipient address (memoId stripped) and amount against txParams.recipients
    • Compares the memo (from txParams.memo or embedded in recipient address) against the decoded transaction memo
    • Validates total output amount matches the declared total
  • Added getMemoIdAndBaseAddressFromAddress import from existing utils
  • Added lodash import (already a listed dependency) for _.isEqual
  • Added 8 new unit tests covering: valid match, wrong address, wrong amount, wrong memo, missing txHex, and multiple recipients

Why

  • A compromised platform prebuild could redirect native STX sends to any address or alter the amount, and the local verifyTransaction would still return true without detecting the mismatch.
  • The SIP10 token path already had full recipient validation; this gap was specific to native STX.
  • This is a security fix required by the Claude Security scan (High severity).

Test plan

  • All 180 existing unit tests pass (cd modules/sdk-coin-stx && mocha)
  • New tests verify correct recipient/amount match returns true
  • New tests verify wrong address, wrong amount, wrong memo all throw descriptive errors
  • New test verifies missing txHex in prebuild throws an error
  • TypeScript compilation succeeds for sdk-coin-stx with no new errors

Ticket: CSHLD-839

@linear-code

linear-code Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

CSHLD-839

@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot force-pushed the cshld-839-stx-verify-transaction branch from eac74de to cce41e6 Compare July 14, 2026 07:01
@prajwalu142 prajwalu142 force-pushed the cshld-839-stx-verify-transaction branch 2 times, most recently from 7f6a910 to 6d7a890 Compare July 14, 2026 11:45
…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
@prajwalu142 prajwalu142 force-pushed the cshld-839-stx-verify-transaction branch from 6d7a890 to fcbb68f Compare July 14, 2026 16:34
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