Skip to content

fix(sdk-core): route legacy type-0 EVM envelopes to serializedTxHex - #10204

Open
dpkjnr wants to merge 3 commits into
masterfrom
cecho-2681-legacy-type0-envelope-routing
Open

dpkjnr wants to merge 3 commits into
masterfrom
cecho-2681-legacy-type0-envelope-routing

Conversation

@dpkjnr

@dpkjnr dpkjnr commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Description

Routes legacy (type-0) EVM TSS transaction envelopes to serializedTxHex verification even on EIP-1559 chains, instead of deciding solely from CoinFeature.TSS_VERIFY_USE_SERIALIZED_TX_HEX.

On an EIP-1559 chain, a type-0 transaction's signableHex is the EIP-155 signing preimage RLP([nonce, gasPrice, gasLimit, to, value, data, chainId, 0, 0]), which is not a parseable serialized transaction under @ethereumjs/tx.

Summary of changes

  • modules/sdk-core/src/bitgo/utils/tss/serializedTxHexVerify.ts (re-exported via tss/index.ts): adds optional CoinWithSerializedTxHexVerification interface and updates shouldVerifyWithSerializedTxHex(coin, unsignedTx?) to short-circuit on CoinFeature.TSS_VERIFY_USE_SERIALIZED_TX_HEX and otherwise delegate to coin.shouldVerifyWithSerializedTxHex(unsignedTx).
  • modules/abstract-eth/src/abstractEthLikeNewCoins.ts: implements shouldVerifyWithSerializedTxHex(unsignedTx) using the existing @ethereumjs/rlp decoder. Returns true only for 6-element pre-EIP-155 or 9-element unsigned EIP-155 (r = 0, s = 0) flat RLP byte-string lists. Type-2 (0x02…), type-1 (0x01…), FLR/FLRP 32-byte pre-hashed digests, Tempo (0x76…), signed 9-element RLP, and malformed hex return false.
  • modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsa.ts & ecdsaMPCv2.ts: pass unsignedTx to shouldVerifyWithSerializedTxHex, fail closed with InvalidTransactionError when serializedTxHex is missing/blank on the serialized verification route, and run assertSignableConsistency(serializedTxHex, signableHex) for consistency-capable coins on that route.
  • modules/sdk-core/src/bitgo/utils/tss/preHashedSignable.ts: guards isAvalancheAtomicTx against undefined serializedTxHex.

Shared files with CECHO-2680 (#10203)

This PR is independent and targets master directly (not stacked on #10203). It shares two files with #10203:

  • modules/abstract-eth/src/abstractEthLikeNewCoins.ts
  • modules/sdk-coin-eth/test/unit/tssPaymentVerification.ts

Whichever PR merges second should rebase and re-run combined checks.

Limitations, exceptions, and open follow-ups (not claiming release readiness)

  • Production-data limitations: Wallet Platform code (abstractEthLikeCommon.ts buildTransactionWithNonce / updateUnsignedTxWithNewNonce) unconditionally sets serializedTxHex, and a Snowflake CDC query of MARTS.WALLET_PLATFORM.BITGO2__TRANSACTION_REQUEST (2.85M EVM transaction txRequests from 2023-07-14 to 2026-11-19) showed 0 missing/empty values on transaction resources (all hex-less EVM txRequests were signMessage / signTypedStructuredData with transactions: []). However, CDC marts coverage cannot prove absence of pre-2023-07 Mongo documents, direct/bulk Mongo writes bypassing Mongoose schema validation, or out-of-repo writers.
  • Pre-hashed exceptions: In ecdsaMPCv2.ts, shouldUsePreHashedSignable(coin, unsignedTx) retains precedence over envelope routing, and the missing-serializedTxHex guard is scoped to verifyWithSerializedTxHex (not usePreHashedSignable) so pre-hashed flows such as FLR/FLRP atomic and Starknet are preserved without running EVM assertSignableConsistency.
  • CECHO-2683 legacy bypass: EvmCoin.verifyTssTransaction (modules/sdk-coin-evm/src/evmCoin.ts) still routes non-EIP-1559 EvmCoin chains (kavaevm, tkavaevm, prividiumeth, tprividiumeth) through verifyLegacyTssTransaction without decoding transaction bytes. Removing that bypass is tracked separately in CECHO-2683 (blocked by this ticket) and is intentionally not included here.

Issue Number

CECHO-2681

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • TypeScript build (yarn tsc --build --incremental) across sdk-lib-mpc, statics, sdk-core, abstract-eth, sdk-coin-eth, sdk-coin-bsc, sdk-coin-xdc, sdk-coin-flr, sdk-coin-flrp — 0 errors.
  • Prettier + ESLint (lint-staged) + commitlint — passed.
  • modules/sdk-core: serializedTxHexVerify.ts, preHashedSignable.ts, ecdsa.ts, ecdsaMPCv2.ts — 39 passing (including coin-detected legacy routing, missing/blank/undefined serializedTxHex fail-closed, and FLR atomic pre-hashed precedence).
  • modules/sdk-coin-eth: tssPaymentVerification.ts — 56 passing (including type-0 envelope detection, type-2 and pre-hashed/Tempo exclusion, full payment verifier on type-0 serialized bytes, unparsable type-0 signableHex proof, and real EcdsaUtils / EcdsaMPCv2Utils signing entry points for matching, mismatched, tampered signableHex, missing serializedTxHex, and type-2 direct-route regression).
  • Regression greps in sdk-coin-bsc (11 passing), sdk-coin-xdc (11 passing), sdk-coin-flr (9 passing), sdk-coin-flrp (6 passing).

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • 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
  • 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

Legacy (type-0) EVM TSS transactions carry an EIP-155 signing preimage
RLP([nonce, gasPrice, gasLimit, to, value, data, chainId, 0, 0]) in
signableHex rather than a parseable serialized transaction. Previously,
verification routing depended only on CoinFeature.TSS_VERIFY_USE_SERIALIZED_TX_HEX,
so a type-0 transaction on an EIP-1559 chain failed to parse or skipped
consistent serialized-byte verification.

Add an optional CoinWithSerializedTxHexVerification hook checked by
shouldVerifyWithSerializedTxHex(coin, unsignedTx) and implement it on
AbstractEthLikeNewCoins using @ethereumjs/rlp to detect 6-element
pre-EIP-155 and 9-element unsigned EIP-155 (r=0, s=0) legacy RLP lists.
On both ECDSA MPCv1 (ecdsa.ts) and MPCv2 (ecdsaMPCv2.ts), missing or
blank serializedTxHex now fails closed before signing on the serialized
route, and assertSignableConsistency runs for consistency-capable coins.
Type-2 EIP-1559 envelopes and pre-hashed signables (FLR/FLRP atomic,
Starknet) keep their existing routes.

Ticket: CECHO-2681
@dpkjnr
dpkjnr requested review from a team as code owners November 19, 2026 06:15

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

@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

CECHO-2681

@github-actions

github-actions Bot commented Nov 19, 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

…xHex

A coin with a pre-hashed route (FLR/FLRP atomic) chooses that route from
serializedTxHex. When it was missing, signing fell through to the default
branch and verified the SHA-256 digest as if it were a transaction. Reject
the request before verification instead.

Ticket: CECHO-2681
Reject 6-field pre-EIP-155 and chain-id-less 9-field legacy envelopes with InvalidTransactionError, run the coin envelope hook on feature-gated serialized-verify coins (BSC/XDC), and add the missing-serializedTxHex and pre-hashed guards to ECDSA MPCv1.

Ticket: CECHO-2681

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