Skip to content

fix(sdk-coin-avaxc): inherit isWalletAddress verification from AbstractEthLikeNewCoins - #10185

Open
prithvishet2503 wants to merge 1 commit into
masterfrom
prithvishet/cecho-2723-bitgojs-avaxciswalletaddress
Open

prithvishet2503 wants to merge 1 commit into
masterfrom
prithvishet/cecho-2723-bitgojs-avaxciswalletaddress

Conversation

@prithvishet2503

@prithvishet2503 prithvishet2503 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • validates address format (InvalidAddressError on malformed input — previously accepted by the stub),
  • verifies TSS/MPC (wallet v3/v5/v6) receive addresses by recomputing the secp256k1 MPC derivation from the wallet's commonKeychain,
  • verifies forwarder (CREATE2) deposit addresses by recomputing the derivation from the base address + salt + factory addresses,
  • fails closed (UnexpectedAddressError) when an address is not derivable.

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:

  • Existing wallets are unaffected. The base class documents v0 forwarders as unverifiable by design (no CREATE2 deployment nonce stored) and returns true for them — identical to the old
    stub's behavior for these wallets.
  • The fail-closed throw is unreachable for legitimate wallets. No real createAddress response can carry forwarderVersion 1/2/4/5 (there are no such avaxc forwarders and statics configures
    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.
  • TSS wallets gain real verification for the first time if the platform ever creates them (v3/v5/v6 paths, plus deriveAddress round-trips).

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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):

  1. MPC v3 round-trip — commonKeychain @ index 0 (m/0 -> 0x01153f...4961, same known-good vector as the sdk-coin-eth and express tests) verifies → true
  2. Well-formed but wrongly-derived address rejected (the CECHO-2723 scenario) — the same keychain derived at index 1 (m/1 -> 0x9b017d...e374) presented as index 0 → false. Stronger than a
    junk address: proves a legitimate-looking address from the wrong derivation index is caught. (Returned true before this fix.)
  3. Invalid format — 0xinvalid throws InvalidAddressError (returned true before this fix)
  4. Keychain material missing — user keychain lacking its commonKeychain rejects with missing required param commonKeychain
  5. Forwarder v0 — returns true, matching the documented base-class behavior for production v0 wallets
  6. Unverifiable forwarder version fails closed — v1 forwarder on AvalancheC (no factory addresses in statics) throws Forwarder factory addresses not configured for this network

Assertions 4 and 6 match exact error messages rather than bare Error, so they fail if the error path changes.

Reproduce:

cd modules/sdk-coin-avaxc
BITGOJS_TEST_PASSWORD=testpassword yarn unit-test
# 145 passing, 0 failing

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

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My code compiles correctly for both Node and Browser environments
  • I have commented my code, particularly in hard-to-understand areas
  • My commits follow Conventional Commits and I have properly described any BREAKING CHANGES
  • The ticket or github issue was included in the commit message as a reference (Ticket: CECHO-2723)
  • I have made corresponding changes to the documentation and on any new/updated functions and/or methods (inherited implementation is documented on AbstractEthLikeNewCoins.isWalletAddress;
    no avaxc-specific JSDoc needed since the override is deleted)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (145 passing)

────────────────────────

@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

CECHO-2723

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Compatibility checks are failing on Node.js 27-nightly (experimental, non-blocking). This does not block merge, but it signals an incompatibility to fix before this release becomes supported.

View run

@prithvishet2503

Copy link
Copy Markdown
Contributor Author

@claude review this PR and score it

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @prithvishet2503's task in 25s —— View job


Review of PR #10185: inherit isWalletAddress in AvaxC

Score: 8.5/10. Approve with minor nits.

Summary

The PR deletes the isWalletAddress stub in avaxc.ts, which always returned true. AvaxC, TavaxC and AvaxCToken now inherit AbstractEthLikeNewCoins.isWalletAddress. This closes the CECHO-2723 integrity hole, where Wallet.createAddress could surface any platform-supplied address as verified.

What I checked

  • The fix is correct and minimal. The diff is a 5-line deletion. I read the inherited implementation at abstractEthLikeNewCoins.ts (around line 3257). It validates address format and short-circuits forwarder v0 to true. It verifies TSS wallets v3, v5 and v6 by recomputing the derivation. It verifies forwarders through verifyForwarderAddress, and it throws when an address is not derivable.
  • The VerifyAddressOptions import is still used. avaxc.ts:158 uses it in verifyAddress, so removing the stub leaves no unused import or lint failure.
  • The test vector is real. The commonKeychain and the 0x01153f…4961 address also appear in sdk-coin-eth/test/unit/eth.ts, so the round-trip test checks a known-good derivation.
  • The six tests cover the right cases. They cover the positive MPC case, the attacker address (false), a malformed address (throws), a missing keychain, forwarder v0 (true), and an unsupported forwarder version (fails closed).

Notes and suggestions

  1. Behavior change for existing wallets. Production wallets are walletVersion 0 / forwarderVersion 0, so they still return true. Forwarder v0 addresses therefore remain unverified for AVAXC. The PR description acknowledges this, but the headline exploit is only partly closed for those wallets. A compromised platform can still substitute an address for any v0 wallet. A follow-up would be needed to verify v0, for example by storing the deployment nonce. I'd call this out in the PR description or the ticket so the residual risk is tracked.
  2. Fail-closed regression risk. Any AVAXC wallet that returns a v1, v2 or v4 forwarder will now throw in createAddress, because statics has no factory addresses for AvalancheC. That is the intended behavior. Confirm with product or ops that no production wallet uses those versions. The BGA sample covers only two wallets.
  3. Test weak spots.
    • Tests 4 and 6 use assert.rejects(..., Error). That passes for any thrown error, including a TypeError from a bad fixture. Assert a specific class or message instead. Test 6 would fit UnexpectedAddressError or the "factory address" error.
    • The negative MPC test uses 0x000…0001. A well-formed but wrong derived address would be a stronger test, for example the same keychain at index 1. That would show a legitimate-looking address that isn't the requested index is rejected.
  4. Import reordering. AvaxSignTransactionOptions was moved below the other imports for no functional reason. This is harmless noise. Mixing node:assert with should is fine, since the rest of the repo does the same.
  5. Nit. The test block has no blank line before describe('Address Verification' (it follows the previous }); directly).
  6. Docs. No docs change is needed.

Not run

I did not execute the test suite in this run. The PR description reports 145 passing. CI's Node 27-nightly failure is marked experimental and non-blocking, and it doesn't look related to this diff.

Verdict

The fix is correct, small, and well tested. The main follow-ups are tightening the two Error-only assertions and tracking the v0 forwarder gap separately.
| Branch: prithvishet/cecho-2723-bitgojs-avaxciswalletaddress

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread modules/sdk-coin-avaxc/src/avaxc.ts Resolved
…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
@prithvishet2503
prithvishet2503 force-pushed the prithvishet/cecho-2723-bitgojs-avaxciswalletaddress branch from 1f089a5 to c1338fa Compare November 16, 2026 18:00
@prithvishet2503

Copy link
Copy Markdown
Contributor Author

@claude review this PR and score it

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @prithvishet2503's task in 25s —— View job


Review of PR #10185: inherit isWalletAddress in AvaxC

Score: 8.5/10. Approve. I didn't run the tests. The sandbox denied the mocha command, so the 145-passing result is the PR's own claim.

What I checked

  • The fix is correct and minimal. It deletes the stub that always returned true, so AvaxC, TavaxC and AvaxCToken inherit AbstractEthLikeNewCoins.isWalletAddress (abstractEthLikeNewCoins.ts:3257). The inherited method does the following:
    • It validates address format.
    • It returns true for forwarder v0.
    • It verifies TSS wallets v3, v5 and v6 by recomputing the derivation.
    • It routes other forwarder versions through verifyForwarderAddress.
  • The test vector is real. The commonKeychain and the 0x01153f…4961 address are identical to the ones in sdk-coin-eth/test/unit/eth.ts (lines 2503 and 2620) and in the express isWalletAddress tests.
  • The index-1 vector is not independently confirmed. 0x9b017d…e374 appears only in this PR, so I'm relying on the PR's statement that it was computed with deriveMPCWalletAddress. If it were wrong, test 2 would still pass, because any wrong address returns false. A positive assertion for index 1 would prove the vector is right. I'd also add the v5 base-address and forwarder paths if you want broader coverage.
  • The earlier review's test nits are already addressed. Tests 4 and 6 now match exact errors, and test 2 uses a well-formed address from the wrong index.

On the inline concern about fail-closed for v1/v2/v4/v5

The concern is valid in principle: getForwarderFactoryAddressesAndForwarderImplementationAddress throws for AvalancheC, and createAddress only swallows MethodNotImplementedError. The PR's production data answers it. The six sampled wallets are all walletVersion 0 with forwarder v0, and BitGo has never created an AVAXC v1/v2/v4/v5 forwarder. Real responses therefore never reach the throwing path. Adding factory addresses to statics would let a compromised platform fabricate a verifiable-looking forwarder, so the author's choice not to add them is sound. I'd treat that comment as informational, not blocking.

Remaining notes

  1. Residual risk. Forwarder v0 deposit addresses are still unverified. This is the same base-class behavior as for every ETH-like coin. The headline attack (substituting an address) is closed only for non-v0 wallets, and production is all v0. Please track the platform-side follow-up (storing the deployment nonce) in a ticket, not only in a note on CECHO-2723.
  2. Wording. The PR says "6 wallets sampled", and that is a small sample. Say so in the description or ticket so nobody reads it as proof that all wallets are v0.
  3. Minor. The AvaxSignTransactionOptions import sits after @bitgo/sdk-coin-eth, and the new node:assert import is mixed with should. Both are harmless. VerifyAddressOptions is still used at avaxc.ts:158, so there's no unused import.
  4. CI. The Node 27-nightly failure is experimental and non-blocking, and it doesn't look related to this diff.

Verdict

This is a correct, small security fix with sensible tests. I'd merge it once the v0 follow-up is filed.
| Branch: prithvishet/cecho-2723-bitgojs-avaxciswalletaddress

@prithvishet2503
prithvishet2503 marked this pull request as ready for review November 16, 2026 18:05
@prithvishet2503
prithvishet2503 requested a review from a team as a code owner November 16, 2026 18:05

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 as P-avax1... or -x, still pass isWalletAddress as verified for forwarderVersion 0 wallets. The format check the PR relies on calls avaxc's isValidAddress (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 to super.isWalletAddress, while leaving isValidAddress unchanged, 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 to isWalletAddress. In that response the address is a string like P-avax1attacker, NodeID-abc or -abc, and coinSpecific.forwarderVersion is 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 calls this.isValidAddress(address). AvaxC overrides that at avaxc.ts:131-134 as isValidEthAddress(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-x or -x and whose coinSpecific.forwarderVersion is 0. AvaxC overrides isValidAddress as !!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();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟣 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.

This branch has not been deployed

No deployments
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