Repository navigation
fix(sdk-coin-eth): strictly verify the multisig enable-token sendMultiSig operation (CECHO-2815) - #10200
Draft
nvrakesh06 wants to merge 1 commit into
Draft
fix(sdk-coin-eth): strictly verify the multisig enable-token sendMultiSig operation (CECHO-2815)#10200nvrakesh06 wants to merge 1 commit into
nvrakesh06 wants to merge 1 commit into
Conversation
…iSig operation (CECHO-2815) The multisig branch of Erc7984Token.verifyEnableTokenTransaction compared only txPrebuild.buildParams.recipients — client-attached echo data built by Wallet.buildTokenEnablements from the caller's own enableTokens — so the operation the user actually signs was never inspected. Onchain-multisig users sign the sendMultiSig operation hash over txPrebuild.recipients[0] (address, amount, data), never over txHex, and the MultiSigV3 contract enforces at execution that the broadcast args hash to that op: a compromised platform could serve any recipient (attacker contract with native value, ERC-20 approve theft, or a delegate substitution) and the user would first-sign it. Strict flow (default): bind the signed recipient in full — 1. sendMultiSig native value must be 0; 2. the recipient data must decode fail-closed as a delegation calldata (rejects approve/transfer and smuggled inner calls); 3. aclMulticall shape must target the ACL contract (the forwarder shape is bound on-chain by onlyParent plus the enforced callFromParent target/value); 4. verifyStrictEnableTokenCalldata binds delegate == pinned enterprise viewing key, future expiry, and an exact deduplicated match against the requested tokens (CECHO-2720 helper, unchanged); 5. when the prebuild carries a txHex, its sendMultiSig args must mirror the recipient — a diverging (decoy) txHex is rejected. Revert path: gated by the Flipt flag cecho-2815-multisig-enable-token-strict- verification delivered on the prebuild as featureFlags. DEFAULT TRUE — the flag absent, unreadable, or true runs strict verification; only an explicit false reverts to the legacy flow, byte-for-byte, per request, with no SDK redeploy. abstract-eth: TransactionPrebuild.featureFlags carries server-evaluated (Flipt) flags with the prebuild; the flag constant lives in zamaUtils so consumers can import it without pulling the sdk-coin-eth module graph (its value import would otherwise enter the eth/erc20Token require cycle first and crash module init). Tests: 13 new multisig strict-path cases — benign both delegation shapes, txHex mirror pass, value theft, approve theft, delegate substitution, smuggled inner call, wrong ACL target, callFromParent theft shape, decoy txHex, non-sendMultiSig txHex, missing recipient, and explicit flag=false reverting to the legacy flow. sdk-coin-eth 591 passing, abstract-eth 188 passing.
Contributor
Contributor
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the client-side verification gap from CECHO-2815: the multisig branch of
Erc7984Token.verifyEnableTokenTransactionvalidated onlytxPrebuild.buildParams.recipients— client-attached echo data thatWallet.buildTokenEnablementsbuilds from the caller's ownenableTokens— so the operation the user actually signs was never inspected.What actually gets signed (the fix's binding target): onchain-multisig users sign the
sendMultiSigoperation hash overtxPrebuild.recipients[0](address, amount, data) — never overtxHex(Eth.signTransaction→getOperationSha3ForExecuteAndConfirmhashes the platform-supplied recipient verbatim;halfSignedcarries notxHex), and the MultiSigV3 contract enforces at execution that the broadcast args hash to that op. Sorecipients[0]is the single authoritative binding, and the strict flow verifies it in full:sendMultiSignative value must be0(blocks direct native-fund theft).decodeDelegationCallsFromCalldata, CECHO-2720): rejects any other selector (e.g. an ERC-20approve(attacker, …)theft prebuild) and any smuggled non-delegation inner call.aclMulticallshape must target the ACL contract; thecallFromParent(forwarder) shape is bound on-chain by the forwarder'sonlyParentmodifier plus the enforcedcallFromParenttarget/value — same decision as the TSS path.verifyStrictEnableTokenCalldata(CECHO-2720 helper, unchanged) binds delegate == pinned enterprise viewing key (fail closed when unpinned), future expiry, and an exact deduplicated match against the requested tokens.txHex, itssendMultiSigargs must mirror the recipient exactly: a diverging (decoy)txHexthat passes verification while different args get signed is rejected.Revert path — Flipt flag, default
true: gated bycecho-2815-multisig-enable-token-strict-verification, evaluated by the platform and delivered on the prebuild astxPrebuild.featureFlags. Default TRUE — flag absent, unreadable, ortrueruns the strict verification; only an explicitfalsereverts to the legacy flow, byte-for-byte, per request, with no SDK redeploy (kill-switch semantics identical in direction to the wrap/unwrap mirror checks).Carrier contract (WP-side, out of this PR's scope):
TransactionPrebuild.featureFlags?: Record<string, boolean>is added to abstract-eth — server-evaluated flags ride the prebuild response; an absent key means that flag's default value, never an error. The Flipt flag definition and the WP plumbing that populates this field are tracked separately (the "Flipt feature" work).Module-graph note: the flag constant lives in
abstract-eth/zamaUtilsrather than sdk-coin-eth so consumers can import it without pulling the sdk-coin-eth graph — a value import fromerc7984Token.tswould otherwise enter theeth/erc20Tokenrequire cycle first and crash module initialization under tsx/esbuild.Known rollout prerequisite (inherited from CECHO-2720): the strict helper fails closed when
zamaViewingKeyAddressis unpinned for the network. Until the Coins Echo team pins the real enterprise viewing keys for mainnet + Hoodi (or the flag is flipped tofalse), strict-mode enable-token verification throws. Both this PR and #10191 share that prerequisite.Issue Number
CECHO-2815 (related: CECHO-2720, CECHO-2719)
Type of change
How Has This Been Tested?
Unit tests — 13 new multisig strict-path cases in
modules/sdk-coin-eth/test/unit/erc7984Token.ts:aclMulticallshape) passes with the flag absent (default true)callFromParentshape) passestxHexpassessendMultiSigvalue rejected (native fund theft)approvetheft prebuild rejected (non-delegation calldata)aclMulticallshape targeted away from the ACL contract rejectedcallFromParenttheft shape (forwarder → attacker contract with funds) rejectedtxHexwhosesendMultiSigargs differ from the signed recipient rejectedtxHexthat is not asendMultiSigenvelope rejectedflag=falsereverts to the legacy flow — a fully hostile prebuild passes, proving the kill switch restores the old behavior byte-for-byteThe five pre-existing legacy-path tests now pin the flag to
false(they document the legacy buildParams contract and prove the revert path).Full-module runs:
modules/sdk-coin-eth591 passing,modules/abstract-eth188 passing — zero failures. Reproduce:cd modules/sdk-coin-eth && npx mocha(alsomodules/abstract-eth).Checklist