Skip to content

fix(sdk-core): assert signableHex consistency in ECDSA MPCv1 signing - #10177

Merged
vibhavgo merged 1 commit into
masterfrom
vibhavgopalkrishna/wci-2239-bitgojs-legacy-ecdsa-mpcv1-path
Nov 16, 2026
Merged

vibhavgo merged 1 commit into
masterfrom
vibhavgopalkrishna/wci-2239-bitgojs-legacy-ecdsa-mpcv1-path

Conversation

@vibhavgo

Copy link
Copy Markdown
Contributor

Summary

Adds a signableHex/serializedTxHex consistency check to the legacy ECDSA MPCv1 signing path for TSS_VERIFY_USE_SERIALIZED_TX_HEX coins (BSC/XDC), matching the check the MPCv2 path already performs (WCI-1398).

Linear: WCI-2239

Changes

  • EcdsaUtils.signRequestBase (sdk-core) now calls baseCoin.assertSignableConsistency(serializedTxHex, signableHex) after verifyTransaction when shouldVerifyWithSerializedTxHex is true and the coin implements the check — identical guard to ecdsaMPCv2.ts
  • Unit tests for the wiring/guard semantics (sdk-core) and end-to-end tests with the real tbsc coin (sdk-coin-bsc)

Test Plan

  • cd modules/sdk-core && BITGOJS_TEST_PASSWORD=test npx mocha test/unit/bitgo/utils/tss/ecdsa/ecdsa.ts
  • cd modules/sdk-coin-bsc && BITGOJS_TEST_PASSWORD=test npx mocha test/unit/bsc.ts
  • yarn lint-changed

@linear-code

linear-code Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

WCI-2239

@github-actions

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

@vibhavgo
vibhavgo force-pushed the vibhavgopalkrishna/wci-2239-bitgojs-legacy-ecdsa-mpcv1-path branch from 428bdce to ee0c89b Compare November 13, 2026 08:20
@vibhavgo

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @vibhavgo's task in 33s —— View job


Review of PR #10177

  • Read the diff and compare with the MPCv2 path
  • Check assertSignableConsistency in abstract-eth
  • Review the tests

Verdict: looks good, with only nits. I only read the code. I did not run the tests, and I couldn't get a diff against origin/master here because the checkout has no merge base. I reviewed the changed files directly.

Correctness

  • modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsa.ts:1079-1081 matches ecdsaMPCv2.ts:998-1000. It runs after verifyTransaction and before the payload is signed or any share is produced.
  • A coin with TSS_VERIFY_USE_SERIALIZED_TX_HEX that has no assertSignableConsistency (the ICP shape) is skipped safely by the isCoinWithSignableConsistency type guard.
  • signRequestBase is the only MPCv1 call site that calls verifyTransaction (searched under ecdsa/), so I found no other legacy path that needs the same check.
  • The abstract-eth implementation (abstractEthLikeNewCoins.ts:3437) re-derives signableHex from serializedTxHex. It handles both legacy and EIP-1559 transactions and sets Petersburg for chains without EIP-1559, such as BSC and XDC. It throws InvalidTransactionError on a mismatch, which is what you want here.

Nits (non-blocking)

  1. Redundant condition (ecdsa.ts:1079): shouldVerifyWithSerializedTxHex(this.baseCoin) is already true inside this if block, so only isCoinWithSignableConsistency(this.baseCoin) is needed. You may want to keep it so the line is identical to the MPCv2 one. In MPCv2 it is needed, because that branch is also entered via shouldUsePreHashedSignable. A small shared helper would stop the two copies from drifting apart.
  2. Redundant restores (test/unit/bitgo/utils/tss/ecdsa/ecdsa.ts:83,139): sentinel.restore() is redundant because afterEach already calls sinon.restore().
  3. Weak test fixture (same file, lines 15-16): serializedTxHex and signableHex are the same string, and the tx is truncated RLP. That is fine for mock-based wiring tests. Use clearly different values so the argument-order assertion at line 79 can detect swapped arguments. If the two arguments were swapped, deepStrictEqual would still pass.
  4. Unrelated doc comment (not part of this PR): abstractEthLikeNewCoins.ts:3433-3436 has a mangled JSDoc. The Verify if a tss transaction is valid block is left unclosed and the @inheritdoc is nested inside it. It is worth fixing in a follow-up.

Tests

The sdk-core tests cover four cases: the arguments passed, an abort before any share is produced, skipping for non-flag coins, and not crashing for flag coins without the method. The sdk-coin-bsc end-to-end tests use the real tbsc coin. I didn't read the bsc test diff in detail.

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

@vibhavgo
vibhavgo force-pushed the vibhavgopalkrishna/wci-2239-bitgojs-legacy-ecdsa-mpcv1-path branch from ee0c89b to 92d5a04 Compare November 13, 2026 09:53
For TSS_VERIFY_USE_SERIALIZED_TX_HEX coins (BSC/XDC), the MPCv1 signing path verified serializedTxHex and signed signableHex without binding the two fields. Adds the same assertSignableConsistency check the MPCv2 path already performs (WCI-1398) so the signed payload must be consistent with the verified transaction.

Ticket: WCI-2239
@vibhavgo
vibhavgo force-pushed the vibhavgopalkrishna/wci-2239-bitgojs-legacy-ecdsa-mpcv1-path branch from 92d5a04 to 57d6ffd Compare November 13, 2026 09:56
@vibhavgo

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @vibhavgo's task in 13s —— View job


Review of PR #10177

Verdict: the change is correct and ready to merge. Everything below is optional. I read the diff and did not run the tests.

Source change (ecdsa.ts:1079)

  • The guard is the same as the MPCv2 one. It runs after verifyTransaction and before any share is produced.
  • A TSS_VERIFY_USE_SERIALIZED_TX_HEX coin with no assertSignableConsistency (the ICP shape) is skipped by the type guard.
  • The shouldVerifyWithSerializedTxHex(this.baseCoin) half of the condition is redundant here, because the enclosing if already checked it. Keeping it makes the line match MPCv2, so I'm fine with that.

Tests

  • bsc tests: they exercise the real tbsc coin. One rejects a tampered signableHex. The other passes a consistent one, using a sentinel thrown in getOfflineSignerPaillierModulus to show execution got past the check. This covers the wiring well.
  • as any (optional): the new tests use as any in several places, for example reqId: {...} as any in bsc.ts. CLAUDE.md says to avoid any. These can become as unknown as <RealType>. getOfflineSignerPaillierModulus is public, so utils as any isn't needed for the stub.
  • sdk-core fixture (optional): serializedTxHex and signableHex are the same string. The argument-order assertion would still pass if the two arguments were swapped. Use two different strings.
  • Redundant restore (optional): sinon.restore() in the bsc after hook, and sentinel.restore() in the sdk-core tests, are probably redundant if afterEach already restores. Check that the bsc describe has an afterEach restore. A test that fails midway could otherwise leave the coin.verifyTransaction stub in place, so afterEach is safer than after.

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

I re-reviewed the updated push and found no bugs. The as any nit is mostly fixed: the only casts left are the two reqId ones in modules/sdk-coin-bsc/test/unit/bsc.ts. Because this changes the ECDSA MPCv1 signing path, a human reviewer should still look at it.

What was reviewed:

  • The new guard in EcdsaUtils.signRequestBase. It runs assertSignableConsistency only in the serializedTxHex branch, after verifyTransaction and before signableHex becomes the signing payload. It matches the guard in ecdsaMPCv2.ts line for line.
  • isCoinWithSignableConsistency. It is a plain duck-type check, so flagged coins that don't implement the method (ICP) skip the assert and don't crash.
  • The new sdk-core and BSC tests. Between them they cover the tampered case, the consistent case, the unflagged case and the flagged coin with no method. I read them but did not run them.
Extended reasoning...

The change adds a guarded call to assertSignableConsistency in the ECDSA MPCv1 signRequestBase (sdk-core), plus unit tests in sdk-core and sdk-coin-bsc. It closes a gap where the server could tamper with the signed payload: serializedTxHex was verified, but a separately supplied signableHex was what got signed. The edit is small and matches the existing MPCv2 guard. Even so, it sits on the TSS/MPC signing path, which counts as crypto, and modules/sdk-core is covered by CODEOWNERS (wallet-core teams). The latest commit fixed most of the earlier typing nit.

@vibhavgo
vibhavgo marked this pull request as ready for review November 13, 2026 10:43
@vibhavgo
vibhavgo requested review from a team as code owners November 13, 2026 10:43

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

@kisslove-dewangan kisslove-dewangan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@vibhavgo
vibhavgo merged commit b9a36d7 into master Nov 16, 2026
28 checks passed
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.

3 participants