Repository navigation
fix(sdk-coin-trx): fail closed on unvalidated contract types in verifyTransaction - #10170
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.
|
|
779a81d to
43cee76
Compare
|
@claude review |
|
Claude finished @harman-bitgo's task in 43s —— View job Review of #10170 (fail closed on unvalidated contract types)
I did not run the tests. This is a read-through only. Summary: The approach is right. Replacing the Concerns
TestsCoverage looks thorough: 14 new owner_address cases and 3 multisig cases, plus the unknown-type throw. I'd add two cases:
The Node 27-nightly failure is marked experimental and non-blocking, and it looks unrelated to this change. |
…yTransaction Previously, verifyTransaction only validated TransferContract (and TriggerSmartContract on TSS), letting all other contract types pass with `return true`. This meant dangerous operations like AccountPermissionUpdate could be signed without any verification. Changes: - TSS path: validate owner_address for all 9 non-transfer contract types, throw on unknown types instead of returning true - Multisig path: add TriggerSmartContract recipient/amount validation (was completely unverified), validate owner_address for all 9 non-transfer contract types, throw on unknown types - Refactor error messages: context-aware messages distinguish consolidation destination vs contract owner_address validation - Extract shared allowlists (OWNER_VALIDATED_CONTRACT_TYPES and OWNER_VALIDATED_MULTISIG_CONTRACT_TYPES) to keep TSS/multisig in sync - Replace `any` types with minimal typed interfaces - Comprehensive test coverage: 65 verifyTransaction tests covering all contract types on both TSS and multisig paths, including rootAddress fallback Note: only owner_address is validated for non-transfer contracts. Fields like receiver_address (DelegateResource), votes (VoteWitness), or permission keys (AccountPermissionUpdate) are not checked because txParams does not yet carry structured intent for these operations. This is intentional and documented. TICKET: CHALO-2126 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43cee76 to
a6b637a
Compare
|
Addressed all review feedback in the latest push (a6b637a):
Pre-existing gaps (AccountPermissionUpdate key validation, multisig JSON-vs-hex contract field reconciliation) acknowledged in inline replies — both are follow-up scope. |
Summary
Fixes CHALO-2126:
Trx.verifyTransactionhad an inverted allowlist — it validated onlyTransferContract(andTriggerSmartContracton TSS) but silently returnedtruefor every other contract type, including dangerous ones likeAccountPermissionUpdateContract.Changes
return truefall-through with explicit owner_address validation for all 9 known non-transfer contract types (staking, voting, resource delegation, account setup, permission update), and throw on unknown typesTriggerSmartContractvalidation (was completely unverified), add owner_address validation for the same 9 contract types, and throw on unknown typesvalidateDecodedContractOwnerAddress(TSS/protobuf path) andvalidateMultisigContractOwnerAddress(multisig/JSON path) verify the contract'sowner_addressmatches the wallet's base addressImpact analysis
Queried Snowflake production data for the last 12 months — all TRX transaction types in production are covered by the BitGoJS
ContractTypeenum. No unknown types exist, so the fail-closed behavior will not break any existing flows.Test plan
TICKET: CHALO-2126
🤖 Generated with Claude Code