Repository navigation
fix(sdk-coin-avaxc): inherit isWalletAddress verification from AbstractEthLikeNewCoins - #10185
prithvishet2503 wants to merge 1 commit into
Conversation
|
|
|
@claude review this PR and score it |
|
Claude finished @prithvishet2503's task in 25s —— View job Review of PR #10185: inherit
|
There was a problem hiding this comment.
Besides the inline finding, I checked whether the new MPC positive test uses a made-up vector. It doesn't: the same commonKeychain and the derived address 0x01153f…4961 already appear in the existing sdk-coin-eth unit tests and the express isWalletAddress route tests.
Extended reasoning...
The change removes the always-true isWalletAddress stub from AvaxC so the class uses the AbstractEthLikeNewCoins address check, and it adds six unit tests. I ruled out the suspected fabricated test vector because the same vector is already used in modules/sdk-coin-eth/test/unit/eth.ts and modules/express/test/unit/typedRoutes/isWalletAddress.ts.
…ctEthLikeNewCoins Remove the stub override of isWalletAddress that unconditionally returned true for every input, which disabled client-side deposit-address verification for AVAXC/TAVAXC wallets. AvaxC now inherits the AbstractEthLikeNewCoins implementation: TSS/MPC receive addresses are recomputed from the commonKeychain and forwarder (CREATE2) deposit addresses are recomputed from the base address and salt. Production v0 forwarder wallets (unverifiable by design, no stored deployment nonce) keep the documented base-class behavior of returning true; forwarder versions with no deployed factory on AvalancheC fail closed. Ticket: CECHO-2723
1f089a5 to
c1338fa
Compare
|
@claude review this PR and score it |
|
Claude finished @prithvishet2503's task in 25s —— View job Review of PR #10185: inherit
|
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.
There was a problem hiding this comment.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟣
modules/sdk-coin-avaxc/src/avaxc.ts— pre-existing, security-relevant: AVAXC deposit addresses that are not EVM addresses, such asP-avax1...or-x, still passisWalletAddressas verified for forwarderVersion 0 wallets. The format check the PR relies on calls avaxc'sisValidAddress(avaxc.ts:133). That function also accepts any string matching AvaxP's/^(^P||NodeID)-[a-zA-Z0-9]+$/, including the empty-prefix-...form. Fix: check receive and base addresses with EVM-only validation (isValidEthAddress) before delegating tosuper.isWalletAddress, while leavingisValidAddressunchanged, because cross-chain export recipients depend on it.Why this was flagged
Trigger:
Wallet.createAddress(sdk-core/src/bitgo/wallet/wallet.ts:1580) passes the platform's response toisWalletAddress. In that response the address is a string likeP-avax1attacker,NodeID-abcor-abc, andcoinSpecific.forwarderVersionis 0. Per the PR description, that is the forwarder version every production AVAXC wallet uses. The inherited check at abstract-eth/src/abstractEthLikeNewCoins.ts:3262 callsthis.isValidAddress(address). AvaxC overrides that at avaxc.ts:131-134 asisValidEthAddress(address) || AvaxpLib.Utils.isValidAddress(address). AvaxP's regex at sdk-coin-avaxp/src/lib/utils.ts:61 has an empty alternative, so any<prefix>-<alnum>string passes. The code then returns true at line 3267-3269, and createAddress hands the user a non-EVM string as a verified C-chain deposit address. The base stub behaved the same way, so this is not a regression. It does mean the PR's claim of an InvalidAddressError on malformed input fails for the population it targets. Sending AVAXC to a P- address through the SDK triggers a cross-chain export, not a revert.Verification: Trigger: a createAddress response whose address is a non-EVM string such as
P-xor-xand whose coinSpecific.forwarderVersion is 0. AvaxC overridesisValidAddressas!!address && (isValidEthAddress(address) || AvaxpLib.Utils.isValidAddress(address))(avaxc.ts:133). So a non-EVM string gets past the format check and is then returned as verified. The base stub returned true for every input.
| @@ -1230,11 +1230,6 @@ export class AvaxC extends AbstractEthLikeNewCoins { | |||
| return hash.digest(); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
🟣 pre-existing, not blocking: Pre-existing, security-relevant: AVAXC TSS wallets still accept any deposit address when the platform reply says forwarderVersion: 0. The inherited isWalletAddress returns true for forwarder v0 (abstractEthLikeNewCoins.ts:3267). That check runs before the TSS/MPC branch at line 3276. Fix: for walletVersion 3, 5 and 6 with a commonKeychain, always run MPC verification, whatever forwarderVersion the platform sends. The fix belongs in the base class or a thin AvaxC override. Users who pass forwarderVersion 0 themselves for multisig v0 wallets must keep getting true.
A small fix can ride a push you are already making; otherwise a short reply is enough.
Why this was flagged
Wallet.createAddress (sdk-core/src/bitgo/wallet/wallet.ts:1561) sets impliedForwarderVersion = forwarderVersion ?? verificationData.coinSpecific?.forwarderVersion. When the caller passes no forwarderVersion, the value comes from the platform's /wallet/:id/address reply. In AbstractEthLikeNewCoins.isWalletAddress (abstractEthLikeNewCoins.ts:3259-3269), forwarderVersion === 0 returns true before isTssWalletVersion/shouldUseTssVerification is checked at lines 3276-3294. A compromised platform or MITM, the threat model of CECHO-2723, can reply {address: <attacker 0x>, coinSpecific: {forwarderVersion: 0}} for an avaxc wallet with walletVersion 3, 5 or 6. The MPC derivation check never runs, and createAddress returns the attacker's address as verified. The PR says TSS wallets gain real verification, but this bypass leaves them exactly as exposed as under the old always-true stub. Its residual-risk note covers only multisig v0 forwarders, not this TSS bypass.
Verification: In wallet.ts:1561, verificationData.impliedForwarderVersion = forwarderVersion ?? verificationData.coinSpecific?.forwarderVersion;, so the version comes from the /wallet/:id/address reply. Then if (forwarderVersion === 0) { return true; } runs before isTssWalletVersion / shouldUseTssVerification and the verifyMPCWalletAddress call that follow.
Description
Problem. AvaxC (sdk-coin-avaxc) overrode AbstractEthLikeNewCoins.isWalletAddress with a stub that unconditionally returned true (// TODO: Fix this later, added July 2022). The stub predated
the Sept 2024 superclass change (COIN-1708) that gave AvaxC a working inherited verification; when the superclass became AbstractEthLikeNewCoins, the stub silently suppressed it.
The sink: Wallet.createAddress (sdk-core/src/bitgo/wallet/wallet.ts:1540-1596) calls this.baseCoin.isWalletAddress(verificationData) as the only client-side integrity check that the
platform-returned deposit address belongs to the wallet. For AVAXC/TAVAXC this call always succeeded — for any address, index, salt, or coinSpecific data. A compromised platform, insider,
or MITM inside the TLS boundary could substitute an attacker-controlled 0x address into the createAddress response and the SDK would surface it to the user as a verified deposit address,
diverting all subsequent AVAXC deposits to an attacker EOA. This is CECHO-2723 (Integrity HIGH).
Fix. Remove the 4-line stub from modules/sdk-coin-avaxc/src/avaxc.ts. AvaxC, TavaxC, and AvaxCToken now inherit AbstractEthLikeNewCoins.isWalletAddress
(modules/abstract-eth/src/abstractEthLikeNewCoins.ts:3257), which:
Production compatibility (verified via BGA on prod — 6 wallets sampled, not 2). Checked 64139ea9... (custodial 2023), 654b39c9... (cold 2023), 65773322... (hot 2023), 6667dbaa... (hot 2024,
BitGo Singapore), 668f0899... (hot 2024), 67fe2a92... (hot 2025, active with 2026 forwarder deployments). Every wallet is multisigType: "onchain", walletVersion: 0, with receive addresses
at forwarderVersion: 0. BitGo has never created a TSS avaxc wallet or a v1/v2/v4/v5 avaxc forwarder; forwarder deployment on avaxc goes through the batcher (AddressInitialization sendq
entries) at v0.
Consequences of that data:
stub's behavior for these wallets.
no factory addresses for the AvalancheC network), so Forwarder factory addresses not configured for this network can only fire on platform responses that are already malicious or
malformed — the correct outcome. I deliberately did not add factory addresses to statics: the deterministic factory contracts do exist on-chain at the universal EVM addresses, but wiring
them into statics would let a compromised platform fabricate a verifiable-looking v4/v5 forwarder for avaxc, which today fails closed.
Residual risk (needs separate tracking). Forwarder v0 deposit addresses remain unverifiable — inherited, documented base-class behavior that applies to all ETH-like coins' v0 wallets, not
just AVAXC. Closing it requires platform-side work (store the deployment nonce at address creation so v0 forwarders can be recomputed client-side), which is out of scope for this SDK
ticket. Follow-up suggested against wallet-platform; noted on CECHO-2723.
Note on the ticket's premise: the ticket claimed AVAXC wallets use forwarder versions the base class can verify; production data shows they are walletVersion 0 / forwarderVersion 0. The fix
is still correct — the stub masked base verification for any TSS/non-v0 wallet and accepted malformed addresses outright.
Issue Number
Ticket: CECHO-2723
Type of change
How Has This Been Tested?
Added a 6-case isWalletAddress suite in modules/sdk-coin-avaxc/test/unit/avaxc.ts (test vector shared with the AbstractEthLikeNewCoins MPC suite; the secp256k1+keccak derivation is
chain-agnostic so it holds for avaxc):
junk address: proves a legitimate-looking address from the wrong derivation index is caught. (Returned true before this fix.)
Assertions 4 and 6 match exact error messages rather than bare Error, so they fail if the error path changes.
Reproduce:
Also verified: module tsc build clean, eslint --quiet clean, prettier --check clean, and the compiled dist/src/avaxc.js no longer contains an isWalletAddress override. The index-1 test
vector was computed with the same deriveMPCWalletAddress helper the verification path uses (m/0 -> 0x01153f3adfe454a72589ca9ef74f013c19e54961 confirmed against the existing vectors before
use).
Checklist
no avaxc-specific JSDoc needed since the override is deleted)
────────────────────────