Security
What Resolution protects, how, and what it leaves to you.
Real money
A fund starts on paper. It trades real money only after the owner signs it over to an Interactive Brokers account, and only through IBKR's Client Portal Gateway, which the owner runs and logs in to.
- No broker password. Resolution never asks for, stores or sends an IBKR username or password. The gateway holds the session; Resolution talks to the gateway's local API. If a broker credential turns up in the environment or the data directory, remove it.
- The gateway's certificate. The gateway ships a self-signed certificate. Resolution accepts it
only by the SHA-256 fingerprint the owner trusted once in the connection wizard
(
IBKR_GATEWAY_CERT_SHA256), on any address. The fingerprint is checked after the TLS handshake and before any byte of a request is written, so a different certificate means nothing is sent, orders included; the owner is notified. Without a trusted fingerprint the certificate must verify against the system's certificate authorities, which a self-signed one never does. A trusted fingerprint with a plainhttp:address is refused. The gateway's stock keystore is public; see operating for what the pin proves and what it does not. - Going live is a signature over the terms. The owner signs
live:<account>:<terms hash>in the browser. The terms are the account, the fund's cash, what the account already held, the live order cap, the price collar, and the IBKR contract id for every instrument. A contract outside that list is never traded. Changing any term means going back to paper and signing again. - Preconditions. The server refuses to go live for the demo fund, with the kill switch engaged, with any paper position or working order, without a logged-in session, or when IBKR reports less available cash than the fund's own cash.
- Every order is still signed. The approval digest names the venue, the account and the contract.
An approval signed for paper cannot be sent live, and one signed for live cannot fall back to paper:
a fund that is live but whose process lacks
BROKER=ibkrsends nothing. - The broker's preview is bound to the signature. Live, IBKR's what-if is in the digest. When the owner signs, it is taken again; a commission that moved by more than max(EUR 1, 20%), a new currency, or a new warning or error refuses the signature and issues the approval again for a new one. The venue repeats the check before sending.
- A currency conversion is signed, and the fund never borrows a currency. A conversion is its own ticket, signed like an order; a rate that moved more than 0.5% since it was shown refuses the signature. Once the fund holds cash in another currency, and always live, a buy is signed only if the cash it is paid from covers it, net of orders already signed. Live conversions are refused (decision 0018).
- Checks before an order leaves. The kernel's HARD rules refuse a live order priced from
simulated or fallback data (
L-LIVE-PRICE), and any risk-adding order above the live order cap (L-LIVE-SIZE). The venue then refuses a limit more than the collar from IBKR's own price. That also catches a pence-for-pounds error. It refuses a buy that IBKR's available funds do not cover, so nothing is bought on margin, and a sell of more shares than the account holds. - Exactly once. Each order carries a client order id derived from the proposal. After a crash the gateway finds the order at IBKR by that id instead of sending it again, and an approval that has expired is closed, never sent late.
- Reconciliation. Every five minutes the fund's positions are compared with IBKR's, less what the account held at go-live. Two breaks in a row raise a halt on all trading that only the owner clears.
- Loosening waits. Raising the live order cap or widening the collar is a loosening, and waits out the mandate's cooling period like any other.
- Back to paper is allowed only from a flat book, so no real position is left without an owner.
This has been tested against a simulated gateway (test/helpers/fake-ibkr.ts), not yet against IBKR.
Rehearse with an IBKR paper-trading login before you sign a real account.
Model keys
A provider key comes from the server's environment, or is pasted in Settings → Model.
- Tested, then saved to a file. A pasted key is tried with one short call and saved only if it
works, to
model-key.jsonin the data directory with mode 0600. A key for a provider used only by the roster goes tomodel-key.<provider>.json, also 0600. The environment outranks both, and while a key comes from the environment the browser cannot replace it (409). - Never in the Record. No key is written to an event, a blob, a log line or a backup's event stream. Seat calls are audited: each prompt and response is stored in the blob store, and every key-shaped secret the process can see is scrubbed from both first. A failed call's error is scrubbed the same way.
- Never sent to the browser.
GET /api/model,GET /api/providersandGET /api/rosterreturn the provider, the model and whether a key is set, never the key. - In memory, nothing is saved. A server whose store is in memory refuses to save a key or a roster.
- Local providers (Ollama, LM Studio) take no key; the host variable is an address.
The files live in the data directory, and so do the backups. A backup holds the Record, not the key files; anyone who restores a backup elsewhere has to supply their own keys.
The seat roster
The roster says which provider and model each seat runs on. It is recorded as roster.set and may not
hold keys: the server refuses a roster with a key in it. Keys given alongside a roster are written to the
per-provider files above. SEAT_ROSTER in the environment outranks the saved roster, and while it is set
the browser cannot change it.
Who can reach it
- Loopback by default. The server listens on
127.0.0.1. Other host names are opt-in throughALLOWED_HOSTS, meant for a tunnel with its own access control. - Host check. A request whose
Hostheader is not loopback or listed inALLOWED_HOSTSgets 421. This blocks DNS rebinding, where a web page points its own domain at your machine. - The token. A random token is generated into
.tokenin the data directory, mode 0600, or fixed withRESOLUTION_TOKEN. Every route but/healthzneeds it, either as theresolution_tcookie or asAuthorization: Bearer <token>. The?t=link sets the cookie (HttpOnly, SameSite=Strict) and the token leaves the address bar. To rotate it, see operating it. - The password. Optional, set under Settings → Password or with
npm run password -- --set. A browser that presents it atPOST /logingets the same cookie as the link and nothing more: it proves that the browser was given the secret, and it is not a second factor (passkeys are, below). Only a scrypt hash is kept, inowner-password.jsonbeside the data with mode 0600 (src/server/password.ts); the server never logs or returns the password, and changing or removing it needs the current one. Guessing is slowed: five wrong passwords in fifteen minutes, per client and across all clients, and the wait doubles with every further one up to an hour (429withretry_after). Forgotten:resolution password --reseton the box, ornpm run password -- --reseton the server, removes it; the link keeps working throughout. - Online.
resolution onlineopens the app to the internet through Tailscale Funnel. Tailscale terminates TLS with a public certificate and forwards to the app on loopback, so what is exposed is the app on port 8443 and, when it is on, the tour on port 10000, and nothing else: not the gateway's login page, not the database, not any other loopback port. The doors are the same two, the link and the password. Behind the proxy the guess throttle keys on the client's forwarded address, the last one inx-forwarded-for(the proxy appends it; anything before it is what the client claimed), and keeps the count across all clients. Over https the server sendsstrict-transport-securityon every answer and marks the session cookieSecure, so a browser never sends it over plain http; on127.0.0.1nothing changes. Enrol a passkey before approving orders from the open internet: the password proves only that a browser was given the secret. The tour holds no secret beyond the read-only shared password hash. - Writes need a header. Every request other than GET and HEAD needs
x-resolution: 1; without it the server answers 403 "Writes need the x-resolution header." A browser cannot add a custom header to a cross-site form or a simple request, and a cross-site request that tries needs a CORS preflight the server never grants, so another site cannot make your browser write to the fund. The web app and the command-line tools add the header themselves.
What the browser loads
The web app is served by the process itself. Preact and htm are vendored, fonts are system fonts, and nothing loads from a third party. The Content Security Policy says so:
default-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none';
form-action 'self'; object-src 'none'
The fund cannot be framed by another site, and a script injected into a page could not send data anywhere but back to the server.
The service worker (web/sw.js) stores the app's files and a short whitelist of read-only answers (the state
snapshot, events, analytics, universe, wire, claims, verification) in the browser's cache, so the desk can open
offline. That copy is fund data on the device: anyone who can use this browser profile can read it, as they could
read the page itself. It holds no token, no key and no secret, and never a proposal, an approval or a verdict. It is
emptied when the server answers 401. Signing, checks and every other decision are network only. See
the guide.
Signing
An approval is a signature over the kernel's canonical digest, made in your browser with a WebCrypto ECDSA P-256 key. The private key never leaves the browser; the server holds public keys only. At submission the gateway re-derives the digest, checks the signature against a registered key, checks the approval has not expired, and re-runs the kernel. Any difference is refused and the refusal recorded. Nothing on the server can forge an approval.
The same browser key signs the other acts that bypass or change the book:
- Overrides. Only
L-PROC-COOLINGandL-RUNGcan be overridden; risk limits and floors never can. An override is a signature overoverride:<rule>:<instrument>:<expires_at>:<sha256(reason)>, so the written reason is bound to it. It expires, 7 days by default and 30 at most, and each proposal it lets through is recorded asoverride.used. The server first returns the exact terms to sign; it stores only what verifies against a registered key. - Corporate actions. Recording one changes nothing. Applying it needs a signature over
corpaction:<id>:<instrument>:<kind>:<ratio>:<new symbol>. - Mandate rows and going live, as before.
The demo is the one exception. It holds a server-side key so the demo can be approved without setup. That key exists only in demo mode, and every event and screen it touches says demo key.
Passkeys: the second factor
The owner token proves that a browser was given the link. The signing key proves that the approval came from that browser. Neither proves that you are at the device now. A passkey (WebAuthn) adds that proof. Enrol one under Settings → Passkeys. Once at least one passkey is enrolled:
- Approving an order needs a passkey assertion as well as the browser signature. The server issues the
challenge for
sign:<proposal id>:<digest hash>, so an assertion made for one order cannot approve another. - Going live needs one bound to
live:<terms hash>. - Enrolling another passkey needs an existing one, and removing one needs an assertion bound to that removal.
- Rejecting an order, going back to paper and the kill switch never ask for it. Stepping back is never made harder.
The server verifies everything itself with node:crypto (src/server/passkey.ts):
- Client data.
clientDataJSONmust carry the right type, the challenge and the page's origin. - Challenges. Each is single use and expires after five minutes.
- Authenticator data. It must carry the SHA-256 of the relying-party id, which is the host without its port, and the flags UP (user present) and UV (user verified). UV means a fingerprint, face or PIN; a bare touch is not enough.
- Keys. Only ES256 (P-256) and RS256 keys are accepted.
- The signature counter. It must grow. A counter that goes back suggests a copied authenticator, and the assertion is refused.
Attestation is none. The server does not check which maker built the authenticator, only that the same
key answers each time.
Passkeys are stored beside the Record in the table owner_passkeys. The table holds the public key and
the counter, never anything secret. Browsers accept passkeys only over https or on localhost, never on
an IP address such as 127.0.0.1. Settings says so when the page comes from a host that cannot use them.
Recovery. If you lose every passkey, run this on the machine that holds the data:
npm run passkeys -- --reset # [--data ./data]; without --reset it lists them
If the server is running, the command writes a single-use random nonce to <data>/.passkey-reset
(mode 0600) and sends it to the server with the owner token. The server checks the nonce, deletes the
file and revokes every passkey. If the server is not running, the command revokes them in the store
directly. The owner token alone cannot remove the second factor: a stolen browser cookie is exactly
what a passkey guards against, so recovery needs a shell on the machine. Approving then needs only the
browser key again until you enrol a new passkey.
The record
- Append-only in the database. Triggers refuse UPDATE and DELETE on the event table, so the application itself cannot rewrite history.
- Hash-chained. Every event carries the hash of the one before it. Verify the chain on the
Record screen, or
GET /api/verify, recomputes it and names the first broken link. - Replayable.
npm run replayrebuilds the fund from the record and compares it with the live state. - Anchored. Every
ANCHOR_EVERY_MINminutes, when the head has moved, the server signs{seq, head_hash, at}with an ed25519 key it keeps inanchor.key(mode 0600; the public half inanchor.pub), writes it toanchors/, recordsanchor.written, and POSTs it toANCHOR_URLif set.npm run verifychecks every anchor against the chain: a rewritten or truncated Record, or an anchor signed by another key, fails. The key is on the same machine as the database, so someone who controls the machine could rewrite both. Anchors protect against that only when copies live elsewhere: setANCHOR_URLto a service you control, or copy theanchorsfolder off. - Timestamped (optional). With
OTS_ENABLED=1, once a day the newest anchor's digest is submitted to OpenTimestamps calendars and the proof kept inots/. That gives a witness outside your machine and outside your key.npm run ots:verifyrecomputes each proof from its anchor, but it does not check the Bitcoin block header; see operating it.
Backups
- Encrypted. AES-256-GCM, with the key derived from
BACKUP_PASSPHRASEby scrypt (N=2^15, r=8, p=1) and a fresh salt and IV per file. The plaintext header (format, parameters, salt, IV) is authenticated with the ciphertext, so a changed header or body fails to decrypt. - The passphrase is never stored. It comes from the environment or is typed at the prompt without echo. Lose it and the backups cannot be read.
- Checked on the way in and out. A backup refuses to run on a broken chain. A restore verifies the chain and the head and compares the projection hash with the one in the file, and only restores into an empty target.
- Files are mode 0600, in
<data>/backups. The drill endpoint takes a file name only and restores only files in that folder. - Not off-site. Nothing copies a backup off the machine. That is yours to do.
Data is not instruction
Feed headlines, web quotes and seat output are data. They are stored and shown as text. None of them can change a rule, a limit, a size or a signature. Seats produce text and probabilities; every money figure (NAV, fills, fees, limits, sizes) is computed by code.
The untrusted block. Text from outside the prompt's own instructions (claims on file, the owner's
thesis, imported notes, documents, headlines) reaches a model only inside a delimited block
(src/seats/untrusted.ts). The block opens and closes with a marker that carries a random 16-hex token,
drawn after the content is fixed, so the content cannot close the block early; anything in the content
that looks like a marker is defused. The content is JSON-encoded, and the block says in plain words that
it is data. It is never joined into the system prompt. The stored prompt and the replay key replace the
token with a fixed placeholder, so a replay still finds the stored answer.
The injection scanner. When a claim is recorded or a feed item is read, a scanner looks for
instruction-like phrasing (English and Dutch), chat role markers, tool-call syntax, hidden or zero-width
characters and long base64 runs. What fires is stored on the claim (injection on claim.recorded) or
the feed item, and shown as a "Reads like instructions" badge in Governance → Claims and on the Wire. It
is a heuristic: it misses some attacks and flags some innocent text. A flag changes nothing else. Flagged
content is still data only; it is not removed, rewritten or given any other weight.
Model replies reach the Record through one filter. ask() in src/seats/seats.ts is the only place a
seat's reply is parsed. It keeps only the fields the scripted answer has, with the same type; everything
else in the reply is dropped. finishView in src/seats/viewschema.ts then bounds every word, keeps
only claim ids that are on file, and writes every number and watch item itself. Seat code appends only
the research event types. test/untrusted.test.ts checks this against a model that returns extra
fields, forged event types and instructions.
Secrets
Everything secret stays on the server and out of the Record:
| Secret | Where it lives |
|---|---|
| The access token | .token, 0600, or RESOLUTION_TOKEN. |
| Model keys | The environment, or model-key*.json, 0600. |
| Notification credentials | The environment only (NOTIFY_*). The Record gets notification.sent with the channel, the kind and whether it worked; never the message, an address, a token or a password. Errors are scrubbed of every configured secret. |
| The backup passphrase | The environment or the prompt. Never written. |
| The anchor key | anchor.key, 0600. |
| The owner's signing key | The browser only. |
Keep environment secrets in a .env file that is not committed, or in your service manager's secret
store.
What operations exposes
/healthzneeds no token. It returns{ok, status, degraded, reasons, setup}, where the reasons are clause names only, for examplebreaker:anthropic,notify:emailorbackup, andsetupisincompleteuntil the wizard has run. It says which provider or channel is failing and whether the fund exists yet, and nothing else: no figure, no position, no error text.GET /api/opsneeds the token. It returns health with the reason text, the providers and their failure rates and last errors (scrubbed of keys), notification channels as configured or not, seat call latency, recent runs, breakers, dead jobs with their errors, and the last backup and anchor. No key, no address and no credential.POST /api/kill/cancel-ordersis the one broker action outside an approval. It only cancels the fund's working orders.
Docker
The image runs as the non-root node user. Compose publishes the app on 127.0.0.1 only, and Postgres
is not published at all. Set POSTGRES_PASSWORD to something other than the default.
What it leaves to you
- The machine. Anyone with your user account can read
.tokenand the data directory. - A tunnel's access control.
ALLOWED_HOSTSonly accepts the name; the tunnel decides who reaches it. - Backups off the machine. The record is the fund. See operating it.
- Anchor copies off the machine, through
ANCHOR_URLor by hand. - Your signing key. Forgetting it in Settings removes it from the browser. A new one can be registered at any time; past signatures still verify.