Skip to content

fix(abstract-eth): verify tokenApproval and ERC-7984 TSS payment calldata - #10206

Open
dpkjnr wants to merge 2 commits into
masterfrom
deepakjangid/cecho-2689-evm-tss-verify-tokenapproval-erc7984
Open

dpkjnr wants to merge 2 commits into
masterfrom
deepakjangid/cecho-2689-evm-tss-verify-tokenapproval-erc7984

Conversation

@dpkjnr

@dpkjnr dpkjnr commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Description

Hardens EVM TSS transaction verification for tokenApproval intents and ERC-7984 confidential payment calldata (transfer / stored payment), closing the gaps tracked in CECHO-2689 (including the Nov 19 ERC-7984 payment-calldata addition from Sanket's v54.4.0 retest on CECHO-1905).

Raw-bytes verification (no builder reserialization)

  • AbstractEthLikeNewCoins.decodeRawTssTxFields (modules/abstract-eth/src/abstractEthLikeNewCoins.ts) decodes txPrebuild.txHex directly with EthTransactionData.fromSerialized(txHex, common) instead of routing through TransactionBuilder.from() / .build().
  • Prior security review found that builder reserialization can normalize or alter calldata bytes before inspection; decoding raw serialized bytes directly ensures the verifier inspects the exact to, value, and data bytes being signed. Used by verifyTssSinglePayment, verifyTssBatchPayment, and verifyTssTokenApproval.

tokenApproval fail-closed verification & wrapper-approve guard

  • verifyTssTokenApproval fails closed with TxIntentMismatchRecipientError unless:
    • txParams.tokenName resolves to a token contract on the current network,
    • to equals the declared token contract,
    • value is 0,
    • data is canonical approve(address,uint256) (0x095ea7b3; rejects trailing bytes / dirty padding),
    • spender equals the network's configured batcherContractAddress,
    • amount equals MAX_UINT256 (2^256 - 1).
  • tokenApproval is added to TSS_DEDICATED_INTENT_TYPES and runs after assertWrapperApproveIsDeclared, preserving the ERC-7984 wrapper-approve guard so a relabelled approve(wrapper, …) still fails with the wrapper-approve error.

ERC-7984 confidentialTransfer payment rules & encrypted-amount limit

  • verifyTssSinglePayment no longer warns and returns on non-ERC-20 calldata when the declared token is an Erc7984Coin:
    • resolveTssToken now returns contract for Erc7984Coin.
    • Requires canonical confidentialTransfer(address,bytes32,bytes) (0x2fb74e62), to equal to the declared token contract, decoded recipient equal to recipient.address, value == 0, non-zero 32-byte encryptedHandle, and non-empty inputProof. Any other calldata (including approve(attacker, MAX_UINT256)) is rejected.
    • Because the transferred amount is encrypted (euint64 ciphertext + input proof), the plaintext amount cannot be compared client-side; only that field stays a warning (encrypted amount cannot be verified against declared plaintext amount).
  • verifyTssBatchPayment fails closed if any recipient names an ERC-7984 confidential token.
  • Erc7984Token.verifyConfidentialTransfer (modules/sdk-coin-eth/src/erc7984Token.ts, token-coin path not retested in Phase 1) now also enforces zero native value, canonical ABI encoding for both direct and sendMultiSig-wrapped shapes, and single-recipient intents when txHex is present, with the encrypted-amount verification limit documented on the method.

sdk-core tokenName propagation for stored approvals

  • TransactionParams.tokenName (modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts) and resolveEffectiveTxParams (modules/sdk-core/src/bitgo/utils/tss/recipientUtils.ts) propagate top-level intent.tokenName when caller txParams omits it.
  • Production tokenApproval intents store tokenName at the intent root with no recipients (657/657 rows); pending-approval / stored-intent signing (EcdsaUtils / EcdsaMPCv2Utils) carries no caller txParams, so propagation is required for stored approvals to verify.

Overlap & known semantic conflict with open PRs (#10203, #10204)

Scope boundaries

  • Sanket's Phase 1 retest is separate and pinned to BitGoJS v54.4.0.
  • This PR does not claim INFOSEC-671 is closed or release-ready. Non-EIP-1559 EvmCoin legacy bypasses remain tracked in CECHO-2683, and multisig (non-TSS) tokenApproval verification is out of scope for this TSS ticket.

Issue Number

CECHO-2689 (related: CECHO-1905)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (rejects malformed/mismatched tokenApproval intents and non-confidentialTransfer calldata on ERC-7984 payments)

How Has This Been Tested?

  • Targeted CECHO-2689 unit & signing-path tests (modules/sdk-coin-eth): 44 passing covering tokenApproval (matching, wrong token contract, wrong spender, finite amount, nonzero value, wrong selector, non-canonical trailing bytes, missing/unresolvable token, retained wrapper-approve guard precedence), ERC-7984 payments (matching with amount-only warning, approve(attacker, MAX) rejection, wrong recipient/token/value/trailing bytes, batch rejection), Erc7984Token coin-path checks (direct & sendMultiSig value, trailing bytes, multi-recipient), and stored tokenApproval signing via both EcdsaUtils (MPCv1) and EcdsaMPCv2Utils (MPCv2) on signableHex and serializedTxHex.
  • Failing-before proof: disabling intent.tokenName propagation caused all 6 stored-approval signing tests to fail; restoring it returned all 6 to passing.
  • Unit test suites:
    • modules/sdk-core/test/unit/bitgo/utils/tss/recipientUtils.ts: 50 passing
    • modules/abstract-eth/test/unit/coin.ts: 217 passing
    • modules/sdk-coin-evm / sdk-coin-bsc / sdk-coin-xdc: 40 / 45 / 65 passing
    • modules/sdk-coin-eth full suite: 617 passing, 1 failing — pre-existing unrelated failure in test/unit/ethSafeRecovery.ts (TypeError: Cannot read properties of undefined (reading 'generateVrfDKGKeyShares') from a stale @bitgo/sdk-lib-mpc copy lacking DklsVrfUtils in this worktree environment; untouched by this PR).
  • Production replay (MARTS.WALLET_PLATFORM.BITGO2__TRANSACTION_REQUEST, LATEST = TRUE, STATE = 'delivered'):
    • tokenApproval: 17/17 verified across ETH (usdc, usdt, aave, eigen), Polygon (polygon:usdc, polygon:usdcv2), and legacy type-0 BSC (bsc:usdt). Production-derived tamper test (swapping real spender for an attacker address) rejected with tokenApproval transaction spender does not match the network batcher contract.
    • hoodeth:* approvals (unreplayed): 9 sampled rows on chainId 4663 could not be replayed because @bitgo/statics exposes hoodeth only as a token prefix with no base coin instance; their calldata matches the same approve(batcher, MAX_UINT256) shape with zero value.
    • ERC-7984 payments (unreplayed): 0 rows exist in production containing selector 0x2fb74e62 or payment intents naming ERC-7984 tokens; verified instead against real TransferBuilderERC7984 and Wallet Platform buildConfidentialTransferCalldata shapes.
  • Lint & commit checks: lint-staged (prettier --write, eslint --fix) and commitlint passed on commit.

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

…data

Verify EVM TSS tokenApproval intents and ERC-7984 confidentialTransfer
payment calldata against raw serialized transaction bytes instead of
warning and signing unchecked.

- Decode raw txHex via EthTransactionData.fromSerialized (bypassing
  TransactionBuilder reserialization) in single payment, batch payment,
  and tokenApproval verification so calldata cannot be altered.
- Fail closed on tokenApproval unless to matches the declared token
  contract, value is 0, calldata is canonical approve(address,uint256),
  spender matches the network batcher, and amount is MAX_UINT256. Keep
  assertWrapperApproveIsDeclared running before tokenApproval.
- Enforce confidentialTransfer(address,bytes32,bytes) on ERC-7984
  payments (canonical ABI, declared token contract, declared recipient,
  zero native value, non-empty handle and proof) and reject ERC-7984
  batches; keep only the encrypted amount as a warning.
- Harden Erc7984Token.verifyConfidentialTransfer with zero native value,
  canonical ABI, and single-recipient checks.
- Propagate top-level intent.tokenName in sdk-core resolveEffectiveTxParams
  so stored tokenApproval intents without caller txParams still verify.

Ticket: CECHO-2689
Co-authored-by: Ralph CLI <ralph-cli@bitgo.com>
Ralph: 18.13.2-bitgo.13 openrouter/deepseek/deepseek-v4.1-flash-1017@default:high+task:high openrouter/z-ai/glm-5.3-flash@smol:low+commit:high+memory:low openrouter/anthropic/claude-opus-5.5@slow:high+plan:xhigh openrouter/openai/gpt-6.1-terra@vision:low+advisor:medium openrouter/inclusionai/ling-3.1-flash@tiny:low openrouter/moonshotai/kimi-k3.1-pro@designer:high openrouter/google/gemini-3-pro-image@image web/exa@web openrouter/microsoft/mai-transcribe-2@dictation openrouter/typesafe/jev-1.14@judge
@dpkjnr
dpkjnr requested review from a team as code owners November 19, 2026 17:39

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

@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

…ytes

resolveEffectiveTxParams copied the stored intent's tokenName for every
type, so a caller's native payment could be verified as a payment of the
stored token. Copy it only for tokenApproval. Erc7984Token's confidential
transfer check decoded a rebuilt copy that drops trailing calldata; decode
the original bytes with the shared helper.

Ticket: CECHO-2689

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