Skip to content

fix(sdk-coin-flrp): verify import destination and close ImportToC type-gate bypass - #10188

Open
prithvishet2503 wants to merge 1 commit into
masterfrom
prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import
Open

prithvishet2503 wants to merge 1 commit into
masterfrom
prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import

Conversation

@prithvishet2503

@prithvishet2503 prithvishet2503 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Problem. Flrp.verifyTransaction's Import branch validated only shapes — output counts, recipient counts, and (for import-to-P) consumed UTXO ids — but never verified who receives the
imported value (CECHO-2717, mirroring the avaxp avaxp-verifytransaction-import-destination-not-bound finding):

  • Import to C-chain (evm.ImportTx): the branch checked explainedTx.outputs.length === 1 and recipients.length === 1, then stopped. The single output's 0x address — parsed straight from the
    attacker-controllable prebuild bytes — was never compared to the expected recipient.
  • Import to P-chain (pvm.ImportTx): only validateImportTx ran, which checks consumed UTXO ids and only when txParams.unspents is defined. The output owner set/threshold that actually
    receives the funds was never checked.
  • Type-gate bypass: TransactionType has no ImportToC key, so the gate carried an explicit exemption (normalizedType !== 'ImportToC') that skipped the type check entirely for ImportToC —
    masking the enum gap and letting a caller who asked for an import be served a prebuild of any type with no type constraint at all.

Exploit. After the user's export step, a compromised platform serves an import prebuild paying the wallet's in-flight atomic UTXOs to an attacker C-chain address or an attacker-owned
P-chain output. verifyTransaction passes; the MPC flow computes/accepts the digest over these bytes and signs (addExternalSignature has no destination check); the imported value lands at
the attacker's address — full theft of the in-flight cross-chain amount, with the verify-before-sign integrity control fully defeated. Fixing the sdk-core pre-hashed-digest finding does not
close this: the verified bytes themselves carry the attacker's destination.

Fix (modules/sdk-coin-flrp/src/flrp.ts):

  1. Import to C-chain — destination check. The single output's 0x address must be a valid C-chain address and must equal txParams.recipients[0].address, compared case-insensitively (the
    parsed output is lowercase; callers pass checksummed EIP-55 addresses). The expected recipient is runtime-guarded (typeof + isValidEthAddress) before comparison — a
    missing/empty/undefined value yields a clean Invalid expected C-chain import recipient: ... error, not a TypeError. The UTXO-id check (validateImportTx) now also applies to this branch
    when txParams.unspents is supplied.
  • No wallet-side C-chain anchor exists and none can be built: the paired C address is keccak(pubkey)[12:], underivable from the P-chain rootAddress (bech32 carries only
    ripemd160(pubkey)), and WalletCoinSpecific carries no paired C address — so recipients, which come from the persisted intent on the TSS signing path and from the caller's request params
    on prebuild paths (never from the prebuild being verified), is the only intent source. Documented in-code.
  1. Import to P-chain — owner-set check (new validateImportDestination). The output owner set (tilde-joined P addresses) must equal the wallet's expected destination:
  • txParams.recipients[0].address and wallet.coinSpecific().rootAddress are both intent sources; when both are present they must agree — a disagreement throws Import destination intent
    conflict instead of silently preferring one;
  • neither available → fails closed (Unable to verify import destination: ...);
  • comparison is order- and case-insensitive over the sorted owner set (shared normalizeAddressSet helper), and both sides are format-validated first.
  1. Type gate closed. ImportToC, importtoc, and import now all normalize to 'Import' — a real TransactionType key — and are enforced like every other type. A caller asking for an import who
    receives an Export or AddPermissionlessDelegator prebuild now gets Tx type does not match with expected txParams type. (This also resolves the BG-62112-class enum aliasing that avaxp
    still carries as a TODO.)
  2. Export branch — destination binding. validateExportTx now compares the exported output's destination to recipients[0].address whenever a non-empty address is supplied — a prebuild
    exporting to a different destination than requested fails. The legitimate empty-placeholder convention (destination supplied by the later import step) remains a no-op.
  3. Delegator branch — nodeID binding. validateDelegationTx now compares the parsed transaction's validator nodeId (exposed as outputs[0].address for delegations) to stakingOptions.nodeID —
    a prebuild staking to a different node than the user chose throws Delegation nodeID mismatch.

Design note: the ticket's addExternalSignature/ImportInCTxBuilder observations describe the data flow correctly, but the fix belongs in verifyTransaction — the integrity gate. The MPC
signature path stays type-agnostic, as in every coin; once verification binds the destination, the signed bytes are trustworthy.

⚠️ Behavior change (stricter verification contract): an Import with no recipients and no wallet rootAddress now throws instead of passing with no destination check at all; an import whose
recipient disagrees with the wallet's rootAddress now throws instead of silently preferring one source. Real signing flows always carry at least one intent source (sdk-core passes wallet;
the TSS path resolves recipients from the persisted intent), so only previously-unverifiable inputs are rejected.

Known related gap (not this PR): sdk-coin-avaxp has the identical unfixed pattern — filed as CECHO-2808 with the full mirror-fix recipe.

Issue Number

Ticket: CECHO-2717
Follow-up: CECHO-2808

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?

Ground truth was established first: the fixture transactions were built and explained through the real TransactionBuilderFactory path to confirm exactly what the destination fields resolve
to (IMPORT_IN_C output → 0x17dbd11b9dd1c9be337353db7c14f9fb3662e5b5 lowercase vs checksummed IMPORT_IN_C.to; IMPORT_IN_P output → the sorted tilde-joined 3-address owner set matching
IMPORT_IN_P.pAddresses; delegation outputs → the validator NodeID-... string).

16 new tests + 3 existing tests updated to carry destination intent, in modules/sdk-coin-flrp/test/unit/flrp.ts:

Import to C-chain:

  1. Attacker destination (0x000...0001) with otherwise-matching shape → throws Import destination ... does not match the expected recipient (the CECHO-2717 scenario; passed before the fix)
  2. Lowercase vs checksummed recipient compares equal → true
  3. Empty-string recipient → clean Invalid expected C-chain import recipient: (no TypeError)
  4. Undefined recipient → clean Invalid expected C-chain import recipient: undefined
  5. Missing recipients → throws (pre-existing shape check, unchanged)

Import to P-chain:
6. Attacker owner set (single attacker P address) → throws (the CECHO-2717 scenario; passed before the fix)
7. wallet.coinSpecific().rootAddress fallback with matching owner set → true
8. rootAddress mismatch → throws
9. Recipients and rootAddress both present and disagreeing → throws Import destination intent conflict
10. Recipients and rootAddress both present, reversed order → true (order-insensitive)
11. No recipients and no wallet → throws Unable to verify import destination (fail closed)

Type gate:
12. type: 'ImportToC' with an Export prebuild → throws Tx type does not match with expected txParams type (bypassed the gate entirely before this fix)
13. type: 'importtoc' (lowercase intent alias) with a genuine import-to-C → true

Export:
14. Recipient carries the matching destination → true
15. Recipient carries an attacker destination → throws Export destination ... does not match the expected recipient

Delegator:
16. Parsed nodeId equals stakingOptions.nodeID → passes; different node → throws Delegation nodeID mismatch

Reproduce:

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

Also verified: module tsc build clean, eslint --quiet clean, prettier --check clean. The three updated tests previously passed without destination intent — they now exercise the destination
checks the way real signing flows do (recipients from the intent, or the wallet's rootAddress), and every other pre-existing test (export fixtures, delegation validation, MPC builds,
address validation, keypairs, explain) passes unchanged.

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-2717)
  • I have made corresponding changes to the documentation and on any new/updated functions and/or methods (JSDoc on validateImportDestination; in-code comments on both import destination
    checks, the intent-source provenance and C-anchor impossibility, the export binding, the delegator nodeID binding, and the type-gate normalization)
  • 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 (382

@linear-code

linear-code Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

CECHO-2717

@prithvishet2503

Copy link
Copy Markdown
Contributor Author

@claude review this PR and Score it

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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


Review of PR #10188 (CECHO-2717)

Score: 8.5 / 10. Approve with minor suggestions.

I read the source diff in modules/sdk-coin-flrp/src/flrp.ts. I did not run the test suite or read the test diff, so the "374 passing" figure is the PR's own claim. The only check I ran was a grep confirming that isValidEthAddress (flrp.ts:38) and ADDRESS_SEPARATOR (lib/iface.ts:73) exist and are imported.

What's good

  • It fixes the stated problem at the right layer. verifyTransaction is the integrity gate. The Import-to-C branch now compares the parsed output address to recipients[0]. The Import-to-P branch now compares the output owner set to the expected wallet destination.
  • The type-gate bypass is closed. ImportToC and importtoc now alias to Import, a real TransactionType key, and the !== 'ImportToC' exemption is gone. Callers who ask for an import and get a different transaction type are now rejected.
  • It fails closed. With no recipients and no wallet rootAddress, the P-chain import throws.
  • The comparison is sound. It is order- and case-insensitive over the sorted owner set, and both sides are format-validated first. Splitting on ~ avoids false mismatches from ordering.
  • The new tests cover the cases that matter. They include the attacker-destination cases for both chains, the rootAddress fallback and mismatch, the fail-closed case and the type-gate case.

Suggestions and concerns

  1. Import-to-C has no wallet-based fallback. It trusts txParams.recipients[0] entirely. If a caller, or an attacker influencing txParams, supplies the same bad address as the prebuild, verification passes. The P-chain branch at least has a rootAddress anchor. If the wallet has a paired C-chain address available via coinSpecific, consider requiring a match against it, or at least documenting that recipients must come from the user's intent and not from the platform.
  2. Recipients take precedence over rootAddress for Import-to-P. recipients[0].address || rootAddress means a supplied recipient overrides the wallet identity. An import should only ever pay the wallet itself, so consider requiring both to agree when both are present. It's a defense-in-depth point, and the current behavior is defensible.
  3. Missing txParams.type still skips the type check. The comment says the branches validate what they can. That is fine for the Import branches now, but the same reasoning isn't applied to every other type. It's worth confirming the Export and Delegator branches also bind the destination.
  4. expectedCDestination isn't format-validated before .toLowerCase(). recipients[0].address is only checked implicitly through equality. This is harmless, since the output has already been validated and an invalid expected address can't equal it. If address is undefined, though, you get a TypeError instead of a clean error. A small guard would help.
  5. Behavior change for callers. Any existing caller that used Import without recipients (P-chain) or without a wallet now throws. That is intended, but I'd call it out in release notes as a stricter verification contract.
  6. The avaxp mirror fix is still open. Please make sure the follow-up ticket exists.

Verdict

The change is correct, focused and well tested for the threat described. The remaining points are hardening and polish, not blockers.
| Branch: prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import

@github-actions

github-actions Bot commented Nov 17, 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
prithvishet2503 marked this pull request as ready for review November 17, 2026 01:10
@prithvishet2503
prithvishet2503 requested a review from a team as a code owner November 17, 2026 01:10

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

@prithvishet2503
prithvishet2503 force-pushed the prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import branch from 70e4706 to 26819ad Compare November 17, 2026 01:16
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
@prithvishet2503

Copy link
Copy Markdown
Contributor Author

@claude review this PR and Score it

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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


Review of PR #10188 (CECHO-2717)

Score: 8 / 10. Approve with follow-ups.

I read the source diff in modules/sdk-coin-flrp/src/flrp.ts. I did not run the tests or read the test diff, so the "382 passing" figure is the PR's own claim. Local git diff origin/master...HEAD failed with "no merge base", so I used git show HEAD.

What's good

  • The fix is at the right layer. verifyTransaction is the integrity gate, and the signing path stays type-agnostic.
  • The type-gate bypass is closed. ImportToC, importtoc and import all normalize to the real Import key, and the !== 'ImportToC' exemption is gone.
  • The C-chain check is careful. The expected recipient gets a typeof and isValidEthAddress guard, then a case-insensitive comparison. A missing recipient now gives a clean error instead of a TypeError. validateImportTx also runs on this branch.
  • The P-chain check fails closed. It uses an order- and case-insensitive owner-set comparison. The recipient and rootAddress must agree when both are present, and it throws when neither is available.
  • The Export and Delegator hardening is useful. The export destination and the delegation nodeID are now bound to intent.

Concerns (none are blockers)

  1. The intent source may not be independent of the platform (flrp.ts:~265).
    • On the TSS path, resolveEffectiveTxParams fills recipients from txRequest.intent.recipients when the client passes none. That data is server-supplied.
    • A compromised platform can put the attacker address in both the intent and the prebuild, and the recipient check then passes.
    • For import-to-P, rootAddress is the only wallet-anchored value. Make it mandatory when it exists, and treat recipients as an extra check that must also match.
    • For import-to-C, there is no wallet anchor at all. The in-code comment says so, but the PR description overstates what this closes for that path. State the residual trust assumption explicitly.
  2. Only the owner set is bound, not the threshold or locktime (flrp.ts:~300).
    • mapOutputToEntry drops the threshold and locktime, so an output over the wallet's own addresses with a lowered threshold or a future locktime still passes.
    • The PR text names "owner set/threshold" as the thing being protected, so this is a gap against the stated goal.
    • Consider checking both on the parsed TransferOutput.
  3. Possible regression for wallets without a usable rootAddress.
    • Import-to-P with empty recipients and no rootAddress, or a non-P-form rootAddress, now throws. Before this PR it passed.
    • Please confirm that every production FLRP wallet exposes a P-form rootAddress in coinSpecific().
    • If it doesn't, derive the expected owner set from the wallet keychains instead.
  4. A missing txParams.type still skips the type check. The import branches now bind the destination, so this is acceptable. Add a test that pins it for the TSS flow.
  5. The Delegator nodeID comparison is skipped when outputs is empty (txNodeId is undefined). Consider failing closed there.
  6. flrp.ts:36-37 swaps the BigNumber and ethereumjs-util import order. This is an unrelated cosmetic change.
  7. Call out the stricter verification contract in release notes. The CECHO-2808 avaxp follow-up exists and is referenced.

Verdict

This is a solid, focused hardening change with good test coverage for the described attack. Concerns 1–3 decide how much of the stated threat is actually closed. I'd resolve 2 and 3, and document 1, before or soon after merge.
| Branch: prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import

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

Still open from earlier reviews (2):

  • 🔴 modules/sdk-coin-flrp/src/flrp.ts:245 — Wallets whose import intent has no recipients and whose rootAddress is missing or not a P-chain owner set can no longer…
  • Also unresolved: 1 minor or pre-existing.

If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.

Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
@prithvishet2503
prithvishet2503 force-pushed the prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import branch from 26819ad to c947795 Compare November 17, 2026 01:27
@prithvishet2503

Copy link
Copy Markdown
Contributor Author

@claude review this PR and Score it

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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


Review of PR #10188 (CECHO-2717)

Score: 7.5 / 10. Approve with follow-ups. One regression risk needs confirming before merge.

I read the source diff of modules/sdk-coin-flrp/src/flrp.ts at HEAD (c947795) and checked ExportInPTxBuilder.ts and the rootAddress references. I did not run the tests or read the test diff, so the "382 passing" figure is the PR's own claim.

What's good

  • The fix is at the right layer. verifyTransaction is the integrity gate, and the signing path stays type-agnostic.
  • The type gate is closed. ImportToC, importtoc and import all normalize to the real Import key, and the !== 'ImportToC' exemption is gone.
  • The C-chain check is careful. The expected recipient gets a typeof and isValidEthAddress guard, then a case-insensitive comparison. validateImportTx now runs on this branch too.
  • The P-chain check fails closed.
    • It compares the owner set without regard to order or case.
    • It throws when recipient and rootAddress disagree, and when neither is present.
  • The earlier review gaps are fixed. validateImportOutputPolicy now checks locktime 0 and that the output threshold matches the consumed UTXOs' threshold. The delegation nodeID check now throws when no nodeId is exposed.
  • The residual trust assumption for C-chain is now written down in the code comment.

Concerns

  1. Regression risk: P→C export binding (flrp.ts:~222-235). Please verify before merge.

    • ExportInPTxBuilder.ts:159-166 builds the exported output with the wallet's own _fromAddresses as owners. The recipient is not used.
    • If a P→C export carries a non-empty recipients[0].address that is a 0x or C- address, validateExportTx throws Invalid expected export destination. A recipient that is only part of the wallet's P set fails the comparison instead.
    • Base verified these exports.
    • Either bind the destination only for flows where the recipient actually sets the output owners, or compare P→C exports against the wallet's own from-addresses.
    • Add a test with a realistic P→C export recipient.
  2. Regression risk: wallets without a usable rootAddress.

    • Import-to-P with empty recipients and a missing or non-P-form rootAddress now throws. Base passed these, and the old tests used recipients: [] with no wallet.
    • Nothing in this repo sets rootAddress.
    • Please confirm that every production FLRP wallet exposes a P-form rootAddress. If not, derive the expected owner set from the wallet keychains, as isWalletAddress does.
  3. The intent source is still not fully independent of the platform.

    • On the TSS path, resolveEffectiveTxParams fills recipients from the server-side txRequest.intent. A platform that controls both intent and prebuild passes the check.
    • For import-to-P, make rootAddress the mandatory anchor when it exists. The current agreement check helps only when both values are present, and a recipient alone is still accepted.
    • For import-to-C there is no wallet anchor. The PR description says this closes the compromised-platform scenario, so narrow that claim to match the in-code caveat.
  4. No value or fee bound on imports (pre-existing).

    • Neither import branch compares outputs[0] value to the sum of the inputs. A prebuild can pay the correct destination a dust amount and burn the rest as fee.
    • Export already bounds this with maxImportFee. I'd add the same bound here, now or as a follow-up.
  5. The delegation stake owners and rewards owner are not checked (pre-existing).

    • validateDelegationTx binds nodeID and amount only. The stake-return owners and rewardAddresses are never compared to the wallet or to stakingOptions.rewardAddress.
    • This is out of scope for this PR but worth a ticket.
  6. A missing txParams.type still skips the type check.

    • This is acceptable now that each branch binds what it can.
    • Add a test that pins this behavior for the TSS flow.
  7. Cosmetic: the BigNumber and ethereumjs-util import order swap is unrelated to the fix.

  8. Release notes. Call out the stricter verification contract: an import with no destination intent, and an import whose recipient disagrees with rootAddress, now both throw. CECHO-2808 covers the avaxp mirror fix.

Verdict

The core fix is correct and closes the reported bypass for the cases where the client supplies the intent. Concerns 1 and 2 could block previously working flows. I'd confirm or fix them before merge. Concerns 3–5 can follow.
| Branch: prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import

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

Still open from earlier reviews (4):

  • 🔴 modules/sdk-coin-flrp/src/flrp.ts:236 — P-to-C exports whose recipient is the C-chain destination can no longer be verified or signed, which works on the base…
  • Also unresolved: 2 minor or pre-existing, 1 blocking on lines changed since (possibly already fixed).

If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.

Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
@prithvishet2503
prithvishet2503 force-pushed the prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import branch from c947795 to cd8bb84 Compare November 17, 2026 15:36
@prithvishet2503

Copy link
Copy Markdown
Contributor Author

@claude review this PR and score it

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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


Review of PR #10188 (CECHO-2717)

Score: 8.5 / 10. Approve with minor follow-ups.

I read modules/sdk-coin-flrp/src/flrp.ts at HEAD (cd8bb84), including verifyTransaction, validateExportTx, validateImportDestination, validateImportOutputPolicy, validateImportFee, validateDelegationTx and validateDelegationOwners. I did not run the tests or read the test diff, so the "382 passing" figure is the PR's own claim.

Earlier review findings that are now fixed in the code

  • P→C export regression. validateExportTx binds the destination only for C→P exports (tx.isTransactionForCChain). P→C exports are deliberately left unbound, and a comment explains why. A non-empty recipient of 0x or C- form no longer throws.
  • Mixed-threshold import regression. validateImportOutputPolicy no longer ties the output threshold to the consumed UTXOs' thresholds. It checks locktime 0, at least one consumed UTXO, and a structurally valid threshold. The comment explains that a 1-of-N UTXO imported into a 2-of-3 output is legitimate.
  • Import fee bound. validateImportFee caps the burned fee at maxImportFee on both import branches.
  • Delegation owners. validateDelegationOwners checks the stake owner set against the wallet anchor and the single rewards owner against stakingOptions.rewardAddress. It fails closed when the stake outputs or the rewards owner are missing.
  • Delegation nodeID. The nodeID check now throws when the parsed transaction exposes no nodeId.
  • Type gate. ImportToC, importtoc and import all normalize to Import, and the !== 'ImportToC' exemption is gone.

Remaining concerns (none block merge)

  1. The intent source is still not independent of the platform.

    • In validateImportDestination, recipientAddress wins over the wallet values, and on the TSS path resolveEffectiveTxParams fills it from the server-side intent.
    • The agreement check only applies when rootAddress is also present. A platform that controls both the intent and the prebuild passes whenever rootAddress is unset.
    • Import-to-C has no wallet anchor at all. The in-code comment states this honestly, but the PR description still says the compromised-platform theft is closed. Please narrow that wording to "closed when the client supplies the intent".
  2. receiveAddress() as a last-resort anchor (flrp.ts:313).

    • Confirm that a wallet's receiveAddress() is always the full P-form owner set. If it is a single member address or a different form, a legitimate import throws Invalid expected import destination or a mismatch.
    • Call it defensively, because a wallet stub without receiveAddress will raise a TypeError. The thrown "Unable to verify" message also doesn't mention receiveAddress.
  3. The output threshold can still be weakened within the wallet's own owner set. The comment at flrp.ts:336-350 admits this, because no authoritative expected threshold reaches verifyTransaction. That is acceptable, but the PR text still claims it protects the "owner set/threshold". Align the wording.

  4. validateDelegationOwners binds the stake owners only when a wallet anchor exists (flrp.ts:489-490). With no anchor, only the rewards owner is bound. This is the same trust limitation as item 1, and a short comment would help.

  5. A delegation with no stakingOptions skips both delegation checks (flrp.ts:~178). This is pre-existing and consistent with the other coins, but a stake prebuild with no stakingOptions verifies with no binding at all. Consider failing closed when normalizedType is AddPermissionlessDelegator and stakingOptions is missing.

  6. Cosmetic. The BigNumber and ethereumjs-util import order swap is unrelated to the fix.

  7. Release notes. Call out the stricter verification contract:

    • An import with no destination intent now throws.
    • An import whose recipient disagrees with rootAddress now throws.
    • An import consuming zero UTXOs now throws.
    • An import that burns more than maxImportFee now throws.
    • A delegation whose rewards owner or stake owners differ from intent now throws.

    CECHO-2808 tracks the avaxp mirror fix.

Verdict

The change is correct and focused, and it fixes the stated bypass at the right layer. It now handles the regression risks raised in earlier rounds. What remains is mostly the residual trust assumption on the intent source, plus a couple of defensive details around receiveAddress(). These are worth documenting or tightening, but they aren't blockers.
| Branch: prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import

manojkumar138
manojkumar138 previously approved these changes Nov 17, 2026

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

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/test/unit/flrp.ts Resolved
Comment thread modules/sdk-coin-flrp/src/flrp.ts Resolved
…e-gate bypass

Flrp.verifyTransaction's Import branch never verified who receives the
imported value: the import-to-C branch checked only output/recipient
counts, and the import-to-P branch checked only consumed UTXO ids. The
type-match gate was skipped entirely for 'ImportToC' (TransactionType
has no such key) and for a missing txParams.type. A compromised
platform could serve an import prebuild paying the wallet's in-flight
atomic UTXOs to an attacker C-chain address or P-chain owner set;
verification passed and the MPC flow signed the theft (CECHO-2717).

- Import to C-chain: the single output's 0x address must equal the
  expected recipient (case-insensitive) and be a valid C-chain address.
  Consumed UTXO ids are also checked against txParams.unspents when
  supplied.
- Import to P-chain: the output owner set (tilde-joined P addresses)
  must equal the wallet's expected destination — txParams.recipients
  when supplied, else the wallet's rootAddress — compared order- and
  case-insensitively over the sorted owner set. No destination intent
  at all fails closed.
- Type gate: 'ImportToC' and 'importtoc' now alias to 'Import' and are
  enforced like every other type, closing the exemption that let a
  mismatched prebuild type slip through.

Ticket: CECHO-2717
@prithvishet2503
prithvishet2503 force-pushed the prithvishet/cecho-2717-bitgojs-flrpverifytransaction-import branch from cd8bb84 to 7477f12 Compare November 17, 2026 16:47

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.

2 participants