Repository navigation
feat(wallet): gate high-value transfers behind the 2-of-3 quorum on submission - #1086
Merged
ibochielizabeth-spec merged 4 commits intoNov 27, 2026
Conversation
…ubmission The 2-of-3 quorum policy existed but nothing called it: `submitPayment` built, signed and submitted a high-value envelope with a single key. This wires the policy into the one function every outbound value-moving path goes through, between signing and `server.submitTransaction`, so a transfer that cannot show two valid signatures throws before any transport exists. Second signatures come from the deployment's configured quorum co-signers (`MULTISIG_COSIGNERS`), consulted over the protocol the HSM signer already speaks. A co-signer is only ever asked, never trusted: its reply must be a 64-byte Ed25519 signature that verifies against this exact envelope, its key must already be an on-chain signer on the account, and the whole envelope is then re-verified against the ledger's own signer set and thresholds. With nothing configured, high-value transfers fail closed with `cosigner_unavailable` rather than silently downgrading to single-key submission. Below the threshold nothing new runs - no extra Horizon read, no co-signer resolution - so a broken co-signer configuration cannot break an ordinary payment. `changeTrust` stays single-key, since it moves no value. Also fixes a reservation leak the gate exposed: the refusal is raised after `submissionStarted` is set, but `handleStellarPaymentFailure` only enqueues a reversal for genuine Horizon rejections, so the velocity reservation was left to expire. Refusals raised before any submission now carry `preSubmission`, and the orchestrator releases the reservation itself.
The gate's own comments claimed `submitPayment` is the one function every outbound value-moving path goes through. That was true at the base commit but is not true on current upstream main, and a comment that overstates a security boundary is worse than no comment: the next reader trusts it. `wallet/hotWalletPool.js` (EF-CHAIN#1081, now merged) builds a native payment of arbitrary size from cold storage, signs it with raw in-process keypairs up to its own `coldStorageThreshold`, and submits directly to Horizon. It applies an ad-hoc quorum unrelated to this policy and this gate cannot see or refuse it. The comments now scope the claim to user-facing outbound transfers, enumerate the modules that submit directly, and separate the genuinely exempt ones (changeTrust, fee bumps, channel accounts) from that real gap. Whether the treasury path comes under one policy is a maintainer decision and is flagged as such rather than assumed. Comments only; no behaviour change.
The guard asserted that `feeBump.js` and `channelAccountPool.js` are dormant, which was true at this branch's base but is not on current main: EF-CHAIN#1066 wires `feeBump.buildFeeBumpEnvelope` into `trustlines.js`. Merging EF-CHAIN#959 onto main therefore turned this test red for a reason that is not a bypass — the wrapped operation is a zero-value ChangeTrust. Reworked so it asserts the invariant instead of the snapshot: - `feeBump.js` may have callers, but only allowlisted ones. Subset semantics, so it holds both on a base that predates `trustlines.js` and on main; an unsanctioned caller still fails, because feeBump is generic and could be handed a valued inner transaction. - `channelAccountPool.js` and `hotWalletPool.js` must stay dormant. Both submit valued transactions straight to Horizon. `hotWalletPool` (EF-CHAIN#1081) signs native payments of arbitrary size with raw in-process keypairs under its own quorum notion; nothing requires it today, so it is a latent rather than live gap, and this is what keeps it that way. Verified red-to-green against both trees: this branch's base and a trial merge onto current upstream main. The module comment is corrected to match. Tests only, plus comments; no behaviour change.
This was referenced Nov 26, 2026
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.
Refs #959.
No closing keyword: two requirements below need a maintainer decision before
the gate can safely be enabled. Whether this closes #959 is your call once
they are settled — see "Unresolved requirements".
Rebased onto the repaired
main(c9439b9, #1085). Merged cleanly, noconflicts, and the suite is green on top of it.
What changed
Wires the existing 2-of-3 quorum policy into the submission path.
multisig.jscould already evaluate a quorum, but nothing called it:submitPaymentbuilt, signed and submitted a high-value envelope with asingle key.
The gate now runs inside
wallet/stellar.adapter.js#submitPayment, after theenvelope is signed and before
server.submitTransaction, so a transfer thatcannot show two valid signatures throws before any transport exists. It
re-runs on the
tx_bad_seqrebuild and precedesonEnvelope, so notxHashis persisted for an envelope that never reached the network.
Second signatures come from the deployment's configured quorum co-signers
(
MULTISIG_COSIGNERS), consulted over the hash-based protocol the HSM signeralready speaks. A co-signer is only ever asked, never trusted: its reply
must be a 64-byte Ed25519 signature that verifies against this exact
envelope, its key must already be an on-chain signer on the account, and
authorizeTransactionthen re-verifies the whole envelope against theledger's signer set and thresholds. Fee-bump envelopes are unwrapped, so a
fee-payer's signature cannot stand in for inner authorization.
Below the threshold nothing new runs — no extra Horizon read, no co-signer
resolution — so a broken co-signer configuration cannot affect an ordinary
payment.
Security: a real hole closed on the way
verifyExportChallenge-style bare-id handling is not the only gap this kindof wiring exposes. Here the specific one was a leaked velocity
reservation: the refusal is raised after
submissionStartedis set, buthandleStellarPaymentFailureonly enqueues a reversal for genuine Horizonrejections, so the reservation was left to expire for a transfer that never
left the process — silently shrinking the user's remaining limit. Refusals
raised before submission now carry
preSubmission, and the orchestratorreleases the reservation itself. Post-submission failures still defer to the
reversal job, because those may correspond to a transaction that really is on
the network. Both directions are tested.
Scope of coverage — please read
This gate covers user-facing outbound transfers: the payment
orchestrator, refunds, recurring payments and the SEP-6/SEP-31 rails all
funnel through
submitPayment. It does not cover every path that canreach Horizon, and this PR does not claim to:
establishTrustlineandwallet/trustlines.jssubmitchangeTrustonly,which moves no value and is exempt on purpose (
ZERO_VALUE_OPERATIONS).wallet/feeBump.jswraps an already-authorized inner transaction; its onecaller is
trustlines.js.wallet/channelAccountPool.jsis operational plumbing and is dormant.wallet/hotWalletPool.js(feat(wallet): build ephemeral hot wallet pool with automated multi-sig replenishment (closes #965) #1081) is not exempt and is the one realgap. Its
_executeMultisigTransferbuilds a native payment of arbitrarysize from cold storage, signs it with raw in-process keypairs up to its own
coldStorageThreshold, and submits directly, applying a quorum notionunrelated to this policy. Nothing in
src/requires it today, so it is alatent bypass rather than a live one.
multisig.sendpath.test.jsasserts exactly that shape — one allowlistedfeeBumpcaller, the other two dormant — so widening the ungated surfacefails a test instead of passing silently. Bringing the treasury path under
one policy, or deciding it is deliberately governed separately, is a
maintainer decision and is not made here.
Unresolved requirements (blocking enablement, not review)
Both are disclosed rather than decided, because either answer changes custody
or compliance policy.
Reference currency is unresolved.
classifyTransactioncompares eachasset's total against one bare number in that asset's own units, with
no FX normalization.
MULTISIG_HIGH_VALUE_THRESHOLDdefaults toMAX_SEND_AMOUNT, documented at.env.example:42as XLM. The issue'sacceptance criteria say "exceeding compliance thresholds (e.g. >
$1,000)" — dollars. So 1000 USDC and 1000 XLM gate identically, roughly
3x apart in real value. The orchestrator already carries a
policySnapshotwithreferenceCurrencyandconvertedAmount, so thedata exists, but routing it into a gate that deliberately reads only the
envelope is an architectural change. Decision needed: per-asset
thresholds, or move classification up to where the FX snapshot lives.
Independent approval is not established.
configuredCoSignersforwards any hash to
MULTISIG_COSIGNER_ENDPOINTand attaches whateververifies. The second signature proves a second key and a second credential
were available — it does not prove a second party reviewed the
transfer. Against a stolen custody key that is genuine defense-in-depth;
against a host holding both credentials it is not. Any compliance-review
semantics live entirely inside the external co-signing service, outside
this repo. Decision needed: is that service required to enforce its
own policy (limits, velocity, hold-and-review), and should that be a
documented deployment precondition?
Also not done, deliberately: the issue's required work includes configuring
account thresholds and adding the compliance and operator signers. This code
never mutates on-chain signers or thresholds —
buildThresholdPlanonlyproduces the plan. That is an operator action.
With
MULTISIG_COSIGNERSunset, every transfer above the threshold isrefused with
cosigner_unavailable(409). This is intentionalfail-closed behaviour — never a silent downgrade to single-key submission —
but it means deploying this without configuration does not preserve all
existing payment behaviour: with the default threshold of 1000 XLM,
transfers above 1000 XLM stop working the moment it is deployed.
Rollout order is load-bearing:
high_thresholdto 2.MULTISIG_COSIGNERSandMULTISIG_COSIGNER_ENDPOINT.Deploying before step 1 converts a single-key vulnerability into a
high-value outage.
Tests added
apps/api/test/multisig.sendpath.test.js(22) — the gate is reachable onevery submission path, runs before submission, survives the retry rebuild,
and is the only gated Horizon payment path, plus the tripwire above.
apps/api/test/multisig.orchestrator.test.js(9) — the refusal path: thecaller sees the gate's own error and status, the row is marked failed
exactly once and never advanced to
pending, notxHashis written for anenvelope that never existed, the failed ledger entry is posted only after
the row is failed, the reservation is released for a pre-submission refusal
and not for a post-submission failure, and a failing reversal job cannot
mask the original refusal.
Results on top of
c9439b9main(c9439b9)Targeted: 75/75 (44 existing multisig + Stellar adapter, 22 new
submission-path, 9 new orchestrator). Backend lint: clean.
prisma validate:valid.
git diff --check: clean. Node 20.20.2, all services mocked,synthetic accounts only — no live signers, credentials or transactions.
Thank you for #1085 — it took this branch from "32 pre-existing failures I
have to explain" to a clean run.
How to test
Scope exception requested: three implementation files
The checklist asks for no more than two. This changes three:
multisig.js,stellar.adapter.js,payment.orchestrator.js(
.env.exampleis config documentation; the rest are tests).Requesting an exception to keep them together. The 6-line orchestrator
edit is the other half of the gate, not a separate change: the gate's refusal
is what creates the leaked velocity reservation, and the reservation fix is
unreachable and untestable without the gate. Splitting them would ship a
release window in which a refused high-value transfer silently consumes the
user's velocity allowance, and would put the gate and the test proving it
unwinds correctly in different PRs. Happy to split if you would rather — say
the word and I will reorder them so the reservation fix lands first.
Checklist
npm testpasses and new backend logic has tests inapps/api/test/scope exception requested above
.env.example; module comments state thesubmission boundary and every exception to it)
.envfiles committed.env.example