Rehearsed end to end for testnet on the deployed service on 2026-11-17, together with the fee
sponsor rotation, with step 10 on 2026-11-18; the measured
times are from that rehearsal. Not yet rehearsed on mainnet.
apps/api/tests/integration/relay-rotation.integration.test.ts runs the same sequence against a
local API on every pull request.When
- Compromise: the key may be exposed, or
S4a.Information.1.M.1,S4a.Spoofing.1.M.1or the forward check fired. Do step 1, then the rest without pausing. - Planned: a scheduled rotation, a maintainer leaving. Skip step 1.
Blast radius
- Only exchange closes. Closes into a wallet the user controls never touch the relay account.
- A close built against the old account but not yet co-signed is refused once the new revision serves, with
400 transaction_structure_not_allowed, because its forward names the old account. Nothing has been submitted, so the client builds it again and gets the new account. - A close co-signed before the switch still lands while the old account exists, which is why step 8 waits before the drain. One submitted after the drain fails as a whole (
op_no_accounton the merge,op_no_source_accounton the forward): no XLM moves, the account pays one fee and stays open, and building again succeeds. - On mainnet, at most the old account’s minimum balance, 1 XLM, is ever at risk, because it holds nothing else. A testnet account created through friendbot holds far more: the testnet accounts retired on 2026-11-17 held about 10,000 XLM each, which the drain in step 9 returned to the operator.
Steps
<net> is testnet or mainnet and <NET> the same in capitals. Run every step in one shell, started like this, so a failed command in a pipe stops the step and the keys live only in a throwaway CLI configuration:
gh run list --workflow deploy-api.yml --status in_progress) before each gcloud run services update.
operator is the operator account that funds the new relay account and receives the old one’s balance; paste its secret at the prompt. It must not be either relay account, and it must be the address in the Rotation operator (<net>) row of the inventory table and the OPERATOR_ADDRESS_<NET> repository variable: the forward check recognises the drain in step 9 only as a merge into that address.
-
Compromise only: pause exchange closes.
Expected:
Done., andPOST $API/v1/<net>/mediator/signanswers503 exchange_forward_paused. -
Generate the new key, without showing it:
Expected: a
G...address. This is<new>below;<old>is the address in theMEDIATOR_ADDRESS_<NET>repository variable. -
Create the account at its minimum balance only, 1 XLM (two base reserves), from the operator account. Never fund it through friendbot or with more: a relay account holds no spendable XLM (threat model, surface 4a).
Expected:
1.0000000(usehttps://horizon.stellar.orgon mainnet). -
Check the bindings, pin them, then add the secret as a new version. An entry with
valueFrom.secretKeyRefcomes from Secret Manager. If the relay secret is bound tolatest, a new version would reach a fresh instance of the current revision before the public key changes, and that instance would answer503 mediator_key_misconfiguration: pin the current version number first. On the production service both the relay and the sponsor secret were bound tolatestat the 2026-11-17 rehearsal, so expect to pin. When the fee sponsor rotation runs in the same session, pin both secrets in one revision (23 seconds on 2026-11-17):Drop theFEE_ACCOUNT_SECRET_<NET>binding from the update when only the relay rotates, and skip the update when the binding already names a version. Expected: the binding names a version number, andCreated version [<n>] of the secret [<relay-secret>].Thetrmatters: a trailing newline makes the key unreadable. Withpipefailset, a failedkeys secretstops here instead of storing an empty version. -
Switch the API in one revision. The secret and the public key must change together; a revision where they disagree answers
503 mediator_key_misconfiguration.IfMEDIATOR_PUBLIC_<NET>is bound to a secret as well, add its version as in step 4 and bind it in the same--update-secretsinstead. Expected:Done.and the new revision serving 100 percent; adescribenow shows version<n>and<new>. Note the time: step 8 counts from it. Thencurl -s "https://api.lumenwipe.com/v1/<net>/mediator/check/<an exchange address>" -H "Authorization: Bearer $KEY" | jq .availablemust printtrue;falsemeans the secret andMEDIATOR_PUBLIC_<NET>disagree or one is unset, and for a mismatch the API logsthe mediator key does not match its configured public key. -
Confirm the new account co-signs. On testnet, run the full exchange flow through the deployed web app:
Expected: it ends with
E2E PASS, and its forward shows on Horizon as a payment from<new>. On mainnet there is no scripted check, because it would close a real account: confirm instead with the first real exchange close, whose forward must be a payment from<new>. In a compromise, turnMEDIATOR_FORWARD_ENABLEDback totrueonce this passes. -
Point the monitors at the new account and keep the old one watched, before the drain, so the new account is watched from now on and no check reads a drained current address. Edit the repository variables and, in the same hour, merge a pull request that changes the
Mediator account (<net>)row of the inventory table to<new>(on mainnet, alsoACCOUNTSinapps/web/public/.well-known/stellar.toml). The config step fails until the variable and the table agree. Two more places hold the address:apps/api/tests/unit/service-account-monitors.test.tspins the current testnet addresses asMEDIATORandSPONSOR; change them in the same pull request. That makes the pull request deploy the API, so merge it only once the last env-only revision of the rotation serves.- On testnet, the playground’s Vercel variable
PLAYGROUND_EXPECTED_MEDIATOR_TESTNET(andPLAYGROUND_EXPECTED_FEE_ACCOUNT_TESTNETfor the sponsor). After changing it, deploy the playground withvercel deploy --prodfrom a clean checkout ofmainlinked to the playground project: a plainvercel redeployis cancelled by the playground’s ignored build step when no playground file changed.
Expected: every job succeeds, and the config step lists bothmediator (<net>): <new>andmediator (retired) (<net>): <old>, drained into <operator address>. Check for the retired line: a misspelled variable name is never passed to the workflow and would leave the old address unwatched without an error. -
Wait 6 minutes from the switch in step 5. A signed close is valid for at most 330 seconds (
MAX_SIGNED_VALIDITY_SECONDS), so after this no close co-signed by the old key can still land. -
Drain the old account. The operator is the transaction source and the old key signs only the merge, so the old address never sources a transaction and its keys check stays quiet. The old key is piped from its previous secret version into the throwaway configuration, never shown:
Expected:
stellar tx sendexits with status 0 and prints the transaction result, and Horizon answers404for<old>. The next monitor run stays green: the keys check sees no transaction sourced from<old>, and the forward check reads this merge into the operator as the drain. For the rest of the 24 hours, any other transaction the old key signs, or any merge or payment out of<old>to another address, is reported as a suspected key compromise. Thebump-sequenceto 0 is a no-op that lets the operator be the source; the fee covers its two operations. In a compromise, whoever holds the old key can make the merge fail first (op_has_sub_entries, by adding a trustline or a signer): the most that costs is the old account’s 1 XLM, and the keys check reports the transaction that did it, whoever sourced it. -
After 24 hours, stop watching the old account and clean up:
Use the address of an exchange that requires the relay. Expected:
200andtrue, since the service binds version<n>, not the disabled one;falsemeans the key the API holds does not matchMEDIATOR_PUBLIC_<NET>. The next monitor run lists only<new>. The new key now lives only in Secret Manager; keep a copy where the team keeps keys before removing the throwaway configuration, if the team’s policy asks for one.
Measured times
From the testnet rehearsal on the production service, run together with the fee sponsor rotation:Confirm the fix
test:mediatorpasses against the new account (step 6) and Horizon shows<old>as404(step 9).- The on-chain monitors run green with the new address, and with the retired one for 24 hours (step 7).
- To roll back before step 9, bind the previous secret version and the old public key in one
gcloud run services update, as in step 5. After step 9 the old account is gone; rotate forward instead.