This document formalizes what Section 13 of the technical architecture already narrates in prose. It is not a rewrite of that section - it restates the same design as a structured STRIDE analysis (Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, Elevation of privilege) so a reader, an auditor, or the security-tooling remediation plan can check specific threats against specific mitigations, one surface at a time. The invariant register lists the invariants these mitigations rest on, each with the code that enforces it and the test that proves it.
Status as of 2026-10-13, checked against commit6a76eab. This is a point-in-time document: it describes the controls present in the code at that commit and the residual risk accepted at that date. Next refresh: in the pull request that adds the next surface, adapter or signing key (Section 13), or by 2027-01-08, when the contract registry’svalidUntilfalls due, whichever comes first. Self-assessed. Written by the LumenWipe maintainers, not by an outside reviewer. Published security reports are listed at lumenwipe.com/security/reports.
1. Scope and method
In scope, one STRIDE pass per surface:- Client-side key handling (wallet path and the secret-key advanced mode).
- The client-side session layer (the
DemolishPhasestate machine and IndexedDB session store). - API transaction construction (the pure transaction-builder module).
- The two backend signing keys: the mediator co-sign key, and the fee-bump sponsor key.
- Allowance revocation (Phase 2, epic #159).
- Soroban token conversion via Soroswap (Phase 2, epic #159).
- DeFi exit adapters - Blend, Aquarius, Soroswap router, Phoenix, FxDAO - and the xBull conversion quote source (epic #151), with Phoenix, FxDAO and xBull each given their own pass.
- The integrator access layer: wallet sign-in, session tokens, and self-serve API key issuance, rotation and revocation.
- Read-only external data sources (RPC providers, the Horizon-compatible enumeration endpoint, the Soroswap routing API, OctoPos, and StellarIndex, a candidate source for tokens and allowances). These carry availability risk, not custody risk - they cannot move funds - and are already addressed as a trust-minimization concern in Section 14, not repeated here.
- A third-party penetration test or formal audit. Not done yet, and outside this document’s scope.
- Infrastructure-level threats (cloud provider compromise, CI/CD supply-chain attacks against the deploy pipeline). Covered by Section 15’s deployment model, not re-analyzed here.
docs/architecture.md or traced to the specific source
file that implements it - this document verifies existing controls, it does not propose new ones.
2. Surface 1: client-side key handling
Two paths: the wallet path (stellar-wallets-kit, primary) and the secret-key advanced mode
(apps/web/lib/stellar/signer.ts), for keys not held in any wallet.
Wallet-path signing carries a narrower version of the same threats: the key never enters the application at
all, so Information disclosure and Tampering against in-memory key material do not apply - the residual
threats are wallet-extension compromise and CSP bypass, both outside this surface’s boundary. The wallet’s own
state is checked rather than trusted: a restored session is shown as connected only after a silent address lookup
matches (
apps/web/hooks/useWalletKitConnection.ts), a wallet that cannot report its network has to be confirmed
by the user, and WalletKitSigner refuses a signature the wallet reports making with another account, or one that
verifies only for the other network, before it is used. The session is read again right before each signature of a
run (beforeSigning), so a wallet that went stale or changed network since the run started is not asked to sign.
These are pre-checks; the approved-hash, own-signature and weight checks
in useCloseExecution stay the authority.
A Ledger signs through the kit’s Ledger module over WebUSB, which the Permissions-Policy opens to this origin
on the network routes and /cosign only (apps/web/config/security-headers.mjs; the built output is checked by
scripts/marketing-csp.mjs check-output). The module signs the exact envelope it is handed, after verify(),
either in full (nonBlindTx, the device shows every operation) or by its hash. A blind hash signature is the
residual Tampering risk on this path: the device shows only 64 hex characters. WalletKitSigner asks for a
full display whenever the signature base fits the smallest Stellar app buffer (4 KiB), and signs by hash only on
a screen that shows the hash’s first and last eight characters beside the prompt with an instruction to compare
them on the device (the close flow’s pre-sign panel and the co-signing station), and only on an attempt the user
starts. Revoking an allowance shows no hash, so it is never signed by hash. The kit signs at the derivation path
it stored for the account, without reading the key back; a device holding another seed is caught inside the kit
when the signature does not verify for the account, and in the close flow by the own-signature check as well
(apps/web/tests/unit/ledger-signing.test.ts).
3. Surface 2: the client-side session layer
apps/web/store/demolish.ts (the DemolishPhase state machine), apps/web/lib/session/store.ts (the
IndexedDB-backed session store, via idb) and apps/web/lib/session/decision-snapshot.ts (the tab’s saved
inputs, in sessionStorage), plus verify() (apps/web/lib/stellar/verify.ts) as the trust
anchor gating every signature this layer eventually authorizes.
4. Surface 3: API transaction construction
The API’s transaction-builder module (apps/api) is a pure module by design invariant - state in, unsigned
envelopes out, no network side effects (CLAUDE.md, “Hard invariants”) - which is what makes it possible for
verify() to treat its output as untrusted input rather than a peer.
5. Surface 4a: backend signing key (mediator co-sign)
apps/api/src/mediator/mediator.controller.ts, mediator-signing.service.ts and mediator-validation.ts. The
mediator is one of the two signing keys the API holds (the other is the fee-bump sponsor, Section 6); it co-signs only the forwarding payment of the exchange-mediator flow
(Section 11).
S4a.Elevation.1: the mediator forward window
Statement. The forward bound is checked against the merged account’s balance read at co-sign time, but what the merge delivers is decided at submit time, so an adversary who controls the merged account can drain it in between and the co-signed forward then pays out of the mediator’s own balance. The identifier is the one the monitoring plan already uses for this threat, and Section 11 refers to it by the same name. The drain can be an operation sourced from the merged account inside a transaction whose source is another account, which leaves the co-signed transaction’s sequence number valid. When the co-signed transaction is then submitted,op0 (the merge) delivers close to nothing while op1 (the
forward) still pays the amount that was valid at co-sign time.
No code-level control closes the window today. The checks in code raise the bar for the active case and the time bound caps how long it stays open, and on
mainnet the funding policy is what will bound it. On testnet the mediator holds friendbot XLM, which has no
value, so the window is accepted there as is. The balance-floor monitor compares against the base reserve
(1 XLM), so on an account funded above that floor it fires only once a drain takes the balance below it; the
forward check is the one that fires on the first over-forward. Mainnet acceptance depends on the funding policy
being in place before the mainnet mediator is deployed. The risk is carried into Section 11 on those terms.
Integrator responsibility for a mediated close
The co-sign endpoint enforces the structure of the mediated pair, not its destination. It refuses a forward to the mediator itself and caps the forward amount at the merged balance read at co-sign time, but it accepts any other destination: it cannot know which exchange address the user meant. It does hold the forward to the destination’s memo rule: a listed exchange that requires a memo needs one, any memo to a listed exchange must be of the registry’s type, and an unlisted account whoseconfig.memo_required data entry is set (SEP-29) needs a
text or id memo. A destination whose data entry cannot be read is refused. It cannot know which memo value the
user meant.
In the LumenWipe web client, verify() holds that check, with the destination the user typed. An integrator
calling the API or the SDK directly has no such check unless it writes one, so before signing a mediated close it
must confirm, from its own inputs and never from the API response:
- The destination the user entered needs the mediator (a known exchange that cannot receive a merge). Otherwise the merge must go straight to the user’s address, and the mediated shape is refused, so an intermediary the API names cannot be slipped into a close to a plain wallet. The converse holds too: a merge straight into a destination that needs the mediator is refused, because the exchange cannot credit it. Both are decided from the integrator’s own copy of the registry, never from the API response.
- The transaction source is the account being closed, and the transaction has exactly two operations: an
accountMergefollowed by apayment. - The merge is sourced from the account being closed (explicitly, or by inheriting the transaction source).
- The payment is sourced from the merge’s destination, the account the merge pays into.
- The payment’s destination is the exchange address the user entered.
- The payment’s asset is native XLM.
- The payment’s amount is at least the native balance the integrator observed for the account, less a small fee tolerance (the web client allows 0.01 XLM).
- The memo, and its type, match what the user confirmed: the bundled registry’s type for an exchange it lists, the user’s choice for any other destination. A close with no memo carries none, and no other transaction of the close carries a memo.
assertCloseIntent in
apps/web/lib/stellar/verify.ts.
@lumenwipe/verify (packages/verify) packages that same code for integrators, with a shared conformance vector
set. It decides whether the mediated shape is allowed (step 1) from the exchange registry bundled in its release
and from a served registry whose signature verifies against the registry keys pinned in that release (see
the signed registry). An integrator may pass the served registry as
servedRegistry; it is merged stricter-only, as in the web client, so it can refuse a direct merge into an address
it lists as needing the mediator, require a memo (step 8), and move the registry’s validity later by at most 120
days. Without a signature that verifies, it never enables the mediated shape: the API that serves it also builds the
transaction and reports the balance step 7 is checked against. It never sets a memo type either: a type that differs
from the bundled one, or from the one the user confirmed for an address only the snapshot lists, refuses the close.
Without one, an exchange listed after that release is checked as a plain wallet until the integrator upgrades, or
until a signed registry lists it.
The signed exchange registry
The API serves the exchange registry with a detached Ed25519 signature made by a maintainer key held offline, never on the API host. The web and@lumenwipe/verify verify it against two public keys pinned in their releases
(apps/web/lib/exchange-registry/trust-roots.ts, listed in the security scope).
A client believes a signature only when a pinned key verifies it, its sequence is at least the sequence of the
registry bundled in the client, its validUntil has not passed and its issuedAt is no more than a day ahead of the
client’s clock. Anything else, including a missing, truncated or forged signature, leaves the registry exactly as
unauthenticated as before: it can only make the client stricter.
What a signature does not do. It gates the mediated shape for an address. It does not vouch for the account a
mediated close merges into: that account is named by the transaction the API builds, and the structural checks above
(the forward from the account the merge pays into, for at least the balance read, to the address the user typed) are
what bound it. A signed registry also cannot retract an address; removing one needs a release.
6. Surface 4b: backend signing key (fee-bump sponsor)
Status: implemented (#164, epic #159). This surface is specified in Section 8.1 of the architecture doc and built inapps/api/src/fee-bump/ (fee-bump.controller.ts,
fee-bump-validation.ts) and apps/api/src/lib/stellar/fee-account.ts. Every row below has been
re-verified against the running code, with test coverage listed in Section 12; two mitigations this
table originally described - the account/IP dimension of rate limiting and the fee account’s
spend cap with alerting - turned out to be operational controls this PR does not implement in
code, and are carried instead as residual risks in Section 11, the same way the mediator’s own
funding discipline is. The spend cap now exists in code as a daily sponsorship budget per source account, per API key
and in total; balance alerting remains operational.
7. Surface 5: allowance revocation
Status: implemented (#162/#163, epic #159). Entirely independent of the account-close flow -apps/web/lib/stellar/verify-revoke-allowance.ts is its own standalone trust anchor, not a branch
of assertCloseIntent, gating the one-operation approve(owner, spender, 0, expiration_ledger)
transaction that apps/api/src/lib/stellar/revoke-allowance.ts builds to zero a live SEP-41
allowance discovered by apps/api/src/lib/stellar/allowances.ts.
Even a wrong or hostile
{token, spender} pair from the discovery endpoint (an out-of-scope, read-only
source per Section 1) bounds its own damage structurally: approve(owner, spender, 0, _) can only ever
zero out one specific allowance - it has no path to move the account’s actual balance, unlike a
diverted destination or amount would.
8. Surface 6: Soroban token conversion via Soroswap
Status: implemented (#161, epic #159).apps/web/lib/stellar/verify.ts’s invoke_host_function
branch for a contract in expected.conversionContracts (the bundled registry’s Soroswap aggregator
and router, never the API), fed by apps/api/src/lib/soroswap/conversion-quotes.ts on the build side.
Documented residual, not a gap: unlike the DeFi-exit branch (Section 9), this branch’s own source
comment states plainly that the authorization tree’s sub-invocations - the actual DEX route the
aggregator picks - are not pinned client-side at all: “the browser has no way to enumerate them
[the pools a route passes through]… the API pins them.” This is a deliberate, already-documented
trust boundary (
docs/architecture.md §10.1), not an oversight comparable to #208 - the floor above
(minAmountOut) is what bounds the damage a route the client cannot enumerate could otherwise do.
Carried forward as a residual risk in Section 11.
Flagged conversions (#450). A token quote whose price impact is above 5%, whose impact could not be
measured, or that is more than 10% above the other provider’s, is offered but never recommended and is
never the default (deriveTokenDecisionPoints, quoteFlags). Converting it needs the
conversion_impact:<contract> confirmation, which counts only when it names the same floor as the convert
answer (isConversionImpactAcknowledged); until then the plan carries the
conversion_impact_not_acknowledged blocker (conversionImpactBlockers). Documented residual, not a
gap: the confirmation is a plan and interface gate, not a build gate. close/transactions does not
re-check it, and the pinned floor the checkbox names is what bounds the swap (quote_drifted, INV-36). An
impact derived from a small probe can read low when a fixed fee or rounding takes more of the probe than of
the full trade; a probe delivering under 10,000 stroops reads as unmeasured and is flagged.
9. Surface 7: DeFi exit adapters (Blend, Aquarius, Soroswap, Phoenix, FxDAO) and xBull conversion quotes
Status: implemented (epic #151).apps/web/lib/stellar/verify.ts’s DeFi-exit branch, fed by
apps/web/lib/stellar/exit-expectations.ts (which builds exitContracts/heldTokenContracts/
positionTokenContracts/exitFunctions from the account read the user reviewed, never from the
transaction under verification, and refuses an exit outright when that read names XLM, a held
classic asset, or a listed Soroban balance as a position’s own share token, or XLM or a held
classic asset as its debt token), backed on the API side by the versioned wasmHash contract registry
(apps/api/src/lib/contract-registry/index.ts) and the exit adapters themselves
(apps/api/src/lib/defi-exits/{blend,aquarius,soroswap,phoenix,fxdao}.ts). The xBull conversion quote
source sits on the same surface: its quotes and swap build live in apps/api/src/lib/xbull/conversion-quotes.ts
and apps/api/src/lib/close-api/xbull-conversion-round.ts, and its router is pinned by the same verify().
Documented residual, not a gap: the exact amount an exit moves, and the protocol-level meaning of
the call beyond function/recipient shape, are not checked client-side - the browser cannot re-simulate
a DeFi protocol’s internal accounting. Issue #208’s own proposal explicitly scoped this out (“keep the
amount unconstrained - the pool decides it”). Carried forward as a residual risk in Section 11.
The table above holds for every adapter. Phoenix, FxDAO and xBull each add a contract, a call or an outside
service the shared rows do not describe, so each gets its own pass below. Every adapter runs through the same
gate in
runExitAdapter (apps/api/src/lib/defi-exits/run-exit.ts) before anything is built:
- The registry must be inside its validity window.
- The position’s contract must have a live code hash that the registry knows for this network and protocol,
checked before any of its state is decoded (
exit_unknown_contract_version,exit_contract_protocol_mismatch). - Each planned step’s amount is held to the balance read just now (plus a bounded margin for a step whose contract clamps the amount itself), with a positive floor where one applies.
- Every other contract a planned step calls must pass the same registry check as item 2. This happens after planning and before anything is built, so the adapter may already have read that contract’s state; nothing is built against it unless it passes.
- The first step is simulated before it is offered.
apps/api/tests/unit/exit-adapter-harness.test.ts.
A position whose exit cannot be built refuses the merge, and the plan names it with its value (or “value
unknown”). This covers code the registry does not know, a pool or position the adapter does not support, a
failing or overpriced simulation (an exit that cannot also restore its archived data is one of these), a call
that needs another account’s signature, an adapter that cannot handle the position and a position too small to
withdraw. The plan runs the same checks as the
exit round before the user decides. If that check cannot run, or the state changes in between, the exit round
still refuses the build and the user analyzes again to see the choice. The user can close the position in its protocol and analyze again, or choose to leave
that one position behind. The choice names both the account and the position’s contract, the plan records it
as a warning, and the exit round honours it only while the exit still cannot be built for one of those
reasons: an exit that builds is run, and a failed read, an expired registry, an unsafe position or a
blocker the user can fix is never offered for leaving. One choice covers every position the account holds in that
contract, and the plan shows how many there are. A position left behind stays
with the address after the merge (apps/api/src/lib/defi-exits/exit-round.ts,
apps/api/tests/unit/leave-unexitable-positions.test.ts).
9.1 Phoenix
apps/api/src/lib/defi-exits/phoenix.ts. A Phoenix LP position leaves the pool through
withdraw_liquidity; a staked position first goes through unbond on the pool’s stake contract, a separate
contract per pool.
9.2 FxDAO
apps/api/src/lib/defi-exits/fxdao.ts. Closing an FxDAO vault means repaying its whole stablecoin debt with
pay_debt; the vault deletes itself and returns the collateral when the debt reaches zero.
The
verify() cases for Phoenix and FxDAO run on synthetic envelopes, and captured testnet exit envelopes for both
also run through verifyCloseTransaction (apps/web/tests/unit/fixtures/real-exit-envelopes.ts).
9.3 xBull conversion quotes
apps/api/src/lib/xbull/conversion-quotes.ts and apps/api/src/lib/close-api/xbull-conversion-round.ts. A
second conversion route raced alongside Soroswap, off unless XBULL_CONVERSION_ENABLED=true, mainnet only. It
is not an exit; it sits on this surface because its router is pinned by the same registry and verify().
Documented residual, not a gap, for xBull: the browser reads the token an xBull route spends and the
token it buys from the route’s own index tuples, through a bundled copy of the router’s asset table
(
apps/web/config/xbull-asset-map.json, read from the live router and re-read when xBull adds assets). It
cannot enumerate the pools in between; the floor on the XLM received bounds the damage. See Section 11.
10. Surface 8: the integrator access layer
Status: implemented. Self-serve API keys for integrators, managed by signing in with a Stellar wallet:apps/api/src/integrator/ (wallet-auth.ts for the challenge and the session token, integrator.guard.ts,
integrator.controller.ts), the key store and its cache in apps/api/src/auth/ (api-key-store.ts,
api-key-directory.ts, rate-limiter.ts), the lifecycle log in apps/api/src/common/audit-logger.ts, and on
the web the key panel (apps/web/components/api-keys/ApiKeysPanel.tsx) with its proxy
(apps/web/lib/integrator/relay.ts) and session cookie (apps/web/lib/integrator/session-cookie.ts). Nothing here signs a transaction or touches funds: an API key reaches the
same read and build endpoints the web’s own key does, and every transaction they return still has to pass the
integrator’s own verification (Section 5, “Integrator responsibility for a mediated close”, and the
SDK verification page).
The flow: the wallet asks for a challenge, signs it as a SEP-53 message, and exchanges the signature for a
session token, which then lists, creates, rotates and revokes the API keys that wallet owns. The Google,
GitHub and email sign-in on the key page (Pollar) ends in the same challenge: LumenWipe receives only the
account’s address and its signature, never the Google, GitHub or email identity behind it. A contract account
(C...) signs a SEP-45 style authorization instead (apps/api/src/integrator/contract-auth.ts, described in
the architecture), through a wallet, Pollar or by hand on the key page, and
gets the same session.
The client IP is the last
X-Forwarded-For entry (TRUSTED_PROXY_HOPS in configure-app.ts): Cloud Run’s front
end keeps whatever the caller sent and appends the address it accepted the connection from, so earlier entries are
the caller’s own claim. One hop holds while the service is reached only through Cloud Run’s front end (its
run.app URL or a domain mapping); putting a load balancer in front adds a second entry and needs the setting
raised to match.
These limits are carried into Section 11:
- The session is stateless, so it cannot be ended before its 30 minutes run out. It needs the wallet’s own signature in the first place, and each signed challenge yields one session at most.
- Signing out on lumenwipe.com clears the session cookie in that browser only. The token is stateless, so a copy taken before sign-out (by script that ran in the origin before the cookie existed, or from the API’s own logs) stays valid upstream until its 30 minutes run out; the web cannot revoke it. The web checks only the token’s shape and expiry, never its MAC, so a forged cookie shows a signed-in page whose every keys call the API refuses with 401.
- The key cache is per instance. Another API instance can keep serving a revoked key from its cache for up to
60 seconds (
api-key-directory.ts), a deliberate trade against a store read on every request. - A contract account’s session rests on the RPC providers’ simulation. One provider that lies can only withhold a session, since every provider must agree, but providers that all lie together can grant one for any contract account; they are the providers every account read already trusts. After a testnet reset, whoever controls a testnet contract’s deployer and salt can redeploy it at the same address and manage the keys it owned.
11. Known residual risks (summary)
The first two risks are already narrated in
docs/architecture.md. Most of the rest follow the same
“operational discipline” or “documented, bounded trust” pattern the earlier rows establish. The integrator rows
are of a different kind: they bound access to API keys and the API’s capacity, not a user’s funds, and the rate
limiter row is open rather than accepted. Restating them here is the point of formalizing the threat model - they are now indexed by surface
and category instead of embedded in prose, and this is the table #171’s tooling remediation plan cross-checks
its own findings against.
12. Coverage cross-reference
What already holds under automated test as of 2026-10-13, not just what is designed:13. Maintenance
This document goes stale the same waydocs/architecture.md’s trust boundary does: a new close operation,
a new signing key, or a new adapter needs a STRIDE entry added here in the same pull request that introduces
it, not as a follow-up. In particular:
- A new operation shape added to the builder and to
verify()’s allowlist (CLAUDE.md, “Consequence for any new close operation”) gets a row in Section 4’s Elevation of privilege threat. - A new server-side signing key gets its own subsection under Section 5/6’s pattern before it ships, the same way this document covers the fee-bump sponsor ahead of its implementation.
- A new DeFi protocol adapter that introduces its own invariants (
docs/architecture.md§9.9) is covered by those invariants directly. It needs its own pass under Section 9 when it adds a contract, a call or an outside service that Section 9’s shared rows do not describe, as Phoenix, FxDAO and xBull do. - A new way to authenticate to the API, or to issue or revoke its keys, gets a row in Section 10.
apps/web/hooks/useCloseExecution.ts requests sponsorship and
re-verifies the result the same way it re-verifies the mediator’s co-sign (Section 5) - and Section 12’s
coverage row now lists the client-side test files this added.
Sections 7-9 (allowance revocation, Soroban token conversion, DeFi exit adapters) were added after this rule
was already being violated: epics #151 and #159 shipped their PRs (#212-#220) without the STRIDE entries this
section calls for, so this document briefly did not cover three real, already-signing surfaces. Section 9 in
particular was written only once issue #208 - a real gap in the DeFi-exit surface it now describes - was found
and fixed, rather than ahead of the surface’s implementation the way this section asks for. Recorded here
plainly rather than silently backfilled, since a maintenance section that hides its own past lapses is worse
than one that names them.
The same lapse happened again. Phoenix, FxDAO, xBull routing and self-serve API keys shipped after the last pass
without entries of their own; Sections 9.1 to 9.3 and Section 10 were added on 2026-10-13 to cover them.