From 716a4182acaa168be4ff936c748538581b03f958 Mon Sep 17 00:00:00 2001 From: ***** <721466+soodoku@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:28:08 -0800 Subject: [PATCH 1/2] Enforce American spelling with codespell Co-Authored-By: Claude Fable 5.2 --- .codespellrc | 4 ++++ .github/workflows/codespell.yml | 18 ++++++++++++++++++ README.md | 22 +++++++++++----------- SECURITY.md | 2 +- docs/THREAT_MODEL.md | 8 ++++---- src/db/migrations/0004_recovery_state.ts | 2 +- src/kernel/access.ts | 4 ++-- src/kernel/audit.ts | 2 +- src/kernel/canonical.ts | 2 +- src/kernel/control.ts | 4 ++-- src/kernel/execution.ts | 4 ++-- src/kernel/registry.ts | 2 +- src/kernel/stepup.ts | 2 +- src/modules/finance/payment.ts | 4 ++-- src/scripts/seed.ts | 2 +- test/access-property.test.ts | 2 +- test/redteam.test.ts | 2 +- 17 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/codespell.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..2c23449 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +builtin = clear,rare,en-GB_to_en-US +skip = *.pdf,*.png,*.jpg,*.jpeg,*.gif,*.csv,*.tsv,*.json,*.geojson,*.graphml,*.ipynb,*.html,*.svg,*.bib,*.bbl,*.lock,*.parquet,*.rda,*.rds,*.RData,*.dta,*.xlsx,*.xml,*.min.js,*.map,*.log,*.aux +ignore-words-list = afterall,authorisation,authorised,defence,enrol,enrolment,honours,normalise,requestor,unauthorised diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..cc542c0 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,18 @@ +name: codespell + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + codespell: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: codespell-project/actions-codespell@e3258cca84ce02b0bb36a3d41f2c18f719a0cc1a # v2.4.3 diff --git a/README.md b/README.md index 72a75c4..f2f13cf 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Each person gets a virtual passkey. | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | [Owner's home](docs/screenshots/01-owner-home.png) | Newly connected accounts stay private until chosen. The joint account says why it can't be shared. | | [Sharing preview](docs/screenshots/03-share-preview.png) | The grant is written out as sentences before the owner signs it. | -| [Delegate's queue](docs/screenshots/04-helper-queue.png) | Grouped by owner. Every bill shows its source and freshness. A guessed bill is labelled as a guess, and an unknown amount stays "unknown". | +| [Delegate's queue](docs/screenshots/04-helper-queue.png) | Grouped by owner. Every bill shows its source and freshness. A guessed bill is labeled as a guess, and an unknown amount stays "unknown". | | [Unsupported action](docs/screenshots/06-honest-capability.png) | A transfer between the owner's own accounts is refused, with the reason given. | | [Approval slip](docs/screenshots/08-approval-slip.png) | Amount, fee, source, destination, preparer, timing and cancellation terms on one screen. | | [Timeline](docs/screenshots/10-timeline-posted.png) | Every status after "Sent" comes from the provider. "Delivered" and "Posted" are different events. | @@ -54,7 +54,7 @@ The vocabulary comes from UMA 2.0 (resource owner, requesting party, resource, s uses a `type`-tagged details object to describe the exact thing being approved. An ESLint rule stops the kernel from importing a module. -### The one authorisation rule +### The one authorization rule An actor may use a scope on a resource if either: @@ -88,7 +88,7 @@ Just before anything is sent, one transaction re-checks everything: In the same transaction it records the attempt and moves the payment to `Dispatching`. -The gate locks the grant row and then the payment row, the same order revocation uses. So the two serialise: +The gate locks the grant row and then the payment row, the same order revocation uses. So the two serialize: - if revocation commits first, nothing is sent; - if the gate commits first, the owner's timeline says the payment was already in flight and a cancellation request is queued. @@ -146,15 +146,15 @@ testcontainer. Every test file clones a migrated template database. | File | What it establishes | | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `test/access-property.test.ts` | For random sequences of grant, pause, resume, revoke and deselect, SQL authorisation agrees with an independent in-memory model on every (person, scope, resource) triple, in both the point checks and the lists. | +| `test/access-property.test.ts` | For random sequences of grant, pause, resume, revoke and deselect, SQL authorization agrees with an independent in-memory model on every (person, scope, resource) triple, in both the point checks and the lists. | | `test/grants.test.ts` | Scoped reads and totals. Guessed IDs. Joint and unselected accounts can't be shared. A delegate can't widen their own access. The passkey is bound to the exact grant and works once. Access requests. Expiry. The audit log is append-only, and editing or deleting an exported row is detected. | | `test/scenarios/payment-flow.test.ts` | The full path. Repeated clicks. Honest capabilities. Approval invalidated by a change. Only the owner approves, and only with a passkey. Expired approvals. Scheduled dates. | -| `test/scenarios/failures.test.ts` | Duplicate jobs. Timeout after acceptance. Request lost before acceptance. A provider without safe retry. A worker that crashed after the gate. Declines. Webhook signatures, duplicates, reordering and early arrival. Returns. Cancelling in flight. | +| `test/scenarios/failures.test.ts` | Duplicate jobs. Timeout after acceptance. Request lost before acceptance. A provider without safe retry. A worker that crashed after the gate. Declines. Webhook signatures, duplicates, reordering and early arrival. Returns. Canceling in flight. | | `test/scenarios/races.test.ts` | Revocation racing dispatch, run 40 times; both orderings must occur or the test fails. Concurrent spending against a monthly limit. The per-payment limit. | | `test/scenarios/controls.test.ts` | Pause and resume. The support kill switch. Recovery. Self-freeze. The gate re-checks narrowed and expired grants. Unknown amounts stay unknown. Autopay and recent-payment warnings. Stale connections. Reconnect remapping. Isolation between owners. | | `test/api.test.ts` | Sessions are required. An actor claimed by the client is ignored. 404 parity. The idempotency header. The 422 capability response. Approving without a passkey fails. Webhook signatures. The scope of audit exports. | -| `test/worker.test.ts` | The same behaviour driven by the real graphile-worker runner. | -| `test/security.test.ts` | One test per hardening item in the threat model: passkey enrolment, notices and the trusted contact, sessions, cross-site requests, headers and CSP, rate limits, fail-closed demo features, database roles, signed audit checkpoints, webhook replay, log redaction. | +| `test/worker.test.ts` | The same behavior driven by the real graphile-worker runner. | +| `test/security.test.ts` | One test per hardening item in the threat model: passkey enrollment, notices and the trusted contact, sessions, cross-site requests, headers and CSP, rate limits, fail-closed demo features, database roles, signed audit checkpoints, webhook replay, log redaction. | | `test/fuzz.test.ts` | 1,500 random requests to real routes (other people's IDs, junk IDs, injection strings, random bodies) sent as a delegate, a family member with no access, and an unrelated user. No 5xx, no response containing any ID or label they may not see, and nothing owned by the owners changes. | **Checking that the tests can fail.** Each guard was switched off in turn and its test re-run: @@ -177,7 +177,7 @@ Three guards are deliberate second layers, and no test fails when one is removed ## Security -Security is the organising principle, and [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md) is its specification. +Security is the organizing principle, and [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md) is its specification. Its central fact: in FinCEN's review of elder-theft reports, adult children were the most frequent perpetrators, at about 40% of cases. So the delegate, the person this product is built for, is treated as the first adversary. A delegate can see and prepare, but can never approve, widen their own access, or act @@ -189,7 +189,7 @@ are fixed and listed in the threat model. | Guard | Why | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | -| Adding a passkey needs an existing passkey, or a recovery window opened by verified identity | A stolen session, or a delegate at the owner's device, could otherwise enrol their own passkey and then approve payments | +| Adding a passkey needs an existing passkey, or a recovery window opened by verified identity | A stolen session, or a delegate at the owner's device, could otherwise enroll their own passkey and then approve payments | | Notices to the owner, the delegate and a trusted contact who is independent of every delegate | The owner hears through a channel the delegate doesn't control | | Sessions: `__Host-` cookie, Secure, HttpOnly, SameSite=Strict; only a hash stored; 30-minute idle and 12-hour absolute expiry; sign out everywhere; recovery ends all sessions | Limits what a stolen cookie or a copied table is worth | | Every state-changing request must come from our origin | Cross-site request forgery | @@ -220,9 +220,9 @@ Report vulnerabilities privately: see [SECURITY.md](SECURITY.md). ## Known limits of R0 -- **Time zones.** The scheduled date is a calendar date, and the server accepts "yesterday in UTC" so that "today" works anywhere in the Americas. Owners' time zones are not modelled. +- **Time zones.** The scheduled date is a calendar date, and the server accepts "yesterday in UTC" so that "today" works anywhere in the Americas. Owners' time zones are not modeled. - **One executor per intent type.** R2 will need capability routing across providers. - **Recovery.** The "independent verification" step is simulated; support attests to it. -- **Postgres row-level security** is not used yet. The authorisation rule is enforced in the application and property-tested; the database roles give defence in depth. Row-level security would need every request to run in a transaction that carries the actor, and is planned for R1. +- **Postgres row-level security** is not used yet. The authorization rule is enforced in the application and property-tested; the database roles give defense in depth. Row-level security would need every request to run in a transaction that carries the actor, and is planned for R1. - **Notices** go to an outbox shown in the app. Email and SMS delivery comes in R1. - **Webhook handling.** A webhook that conflicts with our state triggers a provider fetch inside a database transaction. That's fine for a simulator, but it should move out of the transaction before a real provider is used. diff --git a/SECURITY.md b/SECURITY.md index 091ff55..7e95089 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -14,7 +14,7 @@ Include what you did, what happened, and what you expected. A failing test again This repository is the **R0 demonstrator**. All accounts, balances and payments are simulated fixtures; no real financial data exists anywhere in it and no money can move. Findings are still in scope, -because the same authorisation, approval and dispatch code will carry real data in later releases. +because the same authorization, approval and dispatch code will carry real data in later releases. Especially wanted: diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index 64de6dc..0a54000 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -26,14 +26,14 @@ legitimate grant; they often have physical access to the owner's device, and soc | Attack | Control | Evidence | | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | -| See unshared accounts or totals | One authorisation rule; lists and totals are built from visible resources only | `access-property.test.ts`, `grants.test.ts` "scopes reads…" | +| See unshared accounts or totals | One authorization rule; lists and totals are built from visible resources only | `access-property.test.ts`, `grants.test.ts` "scopes reads…" | | Guess another account's ID | Unauthorised and nonexistent both return 404 | `grants.test.ts`, `api.test.ts` "404 parity" | | Widen their own grant | Only the grantor can set a grant, and only with their own passkey over the exact grant | `grants.test.ts` "never lets a delegate widen…" | | Approve a payment themselves | Approval requires actor = owner plus the owner's passkey over the revision digest | `payment-flow.test.ts` "lets only the owner approve" | | Get approval for one amount, then change it | Every change creates a new revision; approval is bound to the digest | `payment-flow.test.ts` "invalidates approval…" | | Split one payment into many under a limit | Monthly limit, reserved atomically, and pending payments count | `races.test.ts` "concurrent payments…" | | Keep acting after being revoked | Revocation cancels unsent payments at commit; the gate re-checks the grant under lock | `races.test.ts`, `controls.test.ts` "revocation cancels…" | -| **Add their own passkey to the owner's account while holding the owner's device or session** | Enrolment requires step-up with an existing passkey (hardening #1) | `security.test.ts` "passkey enrolment…" | +| **Add their own passkey to the owner's account while holding the owner's device or session** | Enrolment requires step-up with an existing passkey (hardening #1) | `security.test.ts` "passkey enrollment…" | | **Act without the owner knowing** | Out-of-band notices to the owner and a trusted contact (hardening #2) | `security.test.ts` "notifies…" | | Start recovery to take over the owner's account | Only the owner or support can start it; recovery freezes execution and revokes sessions | `controls.test.ts` "recovery…", `security.test.ts` "recovery revokes sessions" | | Pressure the owner into approving | **Residual risk.** Notices to a trusted contact are the only technical control. There is deliberately no cooling-off period (product decision, 2026-09-28). | — | @@ -55,7 +55,7 @@ with a new "helper" or approving a payment, often in real time on the phone. | Attack | Control | Evidence | | ---------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | | Steal a session cookie | `__Host-` cookie, HttpOnly, Secure, SameSite=strict; tokens stored as hashes; idle and absolute expiry | `security.test.ts` "sessions…" | -| Use a stolen session to move money | Money and authority always need a passkey; a session alone can do neither, including enrolling a passkey | `security.test.ts` "passkey enrolment…" | +| Use a stolen session to move money | Money and authority always need a passkey; a session alone can do neither, including enrolling a passkey | `security.test.ts` "passkey enrollment…" | | CSRF | SameSite=strict, plus an `Origin` / `Sec-Fetch-Site` check on every mutation | `security.test.ts` "rejects cross-site mutations" | | XSS | React escaping; strict CSP with no inline scripts; fonts self-hosted | `security.test.ts` "security headers" | | Brute force or enumeration | Rate limits on login, step-up and webhooks | `security.test.ts` "rate limits" | @@ -115,7 +115,7 @@ The reviewer also suspected three things, now addressed: - **Unsolicited access requests with free-text notes, a scammer's lure.** Only existing delegates can ask for more. - **Trusted-contact independence could be dodged with plus-addressing.** Addresses are compared case-insensitively and without `+tags`. -- **Support could open an enrolment window by freezing an account with the right reason text.** Recovery is now a state of its own. +- **Support could open an enrollment window by freezing an account with the right reason text.** Recovery is now a state of its own. ## Out of scope for R0 diff --git a/src/db/migrations/0004_recovery_state.ts b/src/db/migrations/0004_recovery_state.ts index 572e307..afaeeb3 100644 --- a/src/db/migrations/0004_recovery_state.ts +++ b/src/db/migrations/0004_recovery_state.ts @@ -1,7 +1,7 @@ import { type Kysely, sql } from "kysely"; // Recovery is a state of its own, not a freeze reason typed as free text, so -// support can't open an enrolment window by freezing with the right words. +// support can't open an enrollment window by freezing with the right words. export async function up(db: Kysely): Promise { await sql`alter table person add column recovery_started_at timestamptz`.execute(db); } diff --git a/src/kernel/access.ts b/src/kernel/access.ts index 0abc806..de4517b 100644 --- a/src/kernel/access.ts +++ b/src/kernel/access.ts @@ -2,7 +2,7 @@ import { sql } from "kysely"; import type { Executor } from "../db/index.js"; import { KernelError, type Registry } from "./registry.js"; -// Authorisation is plain SQL over grants rather than a policy engine. The +// Authorization is plain SQL over grants rather than a policy engine. The // rules that matter here are stateful (grant versions, row locks against // revocation, spending reservations), which a stateless engine such as Cedar // cannot enforce, so it would add a second system without removing any code. @@ -75,7 +75,7 @@ export async function canAccess( return g !== undefined; } -// Unauthorised and nonexistent look identical, so a guessed ID reveals nothing. +// Unauthorized and nonexistent look identical, so a guessed ID reveals nothing. export async function requireAccess( ex: Executor, registry: Registry, diff --git a/src/kernel/audit.ts b/src/kernel/audit.ts index 6df5d3c..f9473b4 100644 --- a/src/kernel/audit.ts +++ b/src/kernel/audit.ts @@ -30,7 +30,7 @@ export interface AuditRecord { } const GENESIS = "sha256:genesis"; -// Arbitrary constant; serialises audit appends so each row can chain to the previous hash. +// Arbitrary constant; serializes audit appends so each row can chain to the previous hash. const AUDIT_LOCK = 7_331_001; function hashBody(r: Omit): string { diff --git a/src/kernel/canonical.ts b/src/kernel/canonical.ts index ffd9586..f922ade 100644 --- a/src/kernel/canonical.ts +++ b/src/kernel/canonical.ts @@ -2,7 +2,7 @@ import { createHash } from "node:crypto"; import canonicalize from "canonicalize"; // RFC 8785 (JSON Canonicalization Scheme): the same logical object always -// serialises to the same bytes, so a digest identifies the exact content. +// serializes to the same bytes, so a digest identifies the exact content. export function canonicalJson(value: unknown): string { const out = canonicalize(value); if (out === undefined) throw new Error("value cannot be canonicalised"); diff --git a/src/kernel/control.ts b/src/kernel/control.ts index 34ebb7f..2c504de 100644 --- a/src/kernel/control.ts +++ b/src/kernel/control.ts @@ -92,7 +92,7 @@ export async function unfreezeOwner(k: Kernel, ownerId: string, stepUpResponse: // Recovery (lost passkey). The owner's old credentials are removed and all // execution is frozen until the owner completes independent verification and -// enrols a new passkey. A delegate can neither start nor finish this: the +// enrolls a new passkey. A delegate can neither start nor finish this: the // actor must be the owner (in R0 the independent verification is simulated). export async function startRecovery(k: Kernel, actorId: string, ownerId: string) { if (actorId !== ownerId && !(await isSupport(k.db, actorId))) { @@ -137,7 +137,7 @@ const ENROLMENT_WINDOW_MS = 60 * 60 * 1000; // Independent identity verification. In R0 a support agent attests to it; in // R1 this is an identity-verification provider. It opens a one-hour window in -// which the owner, and only the owner, can enrol a new first passkey. +// which the owner, and only the owner, can enroll a new first passkey. export async function completeRecoveryVerification(k: Kernel, actorId: string, ownerId: string) { await requireSupport(k, actorId); await k.db.transaction().execute(async (tx) => { diff --git a/src/kernel/execution.ts b/src/kernel/execution.ts index 5a73efc..ba48f91 100644 --- a/src/kernel/execution.ts +++ b/src/kernel/execution.ts @@ -27,10 +27,10 @@ async function hold(tx: Tx, intentId: string, status: string, why: string): Prom return { kind: "held", why }; } -// Every check that authorised this intent is repeated here, inside one +// Every check that authorized this intent is repeated here, inside one // transaction that holds a lock on the intent and a share lock on the // delegate's grant. Revocation takes an update lock on the same grant row, so -// the two serialise: if revocation commits first, this sees it and nothing is +// the two serialize: if revocation commits first, this sees it and nothing is // sent; if this commits first, the intent is already Dispatching and // revocation can only request cancellation (P7, PRD §10). // diff --git a/src/kernel/registry.ts b/src/kernel/registry.ts index b081e9e..6489ba4 100644 --- a/src/kernel/registry.ts +++ b/src/kernel/registry.ts @@ -61,7 +61,7 @@ export interface IntentExecutor { lookup(idempotencyKey: string): Promise; getOperation(operationId: string): Promise; cancel(operationId: string): Promise<{ canceled: boolean; reason: string }>; - // Maps a provider status to a normalised intent status or "Failed". + // Maps a provider status to a normalized intent status or "Failed". normalize(rawStatus: string): string; verifyWebhook(headers: Record, body: string): ProviderEvent | null; } diff --git a/src/kernel/stepup.ts b/src/kernel/stepup.ts index 563113f..ee6cbd0 100644 --- a/src/kernel/stepup.ts +++ b/src/kernel/stepup.ts @@ -5,7 +5,7 @@ import { KernelError } from "./registry.js"; // Step-up authentication for anything that expands authority or moves money: // creating or widening a grant, approving an intent, finishing recovery. Each // challenge is bound to a purpose and to the digest of the exact thing being -// authorised, and is single-use. A link in an email or a notification only +// authorized, and is single-use. A link in an email or a notification only // opens the screen; it can never supply this proof. export type StepUpPurpose = "grant" | "approve" | "register" | "recovery" | "enrol"; diff --git a/src/modules/finance/payment.ts b/src/modules/finance/payment.ts index fc90a0a..a41f0a3 100644 --- a/src/modules/finance/payment.ts +++ b/src/modules/finance/payment.ts @@ -126,7 +126,7 @@ export async function paymentCapability( }; } const days = (Date.parse(d.scheduledDate) - Date.parse(todayUtc())) / 86_400_000; - // Owners' time zones are not modelled yet; allowing yesterday-in-UTC accepts + // Owners' time zones are not modeled yet; allowing yesterday-in-UTC accepts // "today" anywhere in the Americas. Dispatch never happens before now anyway. if (days < -1) return { state: "unavailable", reason: "The scheduled date is in the past." }; if (days > MAX_DAYS_AHEAD) @@ -241,7 +241,7 @@ function periodKey(tz: string, at = new Date()): string { } // Cumulative caps are reserved atomically: an advisory lock per grant -// serialises concurrent dispatches, pending payments count, and only a +// serializes concurrent dispatches, pending payments count, and only a // definitive failure or return gives the capacity back (PRD §7). async function reserve( tx: Tx, diff --git a/src/scripts/seed.ts b/src/scripts/seed.ts index bf81092..a302c65 100644 --- a/src/scripts/seed.ts +++ b/src/scripts/seed.ts @@ -25,7 +25,7 @@ if (existing.length) { process.exit(0); } -// Simulated account creation: each person may enrol a first passkey for 30 days. +// Simulated account creation: each person may enroll a first passkey for 30 days. const window = new Date(Date.now() + 30 * 86_400_000); await k.db .insertInto("person") diff --git a/test/access-property.test.ts b/test/access-property.test.ts index 8a4a1ac..dcc9d17 100644 --- a/test/access-property.test.ts +++ b/test/access-property.test.ts @@ -6,7 +6,7 @@ import { addPayee, selectAccounts } from "../src/modules/finance/connections.js" import { accountsView } from "../src/modules/finance/reads.js"; import { connectAll, freshApp, grant, type TestApp, resume } from "./helpers.js"; -// The SQL authorisation is checked against an in-memory model that shares no +// The SQL authorization is checked against an in-memory model that shares no // code with it: random sequences of grant, pause, resume, revoke and deselect, // then every (person, scope, resource) triple is compared. diff --git a/test/redteam.test.ts b/test/redteam.test.ts index 76b56b6..308061a 100644 --- a/test/redteam.test.ts +++ b/test/redteam.test.ts @@ -33,7 +33,7 @@ import { status, } from "./scenarios/setup.js"; -// Red-team tests. Each asserts the SECURE behaviour, so each fails while the +// Red-team tests. Each asserts the SECURE behavior, so each fails while the // weakness it names exists. Adversary labels follow docs/THREAT_MODEL.md. const rp = { id: "localhost", name: "test", origin: "http://localhost:5173" }; From 9afdb8deb513900e4c1180ca0c9df2f2cfde4c4c Mon Sep 17 00:00:00 2001 From: ***** <721466+soodoku@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:54:50 -0800 Subject: [PATCH 2/2] Reformat the tables the spelling change resized Co-Authored-By: Claude Fable 5.2 --- README.md | 46 ++++++++++++++++++++++---------------------- docs/THREAT_MODEL.md | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index f2f13cf..a3eb0ef 100644 --- a/README.md +++ b/README.md @@ -19,15 +19,15 @@ bookkeeper. These screenshots were produced by `src/scripts/walkthrough.ts`, which drives the running app in Chromium. Each person gets a virtual passkey. -| Step | What to notice | -| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -| [Owner's home](docs/screenshots/01-owner-home.png) | Newly connected accounts stay private until chosen. The joint account says why it can't be shared. | -| [Sharing preview](docs/screenshots/03-share-preview.png) | The grant is written out as sentences before the owner signs it. | +| Step | What to notice | +| --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| [Owner's home](docs/screenshots/01-owner-home.png) | Newly connected accounts stay private until chosen. The joint account says why it can't be shared. | +| [Sharing preview](docs/screenshots/03-share-preview.png) | The grant is written out as sentences before the owner signs it. | | [Delegate's queue](docs/screenshots/04-helper-queue.png) | Grouped by owner. Every bill shows its source and freshness. A guessed bill is labeled as a guess, and an unknown amount stays "unknown". | -| [Unsupported action](docs/screenshots/06-honest-capability.png) | A transfer between the owner's own accounts is refused, with the reason given. | -| [Approval slip](docs/screenshots/08-approval-slip.png) | Amount, fee, source, destination, preparer, timing and cancellation terms on one screen. | -| [Timeline](docs/screenshots/10-timeline-posted.png) | Every status after "Sent" comes from the provider. "Delivered" and "Posted" are different events. | -| [After revocation](docs/screenshots/11-helper-after-revoke.png) | The delegate loses access on their next request. | +| [Unsupported action](docs/screenshots/06-honest-capability.png) | A transfer between the owner's own accounts is refused, with the reason given. | +| [Approval slip](docs/screenshots/08-approval-slip.png) | Amount, fee, source, destination, preparer, timing and cancellation terms on one screen. | +| [Timeline](docs/screenshots/10-timeline-posted.png) | Every status after "Sent" comes from the provider. "Delivered" and "Posted" are different events. | +| [After revocation](docs/screenshots/11-helper-after-revoke.png) | The delegate loses access on their next request. | ## How it works @@ -149,12 +149,12 @@ testcontainer. Every test file clones a migrated template database. | `test/access-property.test.ts` | For random sequences of grant, pause, resume, revoke and deselect, SQL authorization agrees with an independent in-memory model on every (person, scope, resource) triple, in both the point checks and the lists. | | `test/grants.test.ts` | Scoped reads and totals. Guessed IDs. Joint and unselected accounts can't be shared. A delegate can't widen their own access. The passkey is bound to the exact grant and works once. Access requests. Expiry. The audit log is append-only, and editing or deleting an exported row is detected. | | `test/scenarios/payment-flow.test.ts` | The full path. Repeated clicks. Honest capabilities. Approval invalidated by a change. Only the owner approves, and only with a passkey. Expired approvals. Scheduled dates. | -| `test/scenarios/failures.test.ts` | Duplicate jobs. Timeout after acceptance. Request lost before acceptance. A provider without safe retry. A worker that crashed after the gate. Declines. Webhook signatures, duplicates, reordering and early arrival. Returns. Canceling in flight. | +| `test/scenarios/failures.test.ts` | Duplicate jobs. Timeout after acceptance. Request lost before acceptance. A provider without safe retry. A worker that crashed after the gate. Declines. Webhook signatures, duplicates, reordering and early arrival. Returns. Canceling in flight. | | `test/scenarios/races.test.ts` | Revocation racing dispatch, run 40 times; both orderings must occur or the test fails. Concurrent spending against a monthly limit. The per-payment limit. | | `test/scenarios/controls.test.ts` | Pause and resume. The support kill switch. Recovery. Self-freeze. The gate re-checks narrowed and expired grants. Unknown amounts stay unknown. Autopay and recent-payment warnings. Stale connections. Reconnect remapping. Isolation between owners. | | `test/api.test.ts` | Sessions are required. An actor claimed by the client is ignored. 404 parity. The idempotency header. The 422 capability response. Approving without a passkey fails. Webhook signatures. The scope of audit exports. | -| `test/worker.test.ts` | The same behavior driven by the real graphile-worker runner. | -| `test/security.test.ts` | One test per hardening item in the threat model: passkey enrollment, notices and the trusted contact, sessions, cross-site requests, headers and CSP, rate limits, fail-closed demo features, database roles, signed audit checkpoints, webhook replay, log redaction. | +| `test/worker.test.ts` | The same behavior driven by the real graphile-worker runner. | +| `test/security.test.ts` | One test per hardening item in the threat model: passkey enrollment, notices and the trusted contact, sessions, cross-site requests, headers and CSP, rate limits, fail-closed demo features, database roles, signed audit checkpoints, webhook replay, log redaction. | | `test/fuzz.test.ts` | 1,500 random requests to real routes (other people's IDs, junk IDs, injection strings, random bodies) sent as a delegate, a family member with no access, and an unrelated user. No 5xx, no response containing any ID or label they may not see, and nothing owned by the owners changes. | **Checking that the tests can fail.** Each guard was switched off in turn and its test re-run: @@ -187,19 +187,19 @@ The hardening items, each with a test that fails when the guard is removed (swit all 17 caught). An independent red-team review then found ten more holes, mostly in the delegate model. They are fixed and listed in the threat model. -| Guard | Why | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | +| Guard | Why | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | Adding a passkey needs an existing passkey, or a recovery window opened by verified identity | A stolen session, or a delegate at the owner's device, could otherwise enroll their own passkey and then approve payments | -| Notices to the owner, the delegate and a trusted contact who is independent of every delegate | The owner hears through a channel the delegate doesn't control | -| Sessions: `__Host-` cookie, Secure, HttpOnly, SameSite=Strict; only a hash stored; 30-minute idle and 12-hour absolute expiry; sign out everywhere; recovery ends all sessions | Limits what a stolen cookie or a copied table is worth | -| Every state-changing request must come from our origin | Cross-site request forgery | -| Strict CSP with no inline scripts and no third-party hosts; the font is self-hosted | Cross-site scripting, framing, data exfiltration | -| Rate limits on sign-in, step-up and webhooks | Brute force and enumeration | -| Demo login refused when `NODE_ENV=production`; secrets required outside dev | Demo conveniences must not reach production | -| The app runs as a database role that can only append to the audit log, cannot read the provider's schema, and can only add jobs, not read or change them | Defence in depth if the app is compromised | -| Signed checkpoints of the audit chain, using a key the database never holds | Detects a rewrite even by someone who recomputes every hash | -| Webhook signatures cover a timestamp; anything older than 5 minutes is rejected | Replay of captured webhooks | -| Logs hold method, route and status only | Tokens, amounts and account IDs never reach logs | +| Notices to the owner, the delegate and a trusted contact who is independent of every delegate | The owner hears through a channel the delegate doesn't control | +| Sessions: `__Host-` cookie, Secure, HttpOnly, SameSite=Strict; only a hash stored; 30-minute idle and 12-hour absolute expiry; sign out everywhere; recovery ends all sessions | Limits what a stolen cookie or a copied table is worth | +| Every state-changing request must come from our origin | Cross-site request forgery | +| Strict CSP with no inline scripts and no third-party hosts; the font is self-hosted | Cross-site scripting, framing, data exfiltration | +| Rate limits on sign-in, step-up and webhooks | Brute force and enumeration | +| Demo login refused when `NODE_ENV=production`; secrets required outside dev | Demo conveniences must not reach production | +| The app runs as a database role that can only append to the audit log, cannot read the provider's schema, and can only add jobs, not read or change them | Defence in depth if the app is compromised | +| Signed checkpoints of the audit chain, using a key the database never holds | Detects a rewrite even by someone who recomputes every hash | +| Webhook signatures cover a timestamp; anything older than 5 minutes is rejected | Replay of captured webhooks | +| Logs hold method, route and status only | Tokens, amounts and account IDs never reach logs | In CI, alongside the tests: diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index 0a54000..8c49380 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -33,7 +33,7 @@ legitimate grant; they often have physical access to the owner's device, and soc | Get approval for one amount, then change it | Every change creates a new revision; approval is bound to the digest | `payment-flow.test.ts` "invalidates approval…" | | Split one payment into many under a limit | Monthly limit, reserved atomically, and pending payments count | `races.test.ts` "concurrent payments…" | | Keep acting after being revoked | Revocation cancels unsent payments at commit; the gate re-checks the grant under lock | `races.test.ts`, `controls.test.ts` "revocation cancels…" | -| **Add their own passkey to the owner's account while holding the owner's device or session** | Enrolment requires step-up with an existing passkey (hardening #1) | `security.test.ts` "passkey enrollment…" | +| **Add their own passkey to the owner's account while holding the owner's device or session** | Enrolment requires step-up with an existing passkey (hardening #1) | `security.test.ts` "passkey enrollment…" | | **Act without the owner knowing** | Out-of-band notices to the owner and a trusted contact (hardening #2) | `security.test.ts` "notifies…" | | Start recovery to take over the owner's account | Only the owner or support can start it; recovery freezes execution and revokes sessions | `controls.test.ts` "recovery…", `security.test.ts` "recovery revokes sessions" | | Pressure the owner into approving | **Residual risk.** Notices to a trusted contact are the only technical control. There is deliberately no cooling-off period (product decision, 2026-09-28). | — | @@ -55,7 +55,7 @@ with a new "helper" or approving a payment, often in real time on the phone. | Attack | Control | Evidence | | ---------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | | Steal a session cookie | `__Host-` cookie, HttpOnly, Secure, SameSite=strict; tokens stored as hashes; idle and absolute expiry | `security.test.ts` "sessions…" | -| Use a stolen session to move money | Money and authority always need a passkey; a session alone can do neither, including enrolling a passkey | `security.test.ts` "passkey enrollment…" | +| Use a stolen session to move money | Money and authority always need a passkey; a session alone can do neither, including enrolling a passkey | `security.test.ts` "passkey enrollment…" | | CSRF | SameSite=strict, plus an `Origin` / `Sec-Fetch-Site` check on every mutation | `security.test.ts` "rejects cross-site mutations" | | XSS | React escaping; strict CSP with no inline scripts; fonts self-hosted | `security.test.ts` "security headers" | | Brute force or enumeration | Rate limits on login, step-up and webhooks | `security.test.ts` "rate limits" |