Repository navigation
fix(sdk-coin-flrp): verify import destination and close ImportToC type-gate bypass - #10188
prithvishet2503 wants to merge 1 commit into
Conversation
|
@claude review this PR and Score it |
|
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 What's good
Suggestions and concerns
VerdictThe change is correct, focused and well tested for the threat described. The remaining points are hardening and polish, not blockers. |
|
|
There was a problem hiding this comment.
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.
70e4706 to
26819ad
Compare
|
@claude review this PR and Score it |
|
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 What's good
Concerns (none are blockers)
VerdictThis 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. |
There was a problem hiding this comment.
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.
26819ad to
c947795
Compare
|
@claude review this PR and Score it |
|
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 What's good
Concerns
VerdictThe 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. |
There was a problem hiding this comment.
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.
c947795 to
cd8bb84
Compare
|
@claude review this PR and score it |
|
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 Earlier review findings that are now fixed in the code
Remaining concerns (none block merge)
VerdictThe 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 |
…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
cd8bb84 to
7477f12
Compare
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):
attacker-controllable prebuild bytes — was never compared to the expected recipient.
receives the funds was never checked.
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):
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.
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.
conflict instead of silently preferring one;
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.)
exporting to a different destination than requested fails. The legitimate empty-placeholder convention (destination supplied by the later import step) remains a no-op.
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.
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
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:
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:
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
checks, the intent-source provenance and C-anchor impossibility, the export binding, the delegator nodeID binding, and the type-gate normalization)