Skip to content

Threat model

One page on what EVE Nexus protects, from whom, and how. Update it in the same change as any new cookie, token, trust boundary or plugin interface. (Strategy review item 2.8.)

What is worth stealing

Asset Why it matters
ESI refresh tokens Long-lived access to pilots' EVE data, including mail and wallets for audit scopes
VAULT_MASTER_KEYS Decrypts every stored refresh token, and derives the private-cookie key
Sessions Act as a pilot in Nexus, including admins
Access decisions (States, Groups, Discord roles) Getting a role or channel you shouldn't have is the usual goal of an attacker in EVE
Character summaries (character_snapshots) Wallet balance, asset counts, mail subjects and senders, location: what a spy wants about a pilot
Audit log The record of who had access to what; tampering hides abuse
Discord bot token Manage roles and nicknames on the alliance server

Trust boundaries

Browser ──► Edge (Cloudflare / Caddy / nginx / tunnel) ──► Nexus core ──► PostgreSQL
                                                              │
                                                              ├──► EVE SSO and ESI (CCP)
                                                              └──► Discord API
  • Browser → edge → core. Everything from the browser is untrusted. Forwarding headers (X-Forwarded-For, X-Forwarded-Proto, CF-Connecting-IP) are honoured only from peers in TRUSTED_PROXIES (and, with TRUST_CLOUDFLARE_IPS=true, Cloudflare's published ranges, kept up to date daily). Anyone else's headers are ignored, so they can't forge the IPs written to audit and consent records.
  • Core → PostgreSQL. The API connects as a role that does not own the tables (DATABASE_URL). Migrations run as the owner (DATABASE_MIGRATE_URL) when that is set. The API role can read and write rows and cannot disable the audit trigger or change the schema. The database never sees a secret in clear: refresh tokens are sealed with AES-256-GCM, bound to their character ID (associated data), so a sealed token copied to another character's row fails to decrypt. Secrets in system_config must be sealed (enforced by a CHECK constraint since migration 0004).
  • Core → CCP. Every EVE JWT is checked against CCP's JWKS (signature, issuer, audience, expiry). A changed CharacterOwnerHash marks the character transferred and moves it away from the old account.
  • Core → Discord. Discord OAuth only proves which Discord user a pilot is; it never grants anything in Nexus. The bot only adds or removes roles mapped in Access Control.
  • Plugins (Phase 4). Not built yet. They will run out of process and get scoped, short-lived credentials from core, never the vault key or the database password.

Cookies and tokens

Name Holds Protection
nexus_session Random 256-bit session token HttpOnly, SameSite=Lax, Secure on HTTPS; only its SHA-256 is stored; 14-day expiry; rotated on every sign-in
nexus_sso_pkce (path /sso) PKCE verifier, state, account to link into Encrypted and authenticated (private cookie, key derived from the vault key)
nexus_discord_link (path /discord) OAuth state, account being linked Encrypted and authenticated, short-lived
Refresh tokens In esi_tokens AES-256-GCM with versioned keys; re-sealed on every refresh. A token replaced at sign-in is not revoked at CCP: revoking one ends the character's whole grant for the app, including the new token
Cloudflare API token and tunnel token (built-in tunnel) API token in tunnel_config. Connector token only in the cloudflared container (CLOUDFLARE_TUNNEL_TOKEN) AES-256-GCM like refresh tokens, bound to their purpose; re-sealed with the newest key at startup; only superadmins can change or remove the tunnel; the API token is never sent back to the browser. The connector token is shown once when a tunnel is created, so it can be placed in the connector's environment. The API process does not keep it
Access tokens In memory only Cached per character until a minute before exp; never written to disk or logs
nexus_oidc_resume OIDC sign-in to resume after EVE SSO Encrypted private cookie, 10 minutes, HttpOnly, path /
OIDC client secrets Let another app take a code grant Argon2id hash only; the secret is shown once
OIDC signing keys Sign ID tokens PKCS#8 private key sealed with the vault key, bound to kid; public half is in JWKS
OIDC codes and tokens Act as the pilot in another app SHA-256 only. Codes last 60 seconds and are single use. Access tokens last 10 minutes and can be revoked. Refresh tokens rotate; reuse revokes the family

The account an alt is linked into comes from the server-side session, never from a client value. (The review found an unsigned cookie naming the target account; that was the account-takeover path, now fixed.)

CSRF and abuse

  • State-changing requests need a matching Origin (or Referer) for PUBLIC_URL, on top of SameSite=Lax. Nexus also accepts its own loopback address (http://localhost:<port> or http://127.0.0.1:<port>, the port it is listening on), so an admin on the server can still fix things while the public address is down. Only a page Nexus served itself can have that origin; a session cookie is still required. Admin and group writes also need the right permission, checked server-side.
  • /sso/* and /discord/* allow 30 requests per minute per client IP. /oauth/authorize has its own per-IP budget (default 30). /oauth/token and /oauth/revoke have a budget per client id and IP (default 120) and a separate per-IP budget (default 60), so a new client id on every request still hits a limit before Argon2. At most two Argon2 verifications run at once; past a short queue the token endpoint returns temporarily_unavailable. /oauth/jwks is capped per IP (default 60). A request with no client IP shares an "unknown" bucket instead of skipping the limit. IPv6 is keyed by /64. The numbers are OIDC_AUTHORIZE_PER_MINUTE, OIDC_TOKEN_PER_MINUTE, OIDC_TOKEN_IP_PER_MINUTE, and OIDC_JWKS_PER_MINUTE. Startup logs that unresolved addresses share a bucket, and Admin health repeats it after one such request. Name lookups that cost ESI calls are limited per account.
  • Scopes are only requested after the disclosure screen (POST /sso/start, same-origin and policy-version checked), which records the scopes, policy version, time and IP. Pilots switch categories off per character; Nexus enforces that on its own copy of the grant (granted_scopes), so a later sign-in can't silently re-enable them.
  • Security headers on every response: a content security policy with script-src 'self' (the embedded UI loads its script from this origin), frame-ancestors 'none', X-Frame-Options: DENY, nosniff, a strict referrer policy, and HSTS on HTTPS.

Character data

  • The profile endpoint decides access on the server: the owner, or a leader of the unit their main belongs to (or above it). Everyone else gets 404, the same answer as a missing character, so pages can't be used to probe who is a member.
  • Leader views are written to the audit log before the data is returned.
  • Switched-off categories are never returned, even if stale data were still stored, and the stored rows are deleted in the same transaction as the switch. Findings, the account summary and alert sentences built from that category are deleted in the same step. A revoked or transferred token is treated the same way. Findings from data the pilot still shares are kept for a set number of days (default 180, at most 365).
  • The account overview (/api/v1/accounts/...) uses the same check, and each tab a leader opens is audit-logged (account.viewed, at most once per tab every 10 minutes). Every tab also re-checks which characters grant its category at request time, so a character switched off a moment ago is not listed even before its rows are deleted.
  • Detail rows are stored for skills, clones, assets, the wallet, market orders, contracts, mail headers, notifications, contacts and killmails (history kept 180 days). They are deleted when the category is switched off (same transaction) or the token is lost (next sweep).
  • Mail text is never stored. When the owner, a leader or a superadmin opens a mail, Nexus reads that one mail from EVE with the pilot's token and returns it as plain text (markup stripped, so it can't inject anything into the page). A leader's or superadmin's open is written to the audit log (account.mail_read) before the text is fetched, every time. The pilots' disclosure says leaders can read mail.
  • Corporation wallets (corp_wallet.rs) are read only after a leader connects one with a character holding an accounting role, and only leaders of that corporation or a page above it can view them. Connecting and disconnecting are audit-logged; disconnecting deletes the stored journal and balances. The extra scope is requested only on that connect sign-in (and kept on that account's later sign-ins), never from ordinary pilots.
  • Member lists use the same leader check. CSV exports are audit-logged, and text fields are quoted with formulas defused (a leading =, +, - or @ is prefixed with '), so a character name can't run a formula in a leader's spreadsheet.
  • Background-check reports (reporter/) are derived only from rows already stored above. A report is visible to superadmins, holders of hr.audit.view, and leaders of the pilot's unit who do not outrank that pilot. A non-superadmin cannot read a superadmin's report. The pilot themself gets the same 404 as a missing account, and each view is audit-logged (at most once per 10 minutes). Marking a finding expected or dismissed is HR or superadmin only, because that status is global, and the audit row keeps the previous status and note. A report item that names another Nexus account is shown only when the viewer could open that account's report. Mail subjects and bodies are never read by the checks. Player-written text (journal reasons, names) is untrusted: it is escaped before it is shown, and braces are neutralised before it goes into a sentence template. Findings from data the pilot still shares are deleted a set number of days (default 180, at most 365) after they were last seen.
  • The blacklist blocks sign-in for a blacklisted account and for a character on the Nexus blacklist (sso.blocked_blacklisted in the audit log), ends that account's sessions, revokes its ESI tokens and drops it to the default State. The block is blacklisted_at, not is_active. Corporation entries, alliance entries and the alliance sheet do not block sign-in; they flag dealings in reports. blacklist.manage cannot blacklist a superadmin or a leader the actor does not strictly outrank. Reasons can be restricted, and a viewer cannot overwrite, remove or lift an entry above their restriction level. Restricted reasons are removed on the server for viewers without the matching permission. The audit row records the previous restriction, not the reason text.
  • The Discord webhook is sealed with the vault key like other secrets and never returned by the API. Only a superadmin can set it or the alliance sheet link; the audit log stores the webhook's id suffix, not the token, and says when the secret cannot be decrypted. Alerts name the pilot and link to the report. They do not include the finding sentence, so player-written text and conclusions stay in Nexus. Discord markdown is escaped and URLs in names are broken so they are not auto-linked. The webhook client does not follow redirects. The alliance sheet is fetched read-only from Google and the body is capped while it is read; a failed read, or one that shrinks the list by more than half, keeps the old copy.
  • A data-health note (a category switched off, a stale section, a missing token) is coverage on the report. It is never a Medium or High item and never a Discord alert.
  • Opening the member list is audit-logged. It is the leadership view of who is in the unit, including location, ship, home station, last login, skill points and birthday for pilots who share those categories.
  • The detection rules are not in the public repository (reporter/checks.rs is a stub). Operators who want background checks supply their own.

Integrity of the record

audit_logs is append-only: a trigger blocks updates and deletes, except clearing the actor link when an account is deleted. Admin changes write their audit row in the same transaction as the change, with actor and IP.

Account administration

admin.users.manage can change a pilot's main, which moves their State. It can also add or remove groups when that does not grant a permission the actor does not already hold, end their sessions and re-sync Discord. A manual group add stays across member States and is removed, with reason left organization, when the pilot falls to a non-member State. A manual remove blocks rejoin until another manual add. states.members.manage can force a State, with an optional reason and expiry. Affiliation re-check keeps that override, expires a non-member one when the pilot leaves the organisation, and flags an override that still forces a member State. It cannot grant permissions or superadmin. Permissions come from States and hidden groups (admin.states.manage), and only someone who already holds a permission can attach it. Only a superadmin can assign a group or State that grants admin.states.manage, or change a superadmin's groups or State. Open and requestable groups carry no permissions, because pilots can join those without an admin. A group manager can add a member only when they hold every permission that group grants. Only a superadmin makes another, never removing themselves. Every action is audited in the same transaction. The last sign-in time is stored on the account, so ending sessions doesn't hide when someone was last active. Permissions are loaded on every request, and OIDC userinfo reads the live State and groups, so a removal drops what those grants gave on the next request and the next token. Discord role sync is queued in the same transaction as the membership change.

Dangerous admin actions need a second factor proven in the last 5 minutes on that session (mfa.rs, design in admin-mfa.md): a passkey or security key for superadmin grants, the tunnel, OIDC key and secret rotation, the emergency revoke and the MFA requirement itself; any factor for blacklisting, the webhook and sheet link, OIDC client deletion and scope categories. A copied session cookie alone no longer does these once the person has a factor. WebAuthn requires user verification, uses PUBLIC_URL as the relying party, and stores only the public key; ceremonies are single use, five minutes, and bound to the session that started them. Authenticator secrets are sealed with the vault and each code is accepted once. Five failures in 15 minutes lock confirmations for 15 minutes.

Sign in with Nexus (OIDC)

Other apps authenticate here instead of holding an EVE application. The issuer is PUBLIC_URL, not the request's Host header. A client with no access rule allows only superadmins. Authorize, refresh, and userinfo re-check State, group, and the blacklist; a failed refresh revokes that token family. Consent and logout are POSTs with the same origin check as the rest of Nexus. Userinfo accepts a bearer token only. The consent page cannot be framed. See the design note.

Known gaps

  • Until admin_mfa_required is on, a stolen session of a superadmin who has no second factor can add the attacker's own passkey and pass step-up. Turn the requirement on once operators have enrolled.
  • There is no account that works without EVE SSO yet (the local install account, MFA part 2).

  • Rate-limit and token-cache state is per process: fine for one instance, not for several.

  • A database superuser can still disable the audit trigger; ship logs off-box if that matters.
  • The vault key sits in the process environment. Losing the server means rotating it.
  • Plugin isolation is a design goal only until Phase 4 exists.
  • An audit entry whose actor account was deleted shows "Nexus" as the actor; the entry and its IP remain.
  • A leader can still note down what they saw; the audit log records that they looked, not what they did with it. Corp and alliance leadership should be trusted people.