Repository navigation
fix(sdk-coin-trx): validate consolidation destination in TransferContract and TriggerSmartContract - #10168
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.
|
|
|
@claude review |
Deep Regression AnalysisCode Path Trace (17 scenarios)
Call Site Verification — All 8 production callers pass
|
| Location | Code | wallet value |
|---|---|---|
wallet.ts:900 |
prebuildAndSignTransaction → verify |
wallet: this |
wallet.ts:2430 |
signTransaction → verify |
wallet: this as IWallet |
wallet.ts:2914 |
prebuildAndSignTransaction main path |
wallet: this |
wallet.ts:4063 |
sendAccountConsolidations |
wallet: this |
ecdsa.ts:1072 |
TSS ECDSA with serializedTxHex | wallet: this.wallet |
ecdsa.ts:1079 |
TSS ECDSA with signableHex | wallet: this.wallet |
ecdsaMPCv2.ts:992 |
TSS ECDSAv2 with serializedTxHex | wallet: this.wallet |
ecdsaMPCv2.ts:1002 |
TSS ECDSAv2 with signableHex | wallet: this.wallet |
All production callers pass a real Wallet instance → coinSpecific() always available with baseAddress.
Regression Risk Summary
- 10 scenarios: Behavior identical (normal sends, non-Transfer contracts)
- 6 scenarios: Previously had zero validation → now properly validated (security fixes)
- 1 scenario (
wallet={}): Now throws instead of silently passing — correct fail-closed, not a production path - Zero regressions identified
Suggested Manual Test Plan (post-merge)
P0 — Must test:
- Native TRX consolidation (TSS wallet)
- Native TRX consolidation (on-chain multisig wallet)
- TRC20 token consolidation (TSS wallet)
- Native TRX single send (TSS + on-chain)
- TRX sendMany / bulk withdrawal with 2+ recipients
P1 — Should test:
6. TRC20 single send (TSS, both via TrxToken and native Trx coin instance)
7. TRC20 single send (on-chain multisig)
8. Non-Transfer contracts (permission update, freeze, vote)
P2 — Good to test:
9. Batch consolidation (sendAccountConsolidations plural)
10. Consolidation triggering pending approval
Confidence Rating: 9/10
Not 10 because validateTriggerSmartContract doesn't handle recipients.length > 1 for TRC20 sendMany (pre-existing gap, unchanged by this PR).
Unit Tests: 152 pass, 0 fail
- 140 existing tests unchanged
- 12 new tests covering: consolidation pass/fail (TransferContract + TRC20), sendMany match/no-match, missing wallet base address
307b943 to
d74a70d
Compare
…ract and TriggerSmartContract validateTransferContract and validateTriggerSmartContract skipped destination validation when txParams.recipients was absent (consolidation flow), returning true after checking only that amount > 0. A compromised platform could return a consolidation prebuild sending funds to an attacker address, and verifyTransaction would sign it without inspecting the destination. Now: - When recipients is absent/empty, validate the destination matches the wallet's base address (via wallet.coinSpecific().baseAddress). - When recipients has >1 entry (sendMany/bulk withdrawal), validate the prebuild matches at least one recipient. - Extract shared validateConsolidationDestination helper for both paths. - Pass wallet from verifyTransaction down to both validators. TICKET: CHALO-2125 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d74a70d to
eb88e31
Compare
Summary
validateTransferContractandvalidateTriggerSmartContractskipped destination validation whentxParams.recipientswas absent (consolidation flow), returningtrueafter only checkingamount > 0. A compromised platform could return a consolidation prebuild redirecting funds to an attacker address —verifyTransactionwould pass andsignTransactionwould sign it. For Tron receive addresses, the user's single signature is sufficient on-chain, enabling immediate fund theft without BitGo co-signature.wallet.coinSpecific().baseAddresssendMany/bulk withdrawal), the prebuild is validated against all recipients (must match at least one)validateConsolidationDestinationhelper used by both native TRX and TRC20 pathswalletfromverifyTransactiondown to both validator methodsTest plan
TICKET: CHALO-2125
🤖 Generated with Claude Code