Repository navigation
Conversation
Every encrypted state blob AWM seals now carries AEAD associated data naming its flow, blob type, source, wallet pub and signable, and every unseal site recomputes the expected context from the request and rejects a mismatch before any plaintext is decrypted or returned. Blobs replayed across flows (for example keygen state into the EdDSA R-share round), across wallets, or across signing sessions are rejected without disclosing plaintext. The EdDSA R-share envelope gets an additional wrapper applied at the commitment round because the pinned SDK seals it without associated data; the R and G rounds verify the wrapper before handing the inner envelope to the SDK. MPCv2 signing already validates associated data inside the SDK and is unchanged. Legacy blobs without a binding are rejected fail-closed; flows spanning a deploy must be restarted. Ticket: WCI-2169
e279212 to
e1182d8
Compare
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.
Review: bind encrypted MPC state blobs to flow contextI read the full diff, including the seal/unseal helper, all six handler changes and the tests. The approach is sound. Putting the context in the AEAD associated data (AAD) and failing closed is the right way to close the cross-flow decryption-oracle hole. I found no key material, plaintext or blob contents logged or returned on the new error paths. The findings below are all non-blocking, though the first two are worth fixing before merge. Findings1.
2. The AAD is only enforced if
A failed decrypt of a tampered blob also surfaces as a generic error, so probably a 500. A 400 would match the rest of the fail-closed path. 3. AAD values are not escaped ( Values are joined with 4. Keygen state binding is weak across ceremonies (acknowledged residual) The ECDSA MPCv2 and EdDSA keygen state binds only 5. Commitment round now returns an explicit field list ( The old code spread everything 6. New hard requirement on The commitment round now throws a 400 if 7. Rollout The PR text says signer and relay need no coordinated upgrade, which is true for the wire format. But any in-flight keygen or signing session across the deploy now fails with a 400 and needs a restart. That seems acceptable, but it belongs in the release notes, which are currently empty. Nits
TestsThe coverage is good: cross-flow replay, an unbound legacy blob, a different signable, and cross-source and cross-coin keygen replay. Still missing:
Overall the change is a clear improvement. I'd fix findings 1 and 2 and confirm 5 and 6 before merge. |
Summary
Binds every encrypted MPC state blob AWM seals to the context it was created for, and verifies that binding before any unseal:
stateBindinghelper (advancedWalletManager/handlers/utils/stateBinding.ts): seal/unseal with AEAD associated data of the form<domain>:v1|k=v|.... The adata is covered by the AES-GCM tag, so it cannot be stripped or altered without breaking decryption and cannot be forged without the KMS data key.source|pub|sha256(signable)|derivationPath; the R and G rounds verify and peel the wrapper before handing the inner envelope to the SDK.source|coin.sourceplus the consuming stage (round 1..4/finalize), so a state blob sealed for one round slot cannot be replayed into another.Known residuals (follow-ups): binding is not single-use — replaying a blob into its own original context is still accepted (mitigated for MPCv2 signing by the SDK's in-process single-use once the SDK is bumped); keygen state binds only the request-available discriminators above, so a same-context replay across ceremonies is not rejected by the binding.
Test plan
signMpcTransaction.test.ts: new cases — a keygen-flow blob replayed into the R round is rejected without plaintext disclosure, an unbound legacy blob is rejected, and a blob bound to another signable is rejected; the existing commitment→R→G E2E is unchanged.mpcFinalize.test.ts: finalize fixtures resealed with the binding; new cross-source and cross-coin replay rejections.postMpcV2Key.test.ts: new cross-source replay rejection onmpcv2/round; the out-of-sequence round tests now expect the binding rejection (the check fires before the state's own round comparison).src/__tests__/api/advancedWalletManagersuite: 97 passing, 0 failing.npx tsc --noEmitshows one pre-existing error inrecoveryEcdsa.test.ts(RecoverOptions.userKey), verified present on master.Release notes
Ticket: WCI-2169