Appearance
Threat model
STRIDE over the architecture as it runs on 2026-10-09, including the two pieces added for launch: Stripe billing (ADR 0037, SPEC-016) and self-service sign-up (ADR 0038, SPEC-017), both built but not yet switched on. Each threat names the control and where it lives, and the gaps still open. For reporting an issue, see SECURITY.md.
Architecture
text
Owner's Claude (web, desktop, phone) Owner's browser
│ MCP over HTTPS, OAuth │ sign-up, Stripe Checkout / Portal
▼ ▼
Cloudflare Access (Managed OAuth, policy, MFA) ─┘
│ Cloudflare Tunnel (outbound only, no open ports)
▼
App: Node, Hono, MCP SDK (src/web, src/mcp) ──► Xero API (OAuth, tokens encrypted)
│ role `app`, never the owner Companies House API (public data)
▼ Stripe API and webhook
Postgres: row-level security on entity_idTrust boundaries: (1) the internet to Cloudflare; (2) Cloudflare to the app; (3) the app to Postgres; (4) the app to Xero and Stripe; (5) the language model to the tools, since the model reads text an attacker may control (bank lines, invoice references, emails).
Assets
Customers' Xero access (encrypted refresh tokens), the books data read from Xero, statement contents in memory, the audit log of writes, subscription state, and the secrets in Doppler (database passwords, XERO_TOKEN_ENCRYPTION_KEY, ACTIVITY_LOG_HASH_KEY, Stripe keys).
Spoofing
| Threat | Control | Where |
|---|---|---|
A stranger calls /mcp | Cloudflare Access in front; the app verifies the Access JWT itself (signature against the team's keys, issuer, AUD, expiry) and returns 503 if Access is unconfigured, never open | src/web/access.ts, src/web/app.ts, AUDIT C4, ADR 0020 |
| A signed-in person acts for a company that is not theirs | Identity only from the verified token; a principal row with an entity_access grant is required; the company comes from the session, never from tool input | src/web/known-person.ts, semgrep mcp-entity-from-session, CLAUDE.md rule 4 |
| Forged Stripe webhook | Stripe-Signature verified over the raw body with the webhook signing secret before any state changes; each subscription is re-read from Stripe before it is recorded | src/web/billing.ts, SPEC-016 S5, ADR 0037 |
| Self-service sign-up abused to create accounts | A new account sees no company until it connects its own Xero organisation through Xero's consent screen (/mcp refuses a principal with no company), and the company's entitlement comes from Stripe, not from input | src/web/onboarding.ts, src/xero/connect.ts, src/mcp/context.ts, SPEC-017, ADR 0038 |
Tampering
| Threat | Control | Where |
|---|---|---|
| Prompt injection in a bank line, invoice or email makes the model write to Xero | Every write is a preview; only Approve in an approval card makes the write. The card calls an app-only tool the model cannot see, with a one-time token only the card receives (hash stored); nothing in chat counts as approval | src/mcp/approval-card.ts, AUDIT C5, "C5:" tests in tests/mcp/bank-tools.test.ts |
| A write after the books are locked | Refused on or before Xero's period and year-end lock dates, at preview and at write | AUDIT C5 (#122) |
| A replayed or duplicated write | Preview claimed once, by the same person, within 15 minutes; Xero Idempotency-Key on every write | AUDIT M4, M5 |
| Changing the audit log | ledger_write append-only by RLS and revoked UPDATE/DELETE | src/platform/policies.sql, bootstrap.sql, AUDIT M6 |
| Model invents or alters a figure | Figures come only from code; replies start with a code-built summary the model is told to show as it is | CLAUDE.md rule 3, src/mcp/guidance.ts |
| A malicious deploy | A deploy user with a forced command, a root program that takes no input, and a compose check that refuses privileged settings; images built in CI, signed and deployed by digest are planned (ADR 0028, proposed; issue #75) | ADRs 0023, 0028 |
| Webhook replay changes a subscription | Stripe's signed timestamp checked within the SDK's tolerance; each event records Stripe's current subscription state, re-read from Stripe, so a replay changes nothing | src/web/billing.ts, SPEC-016 S7, ADR 0037 |
Repudiation
| Threat | Control | Where |
|---|---|---|
| "I didn't approve that" | Every write logged with who approved, the exact entry, before and after, outcome | ledger_write, AUDIT M6 |
| What did the model propose, and why? | Activity log of proposals, approvals and outcomes; bank line IDs only as keyed hashes | ADR 0033, SPEC-010 |
| Who signed in? | Cloudflare Access and Entra sign-in logs | ADR 0026 |
Information disclosure
| Threat | Control | Where |
|---|---|---|
| One customer reads another's data | Postgres RLS on entity_id on every table but principal; the app connects as app, which cannot bypass it; RLS tests in CI against a real Postgres | ADR 0003, tests/platform/rls.test.ts, policies.test.ts |
| Stolen database copy exposes Xero access | Tokens encrypted with AES-256-GCM; the key is in Doppler and the app's environment, never in the database or its backups | src/platform/crypto.ts, AUDIT X1 |
| Statement contents leak | Never stored or logged; read in memory for one request; semgrep forbids logging statement text | ADR 0032, semgrep no-logging-statement-text |
| Bank credentials leak | None held: statement files only; the database refuses any other source and any stored credential | ADR 0035, migration 0014 |
| Secrets in the repository | gitleaks over full history in CI and before each commit; fixtures use fake values | scripts/security/gitleaks.sh, AUDIT K2 |
| Secrets or tokens in logs | semgrep no-logging-credentials; structured logger | src/platform/logger.ts |
| Error messages leak internals | Plain-English tool errors without stack traces | AUDIT C2 |
| The statements folder is shared on a local server | The owner confirms file names and dates before any file is used | src/mcp/guidance.ts, ADR 0032 |
Denial of service
| Threat | Control | Where |
|---|---|---|
| Large requests | 1 MB body limit, 413 | src/web/app.ts |
| Exhausting the Xero rate limit (60 a minute) | Calls in sequence, 429 back-off honouring Retry-After, exact call budgets per entry point in CI | AUDIT X3, tests/performance/budgets.ts |
| Hanging upstreams | 30-second timeout on every outbound request | src/platform/timed-fetch.ts, AUDIT K3 |
| Single host | The NAS is one machine; Cloudflare in front; nightly backups with a restore test | Gap: no second host; recovery is restore from backup |
Elevation of privilege
| Threat | Control | Where |
|---|---|---|
| The model calls a tool it should not | The approval tool is app-only and hidden from the model; no MCP tool files with HMRC or Companies House | AUDIT C5, CLAUDE.md rule 5, ADR 0036 |
| Pull request steals deploy secrets | Doppler tokens only on a dedicated deploy runner; repository write limited to the Product Owner and Rob | ADR 0019 (#71) |
The deploy SSH key is stolen | restrict, from= the runner, forced command; not in the docker group; root program takes no input | ADR 0023 |
| Database owner credentials misused | Migrations run only from the pipeline, backup first; developers use throwaway databases | ADRs 0014, 0029, 0030 |
Open gaps (known, ranked)
- Single production host on FEAW premises; cloud hosting is still on not-doing.
prdanddevsecrets separation is incomplete (issue #63);migrate-nasstill readsdev(ADR 0019).- Retention periods proposed in ADR 0026 are not yet enforced by scheduled deletes. Account deletion is built: it cancels the subscription, revokes and deletes the Xero tokens, and deletes every row of a company only that person used, keeping only a pseudonymised activity log for 6 years (SPEC-017, migration 0018).
- Base image vulnerabilities are reported, not blocking, until #75.
- Sign-up and billing are built (SPEC-016, SPEC-017) but not switched on; review this page when they go live.