@eloxiv/cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/AgentSkills.d.ts +51 -0
  4. package/dist/AgentSkills.d.ts.map +1 -0
  5. package/dist/AgentSkills.js +264 -0
  6. package/dist/AgentSkills.js.map +1 -0
  7. package/dist/AgentWeb.d.ts +83 -0
  8. package/dist/AgentWeb.d.ts.map +1 -0
  9. package/dist/AgentWeb.js +436 -0
  10. package/dist/AgentWeb.js.map +1 -0
  11. package/dist/App.d.ts +213 -0
  12. package/dist/App.d.ts.map +1 -0
  13. package/dist/App.js +357 -0
  14. package/dist/App.js.map +1 -0
  15. package/dist/Blueprint.d.ts +47 -0
  16. package/dist/Blueprint.d.ts.map +1 -0
  17. package/dist/Blueprint.js +241 -0
  18. package/dist/Blueprint.js.map +1 -0
  19. package/dist/Brand.d.ts +42 -0
  20. package/dist/Brand.d.ts.map +1 -0
  21. package/dist/Brand.js +370 -0
  22. package/dist/Brand.js.map +1 -0
  23. package/dist/Changelog.d.ts +22 -0
  24. package/dist/Changelog.d.ts.map +1 -0
  25. package/dist/Changelog.js +117 -0
  26. package/dist/Changelog.js.map +1 -0
  27. package/dist/Cli.d.ts +17 -0
  28. package/dist/Cli.d.ts.map +1 -0
  29. package/dist/Cli.js +810 -0
  30. package/dist/Cli.js.map +1 -0
  31. package/dist/DbAdmin.d.ts +18 -0
  32. package/dist/DbAdmin.d.ts.map +1 -0
  33. package/dist/DbAdmin.js +91 -0
  34. package/dist/DbAdmin.js.map +1 -0
  35. package/dist/Dependencies.d.ts +53 -0
  36. package/dist/Dependencies.d.ts.map +1 -0
  37. package/dist/Dependencies.js +132 -0
  38. package/dist/Dependencies.js.map +1 -0
  39. package/dist/Deploy.d.ts +39 -0
  40. package/dist/Deploy.d.ts.map +1 -0
  41. package/dist/Deploy.js +458 -0
  42. package/dist/Deploy.js.map +1 -0
  43. package/dist/Docs.d.ts +71 -0
  44. package/dist/Docs.d.ts.map +1 -0
  45. package/dist/Docs.js +240 -0
  46. package/dist/Docs.js.map +1 -0
  47. package/dist/Doctor.d.ts +56 -0
  48. package/dist/Doctor.d.ts.map +1 -0
  49. package/dist/Doctor.js +368 -0
  50. package/dist/Doctor.js.map +1 -0
  51. package/dist/Dossier.d.ts +23 -0
  52. package/dist/Dossier.d.ts.map +1 -0
  53. package/dist/Dossier.js +92 -0
  54. package/dist/Dossier.js.map +1 -0
  55. package/dist/Emit.d.ts +26 -0
  56. package/dist/Emit.d.ts.map +1 -0
  57. package/dist/Emit.js +51 -0
  58. package/dist/Emit.js.map +1 -0
  59. package/dist/Errors.d.ts +26 -0
  60. package/dist/Errors.d.ts.map +1 -0
  61. package/dist/Errors.js +17 -0
  62. package/dist/Errors.js.map +1 -0
  63. package/dist/Evals.d.ts +52 -0
  64. package/dist/Evals.d.ts.map +1 -0
  65. package/dist/Evals.js +126 -0
  66. package/dist/Evals.js.map +1 -0
  67. package/dist/Files.d.ts +47 -0
  68. package/dist/Files.d.ts.map +1 -0
  69. package/dist/Files.js +145 -0
  70. package/dist/Files.js.map +1 -0
  71. package/dist/Generate.d.ts +80 -0
  72. package/dist/Generate.d.ts.map +1 -0
  73. package/dist/Generate.js +310 -0
  74. package/dist/Generate.js.map +1 -0
  75. package/dist/Guards.d.ts +45 -0
  76. package/dist/Guards.d.ts.map +1 -0
  77. package/dist/Guards.js +530 -0
  78. package/dist/Guards.js.map +1 -0
  79. package/dist/Inspect.d.ts +125 -0
  80. package/dist/Inspect.d.ts.map +1 -0
  81. package/dist/Inspect.js +270 -0
  82. package/dist/Inspect.js.map +1 -0
  83. package/dist/Keychain.d.ts +57 -0
  84. package/dist/Keychain.d.ts.map +1 -0
  85. package/dist/Keychain.js +73 -0
  86. package/dist/Keychain.js.map +1 -0
  87. package/dist/Lock.d.ts +13 -0
  88. package/dist/Lock.d.ts.map +1 -0
  89. package/dist/Lock.js +145 -0
  90. package/dist/Lock.js.map +1 -0
  91. package/dist/Mcp.d.ts +91 -0
  92. package/dist/Mcp.d.ts.map +1 -0
  93. package/dist/Mcp.js +128 -0
  94. package/dist/Mcp.js.map +1 -0
  95. package/dist/Merge.d.ts +18 -0
  96. package/dist/Merge.d.ts.map +1 -0
  97. package/dist/Merge.js +43 -0
  98. package/dist/Merge.js.map +1 -0
  99. package/dist/Migrate.d.ts +78 -0
  100. package/dist/Migrate.d.ts.map +1 -0
  101. package/dist/Migrate.js +288 -0
  102. package/dist/Migrate.js.map +1 -0
  103. package/dist/Plugins.d.ts +36 -0
  104. package/dist/Plugins.d.ts.map +1 -0
  105. package/dist/Plugins.js +304 -0
  106. package/dist/Plugins.js.map +1 -0
  107. package/dist/Postgres.d.ts +73 -0
  108. package/dist/Postgres.d.ts.map +1 -0
  109. package/dist/Postgres.js +294 -0
  110. package/dist/Postgres.js.map +1 -0
  111. package/dist/Publish.d.ts +23 -0
  112. package/dist/Publish.d.ts.map +1 -0
  113. package/dist/Publish.js +59 -0
  114. package/dist/Publish.js.map +1 -0
  115. package/dist/Registry.d.ts +539 -0
  116. package/dist/Registry.d.ts.map +1 -0
  117. package/dist/Registry.js +340 -0
  118. package/dist/Registry.js.map +1 -0
  119. package/dist/Remote.d.ts +90 -0
  120. package/dist/Remote.d.ts.map +1 -0
  121. package/dist/Remote.js +1006 -0
  122. package/dist/Remote.js.map +1 -0
  123. package/dist/Run.d.ts +120 -0
  124. package/dist/Run.d.ts.map +1 -0
  125. package/dist/Run.js +477 -0
  126. package/dist/Run.js.map +1 -0
  127. package/dist/SyncGen.d.ts +118 -0
  128. package/dist/SyncGen.d.ts.map +1 -0
  129. package/dist/SyncGen.js +392 -0
  130. package/dist/SyncGen.js.map +1 -0
  131. package/dist/Update.d.ts +301 -0
  132. package/dist/Update.d.ts.map +1 -0
  133. package/dist/Update.js +627 -0
  134. package/dist/Update.js.map +1 -0
  135. package/dist/bin.d.ts +3 -0
  136. package/dist/bin.d.ts.map +1 -0
  137. package/dist/bin.js +42 -0
  138. package/dist/bin.js.map +1 -0
  139. package/dist/docs/backlog.md +56 -0
  140. package/dist/docs/ci.md +277 -0
  141. package/dist/docs/cli.md +696 -0
  142. package/dist/docs/connectors/google.md +115 -0
  143. package/dist/docs/connectors/http-openapi.md +7 -0
  144. package/dist/docs/connectors/mcp.md +8 -0
  145. package/dist/docs/connectors/microsoft-graph.md +75 -0
  146. package/dist/docs/connectors/openai.md +25 -0
  147. package/dist/docs/connectors/slack.md +162 -0
  148. package/dist/docs/connectors/workos.md +39 -0
  149. package/dist/docs/contracts/README.md +173 -0
  150. package/dist/docs/contracts/action-consent.md +92 -0
  151. package/dist/docs/contracts/action-registry.md +85 -0
  152. package/dist/docs/contracts/actor.md +100 -0
  153. package/dist/docs/contracts/agent-resources.md +90 -0
  154. package/dist/docs/contracts/agent-runtime.md +257 -0
  155. package/dist/docs/contracts/approvals.md +126 -0
  156. package/dist/docs/contracts/audit.md +75 -0
  157. package/dist/docs/contracts/auth-provider.md +74 -0
  158. package/dist/docs/contracts/calendar-provider.md +46 -0
  159. package/dist/docs/contracts/client-sdk.md +245 -0
  160. package/dist/docs/contracts/collab-document.md +151 -0
  161. package/dist/docs/contracts/command.md +44 -0
  162. package/dist/docs/contracts/connections.md +235 -0
  163. package/dist/docs/contracts/context-accounting.md +50 -0
  164. package/dist/docs/contracts/daemon.md +243 -0
  165. package/dist/docs/contracts/db-tx.md +53 -0
  166. package/dist/docs/contracts/delegation.md +68 -0
  167. package/dist/docs/contracts/device-control.md +103 -0
  168. package/dist/docs/contracts/directory-provider.md +36 -0
  169. package/dist/docs/contracts/directory.md +161 -0
  170. package/dist/docs/contracts/document-source.md +33 -0
  171. package/dist/docs/contracts/files.md +115 -0
  172. package/dist/docs/contracts/flags.md +83 -0
  173. package/dist/docs/contracts/host.md +68 -0
  174. package/dist/docs/contracts/http-api.md +43 -0
  175. package/dist/docs/contracts/ingestion.md +130 -0
  176. package/dist/docs/contracts/ingress.md +141 -0
  177. package/dist/docs/contracts/invocation.md +260 -0
  178. package/dist/docs/contracts/local-client.md +108 -0
  179. package/dist/docs/contracts/locale.md +56 -0
  180. package/dist/docs/contracts/machine-identity.md +117 -0
  181. package/dist/docs/contracts/mail-provider.md +49 -0
  182. package/dist/docs/contracts/memory.md +53 -0
  183. package/dist/docs/contracts/messaging.md +40 -0
  184. package/dist/docs/contracts/metering.md +139 -0
  185. package/dist/docs/contracts/model-provider.md +84 -0
  186. package/dist/docs/contracts/module-manifest.md +213 -0
  187. package/dist/docs/contracts/notification-channel.md +90 -0
  188. package/dist/docs/contracts/notifications.md +123 -0
  189. package/dist/docs/contracts/outbox.md +80 -0
  190. package/dist/docs/contracts/privacy.md +110 -0
  191. package/dist/docs/contracts/progress.md +52 -0
  192. package/dist/docs/contracts/query-surface.md +108 -0
  193. package/dist/docs/contracts/readiness.md +63 -0
  194. package/dist/docs/contracts/release.md +142 -0
  195. package/dist/docs/contracts/result-rendering.md +61 -0
  196. package/dist/docs/contracts/sandbox.md +186 -0
  197. package/dist/docs/contracts/scheduler.md +148 -0
  198. package/dist/docs/contracts/screen-context.md +81 -0
  199. package/dist/docs/contracts/search.md +120 -0
  200. package/dist/docs/contracts/secrets.md +74 -0
  201. package/dist/docs/contracts/settings.md +109 -0
  202. package/dist/docs/contracts/sharing.md +77 -0
  203. package/dist/docs/contracts/slot.md +48 -0
  204. package/dist/docs/contracts/space.md +67 -0
  205. package/dist/docs/contracts/storage-adapter.md +45 -0
  206. package/dist/docs/contracts/storage-backend.md +56 -0
  207. package/dist/docs/contracts/sync.md +213 -0
  208. package/dist/docs/contracts/telemetry.md +80 -0
  209. package/dist/docs/contracts/theme-tokens.md +50 -0
  210. package/dist/docs/contracts/tool-source.md +58 -0
  211. package/dist/docs/contracts/versioning.md +99 -0
  212. package/dist/docs/contracts/view.md +65 -0
  213. package/dist/docs/contracts/work-items.md +99 -0
  214. package/dist/docs/contracts/workflow.md +82 -0
  215. package/dist/docs/decisions.md +163 -0
  216. package/dist/docs/example-app.md +192 -0
  217. package/dist/docs/getting-started.md +927 -0
  218. package/dist/docs/goal.md +54 -0
  219. package/dist/docs/parity.md +29 -0
  220. package/dist/docs/performance.md +129 -0
  221. package/dist/docs/registry/README.md +74 -0
  222. package/dist/docs/registry/app.md +38 -0
  223. package/dist/docs/registry/approvals-ui-foldkit.md +28 -0
  224. package/dist/docs/registry/calendar-ui-foldkit.md +27 -0
  225. package/dist/docs/registry/calendar.md +35 -0
  226. package/dist/docs/registry/chat-ui-foldkit.md +30 -0
  227. package/dist/docs/registry/desktop-rune.md +49 -0
  228. package/dist/docs/registry/desktop.md +32 -0
  229. package/dist/docs/registry/eloxiv-action.md +25 -0
  230. package/dist/docs/registry/eloxiv-connector.md +25 -0
  231. package/dist/docs/registry/eloxiv-module.md +25 -0
  232. package/dist/docs/registry/eloxiv-policy.md +25 -0
  233. package/dist/docs/registry/eloxiv-view.md +25 -0
  234. package/dist/docs/registry/hello-ui-foldkit.md +29 -0
  235. package/dist/docs/registry/hello.md +39 -0
  236. package/dist/docs/registry/home-ui-foldkit.md +27 -0
  237. package/dist/docs/registry/home.md +29 -0
  238. package/dist/docs/registry/inbox-ui-foldkit.md +27 -0
  239. package/dist/docs/registry/mail-ui-foldkit.md +27 -0
  240. package/dist/docs/registry/mail.md +34 -0
  241. package/dist/docs/registry/meeting-prep.md +26 -0
  242. package/dist/docs/registry/members-ui-foldkit.md +28 -0
  243. package/dist/docs/registry/mobile.md +37 -0
  244. package/dist/docs/registry/notes-ui-foldkit.md +27 -0
  245. package/dist/docs/registry/notes.md +26 -0
  246. package/dist/docs/registry/people-ui-foldkit.md +28 -0
  247. package/dist/docs/registry/people.md +38 -0
  248. package/dist/docs/registry/shell-foldkit.md +34 -0
  249. package/dist/docs/registry/theme.md +25 -0
  250. package/dist/docs/registry/ui-conformance.md +30 -0
  251. package/dist/docs/release.md +100 -0
  252. package/dist/docs/scaffold.md +826 -0
  253. package/dist/docs/security/threat-model.md +299 -0
  254. package/dist/docs/upstream/zero-cache-socket-handoff.md +105 -0
  255. package/dist/index.d.ts +8 -0
  256. package/dist/index.d.ts.map +1 -0
  257. package/dist/index.js +8 -0
  258. package/dist/index.js.map +1 -0
  259. package/package.json +48 -3
  260. package/src/AgentSkills.ts +329 -0
  261. package/src/AgentWeb.ts +507 -0
  262. package/src/App.ts +435 -0
  263. package/src/Blueprint.ts +276 -0
  264. package/src/Brand.ts +415 -0
  265. package/src/Changelog.ts +136 -0
  266. package/src/Cli.ts +1458 -0
  267. package/src/DbAdmin.ts +115 -0
  268. package/src/Dependencies.ts +170 -0
  269. package/src/Deploy.ts +563 -0
  270. package/src/Docs.ts +309 -0
  271. package/src/Doctor.ts +424 -0
  272. package/src/Dossier.ts +148 -0
  273. package/src/Emit.ts +68 -0
  274. package/src/Errors.ts +18 -0
  275. package/src/Evals.ts +153 -0
  276. package/src/Files.ts +152 -0
  277. package/src/Generate.ts +402 -0
  278. package/src/Guards.ts +541 -0
  279. package/src/Inspect.ts +358 -0
  280. package/src/Keychain.ts +107 -0
  281. package/src/Lock.ts +174 -0
  282. package/src/Mcp.ts +159 -0
  283. package/src/Merge.ts +70 -0
  284. package/src/Migrate.ts +331 -0
  285. package/src/Plugins.ts +347 -0
  286. package/src/Postgres.ts +353 -0
  287. package/src/Publish.ts +64 -0
  288. package/src/Registry.ts +405 -0
  289. package/src/Remote.ts +1158 -0
  290. package/src/Run.ts +541 -0
  291. package/src/SyncGen.ts +570 -0
  292. package/src/Update.ts +873 -0
  293. package/src/bin.ts +46 -0
  294. package/src/index.ts +7 -0
@@ -0,0 +1,299 @@
1
+ # Eloxiv threat model
2
+
3
+ What an Eloxiv app has to protect, who might attack it and through which doors, and, for each threat that matters, the code that stops it and the test that proves it. It covers the eight areas of [goal.md](../goal.md) criterion 16: identity, policy, approval, MCP and OAuth, webhooks, the sandbox, the daemon and secrets. It is written for a developer building an app on Eloxiv and for the independent security review that follows; it is the review's starting map, not its verdict.
4
+
5
+ As of build/main `30868ff1` plus `build/guards` (2026-11-15). The identity, connections (endpoint Connections and outbound MCP) and device-control branches that were in flight when it was first written have merged, and their threats are mapped below (ID-15 to ID-20, SE-12 to SE-16, DM-12 to DM-14); see [Merged since the first version](#merged-since-the-first-version).
6
+
7
+ ## How to read this
8
+
9
+ Each area has a table. A row is one threat:
10
+
11
+ - **Id**: stable; other documents may cite it.
12
+ - **STRIDE**: S spoofing, T tampering, R repudiation, I information disclosure, D denial of service, E elevation of privilege.
13
+ - **Threat**: the attack, from a plausible attacker.
14
+ - **Mitigation**: where the code stops it.
15
+ - **Proof**: the test that would fail if the mitigation broke: its repository-relative file in backticks, then its exact title in curly quotes. A kit's test is cited at the kit (`packages/testing/src/conformance/<Name>.ts`), which a test file runs against the kernel. A threat without a test says why after `Limit:`.
16
+
17
+ The done gate checks the map: [`tools/done/test/threat-model.test.ts`](../../tools/done/test/threat-model.test.ts) fails if a cited file or test title does not exist, if a cited kit is run by no test file, or if a threat cites neither a test nor a limit. Rename a test and the gate names this file; add a threat and it must cite its proof.
18
+
19
+ Following the owner's direction on proportion, the map lists what a real user, operator or attacker would plausibly do, and anything that leaks data across people or organisations. Contrived setups (a hand-held database lock, a saturated pool, a precisely timed interleaving with no security consequence) are stated limits in the contracts and [backlog.md](../backlog.md), not rows here.
20
+
21
+ ## The system
22
+
23
+ One kernel process per deployment (Bun or Node) serves every surface over HTTP: Effect RPC (`/rpc`), HTTP actions (`/api/actions/*`), MCP (`/mcp`), Better Auth (`/auth/*`), the OAuth 2.1 server (`/oauth/*`), inbound webhooks (`/ingress/*`), Zero's query and push endpoints, device routes (`/kernel/devices/*`), the MAKE routes and kernel management (`/kernel/*`). Behind it are PostgreSQL (the source of truth; every module in its own schema with its own roles, under row-level security compiled from Cedar policy) and zero-cache (Node), which replicates each client's policy-scoped partial replica. Clients are the browser or Tauri shell through the client SDK, the CLI, external MCP clients, and the device daemon on a person's own machine, which runs agent turns on the person's Codex or Claude Code subscription and relays their tool calls back to the kernel. Outbound, the kernel calls providers (Google, Microsoft Graph, Slack, model providers) over Connections it holds in custody.
24
+
25
+ ## Assets
26
+
27
+ | Asset | Where it lives | Why it matters |
28
+ | --- | --- | --- |
29
+ | Organisation data | module schemas in PostgreSQL; each client's replica | the product: one organisation's or one person's records must never reach another |
30
+ | Directory | `eloxiv.organisation`, `membership`, roles, groups, permissions; `sync_fact` | decides who may do what, in the database and live in sync |
31
+ | Credentials of people | Better Auth sessions (cookie or bearer) | a stolen or forged session acts as the person |
32
+ | Credentials of agents and machines | agent sessions, API tokens, OAuth access and refresh tokens, device credentials, per-turn harness tokens | each acts for a person or a service principal within a scope |
33
+ | Provider grants | Connections' access and refresh tokens (custody adapter, Secrets by default) | act at Google, Microsoft or Slack as the person |
34
+ | Secrets | `eloxiv.secret` (envelope-encrypted), the key ring in configuration | API keys and tokens for modules and connectors |
35
+ | Pending decisions | business approval requests, consent requests, remembered permissions | each releases a held call when decided |
36
+ | Deferred work | schedules, workflows, agent runs, device turns, scheduled external effects | runs later, under the authority it was asked under |
37
+ | Audit trail | `eloxiv.audit_log` | who did what, for repudiation and incident response |
38
+ | Database privilege | the kernel role, module owner and runtime roles, setup's role, the recorded security state | a module or migration that escapes its role reaches everything |
39
+ | The person's machine | the daemon's state directory, its credential store, workspaces it runs harnesses in | a local attacker or a hostile web page could drive the person's own subscriptions and files |
40
+
41
+ ## Actors
42
+
43
+ | Actor | Trust | Reaches the kernel through |
44
+ | --- | --- | --- |
45
+ | Anonymous internet client | none | every public route: sign-in and sign-up, OAuth endpoints, `/mcp` (refused without a credential), webhooks, request bodies |
46
+ | Person (member of one or more organisations) | their policy, in the organisation they act in | shell, client SDK, CLI, MCP clients they authorise |
47
+ | Organisation administrator | the organisation's management permissions (`eloxiv.directory.manage` is the organisation's superuser) | the same surfaces, plus management operations |
48
+ | Another organisation's member | none in this organisation | the same surfaces, naming an organisation they do not belong to |
49
+ | Registry and app modules | trusted app code, in process (known gap 10 in [scaffold.md](../scaffold.md)): the boundary stops mistakes and SQL-level escapes, not hostile in-process code | handlers, subscribers, workflows, connectors, migrations |
50
+ | MAKE modules (made at runtime by a person or their agent) | untrusted code | the sandbox (QuickJS in WebAssembly) and a database session logged in as their own runtime role |
51
+ | The agent (one per person per organisation) | the person's policy, less: consent holds destructive calls, kernel governance is the person's own | agent tools in the kernel, its agent session over any surface; it reads untrusted text (records, messages, provider content), so it may be steered by prompt injection |
52
+ | External MCP clients | the person's policy, narrowed by the OAuth grant's scope, audience and organisation; origin `agent` | `/mcp` with an OAuth access token |
53
+ | Service principals and API tokens | their roles and the token's scope; never management operations or sync | HTTP actions, RPC, MCP |
54
+ | Paired devices (the daemon, headless runners) | the device's person (or service principal); only through the relay and device routes | `/kernel/devices/*` with the device credential; harness tokens on the daemon's loopback relay |
55
+ | Local processes and web pages on the person's machine | none | the daemon's loopback port |
56
+ | Webhook senders (Slack, GitHub, any configured source) | none until verified; then a delivery acts only as a linked identity or a declared service principal | `/ingress/<source>` |
57
+ | Providers answering the kernel | untrusted answers | responses to Connections' requests |
58
+ | Operators | the deployment's configuration and database administration | environment, setup, the database |
59
+
60
+ ## Trust boundaries
61
+
62
+ 1. **Network to kernel.** Every request is authenticated afresh from its credential (`Identity.authenticateCall`); the call's origin (`person`, `agent`, `system`) comes from the surface and credential, never from a header. Bodies are counted as they arrive and refused past their limit.
63
+ 2. **Kernel to database.** The kernel role is no superuser, bypasses no row-level security and reaches no module table; handlers run as their module's runtime role under row-level security generated from compiled Cedar policy; setup alone (its own role) changes schemas and records the security state.
64
+ 3. **Module to module.** Each module owns a schema and two roles; cross-module work goes only through actions, events, entity references and capability contracts.
65
+ 4. **Kernel code to module code.** Module code runs without the kernel's services (`asModuleCode`); kernel workflows and kernel modules are defined only in kernel source and frozen.
66
+ 5. **Trusted to untrusted code.** MAKE modules run in QuickJS with no ambient authority, on a database session logged in as their own runtime role; their views' code runs there too, and reaches the browser only as a view tree the shell draws in a frame where nothing runs or loads.
67
+ 6. **Person to agent.** An agent acts as the person, less: destructive calls wait for the person's consent, and consent and business approvals are the person's own decisions.
68
+ 7. **Now to later.** Deferred work carries an authority chain that `Authority.assert` checks inside the transaction that acts, so nothing outlives a revocation.
69
+ 8. **Kernel to client replica.** Sync applies the entity's compiled read filter, evaluates directory facts live in zero-cache, and scopes each replica to one person and organisation.
70
+ 9. **Machine to daemon.** The daemon listens on loopback, checks Host and Origin, and authenticates every local client; it holds the device credential and gives harnesses only per-turn tokens.
71
+ 10. **Kernel to providers and senders.** Webhooks are verified before they are stored; provider answers are classified by the capability contract; tokens go only to the origins a connector declares.
72
+
73
+ ## Cross-cutting mitigations
74
+
75
+ These carry most of the weight; the area tables cite them.
76
+
77
+ - **One invocation path** ([Invocation](../contracts/invocation.md), `packages/kernel/src/Invocation.ts`): every surface (typed client, HTTP, MCP, agent tools, CLI, scheduler, workflows, ingress) runs identity, policy, consent or business approval, idempotency, execution under row-level security, audit and outbox in that order. Proven across all eight surfaces by `packages/testing/test/surfaces-property.test.ts` “gives the same identity, policy result, approval, idempotency, audit record and outbox event on every surface, and hides what the caller cannot reach”.
78
+ - **Deferred authority** (`packages/kernel/src/Authority.ts`): an `Asserted` capability, made only by `Authority.assert` inside the acting transaction, is required by every API that touches protected data; `packages/kernel/test/authority-capability.test.ts` “is made only by Authority.assert: Authority.ts exports no way to construct it”.
79
+ - **Database-enforced isolation** (`packages/kernel/src/db/Bootstrap.ts`, `packages/kernel/src/policy/Rls.ts`, `packages/kernel/src/Release.ts`): module roles, forced row-level security, setup's refusals and the recorded security state; `registry/test/isolation-all.test.ts` “has PostgreSQL refuse each module's roles reading, writing and deleting every other module's tables”.
80
+ - **Fail closed**: a policy the compiler cannot translate denies; a credential, link or provenance that cannot be checked refuses.
81
+
82
+ ## 1. Identity
83
+
84
+ Entry points: Better Auth's routes behind the kernel (`packages/kernel/src/Identity.ts`, `packages/kernel/src/AuthSeam.ts`), the cookie guard (`packages/kernel/src/surfaces/CookieGuard.ts`), credential resolution for every surface (`Identity.authenticateCall`), agent sessions, the client address (`packages/kernel/src/machine/MachineIdentity.ts`), sign-out and session revocation.
85
+
86
+ | Id | STRIDE | Threat | Mitigation | Proof |
87
+ | --- | --- | --- | --- | --- |
88
+ | ID-1 | S | A request with no credential, or one that is not a member of the organisation it names, acts | `Identity.authenticateCall` resolves the bearer or cookie afresh on every call to exactly one actor and membership; non-members are refused | `packages/testing/src/conformance/Actor.ts` “refuses requests without a session”; `packages/testing/src/conformance/Actor.ts` “refuses a signed-in user who is not a member of the organisation”; `registry/test/surfaces.test.ts` “rejects unauthenticated calls on every surface and audits the denial” |
89
+ | ID-2 | E | A member acts in another organisation, or with another organisation's directory, by naming it | the organisation comes from `x-eloxiv-org` but the membership, roles, groups and permissions are read for that organisation only | `packages/testing/src/conformance/Actor.ts` “acts in the organisation the request names, with only that organisation's directory”; `packages/testing/src/conformance/Invocation.ts` “refuses to act in an organisation the caller does not belong to” |
90
+ | ID-3 | S | A forged cross-site request rides the person's session cookie (CSRF), including through a GET that writes or a route added later | the cookie guard refuses cookie-authenticated state changes without a trusted origin, fitting Fetch Metadata and the route's body type; every route the router registers is classified, and an unlisted one is refused | `packages/testing/test/cookie-guard.test.ts` “refuses a forged cookie request on every listed route, and on a route the kernel does not have”; `packages/testing/test/cookie-guard.test.ts` “lists every state-changing route the kernel's router registers, so a new one is classified”; `packages/testing/test/cookie-guard.test.ts` “changes nothing on a forged GET to a route that writes: no protection, no write” |
91
+ | ID-4 | S | Password guessing against sign-in, through Better Auth or the OAuth sign-in page, with a spoofed address per guess | Better Auth's limiter on in every environment, counts in the database, one bucket for both endpoints, keyed on the address the kernel states (the peer, or what a trusted proxy appended), never `x-forwarded-for` as sent | `packages/testing/test/sign-in-limit.test.ts` “counts both endpoints in one bucket”; `packages/testing/test/sign-in-limit.test.ts` “does not let a client choose its address with x-forwarded-for or the kernel's own header”; `packages/testing/test/sign-in-limit.test.ts` “shares one budget between kernel processes on the same database”; `packages/kernel/test/client-address.test.ts` “is the peer without a trusted proxy, whatever x-forwarded-for says” |
92
+ | ID-5 | T | An agent's call is passed off as the person's (to escape consent) by a header | origin and agent session are decided from the surface and credential alone | `packages/testing/src/conformance/ActionConsent.ts` “decides origin and session from the credential and surface, never from a header”; `packages/testing/test/credentials.test.ts` “gives a person's session and their agent session the same actor; only the agent session is an agent's” |
93
+ | ID-6 | E | An agent session, API token or OAuth token manages the directory, machine identities, secrets or devices, or opens sync | management operations and sync accept only a signed-in person (`machine/Managed.ts` authenticates the session) | `packages/testing/test/credentials.test.ts` “refuses an agent session for management operations and sync, which need a signed-in person” |
94
+ | ID-7 | E | A signed-out or revoked session keeps working: a call resolved before the sign-out commits after it, a replica keeps syncing, a stream keeps delivering | sign-out waits (within a bound) for work holding the session, then revokes; every call asserts the session inside its transaction; sync's session fact is removed live; streams check the session per delivery | `packages/testing/test/session-authority.test.ts` “refuses an action whose person was resolved before a sign-out that committed before its assertion”; `packages/testing/test/sync-revocation.test.ts` “a signed-out session's replica receives nothing more once the sign-out replicates, long before any revalidation”; `packages/testing/test/session-commit.test.ts` “delivers nothing on a run's stream once its session expired during the delivery (Sol: SSE events after expiry)”; `e2e/sign-out.spec.ts` “a session revoked elsewhere ends the shell's: the next write is refused, the rows go, and sign-in shows why” |
95
+ | ID-8 | I | Another session's raw token leaks through Better Auth's session listing | the kernel strips tokens from list-sessions and lists nothing for a revoked session | `packages/testing/test/auth-seam.test.ts` “lists no session's token, and a revoked session still held lists nothing (Sol: its other sessions' raw tokens)” |
96
+ | ID-9 | S | A cookie written in a syntax one parser reads differently from another lets a revoked session through, or makes sign-out report success for a session that still works | one cookie parser, Better Auth's own (better-call's), used only by the auth provider and the cookie guard; a person's credential resolved at one call site (`provider.resolve` in `resolvePerson`) | `packages/kernel/test/identity-resolution.test.ts` “is parsed only by the provider and the cookie guard”; `packages/testing/test/auth-seam.test.ts` “resolves a credential as Better Auth does, whatever the cookie's syntax: sign-out never says it ended a session that still works (Sol: a quoted cookie)” |
97
+ | ID-10 | R | An unauthenticated or refused call leaves no record; or an anonymous flood fills the audit log | every failure that reaches `invoke` is audited once; refusals of callers not identified are bounded per address and route | `registry/test/surfaces.test.ts` “rejects invalid input on every surface and audits each rejection”; `packages/testing/test/session-commit.test.ts` “bounds every record of a caller it cannot identify, on every route the kernel registers, whatever the outcome (Sol: InvalidInput wrote 8 of a bound of 2)” |
98
+ | ID-11 | D | A large or never-ending request body exhausts memory or holds connections | bodies counted as they arrive, refused at the first byte past the route's limit (4 MiB, 16 KiB for OAuth, 64 KiB for management); slow bodies answered 408; idle connections closed | `packages/testing/test/request-limits.test.ts` “refuses a body past its limit while it is still being sent, on every route that takes one from anyone”; `packages/testing/test/ingress.test.ts` “answers 408 to a sender that does not finish its body within the deadline” |
99
+ | ID-12 | S | An unverified sign-in email links an account to a person record (claiming someone's People record) | `people.claim` requires `emailVerified`, read afresh with every call | `registry/test/people.test.ts` “refuses a claim by an unverified sign-in email, and matches a verified one whatever its case” |
100
+ | ID-13 | S | A policy on `principal.email` trusts an address the account never proved (sign-up is open, so a member's address is whatever they signed up with) | only a verified address is identity: policy compiles `principal.email` as no address for an account that has not verified it (`policy/Policy.ts`), `people.claim` needs a verified one (ID-12), and a deployment can refuse a session until the address is verified | `packages/testing/test/verified-email-policy.test.ts` “gives an unverified sign-up with someone else's address nothing that address is granted”; `packages/testing/test/account-security.test.ts` “gives no session to an unverified address, and verifies one that receives its mail” |
101
+ | ID-14 | I | Someone who can read the database (a leaked backup, an operator) takes over signed-in people with the session tokens in it | the store keeps each session token's SHA-256 digest only (`auth/SessionTokens.ts`: Better Auth's statements rewritten to store and match digests, every provider through `storedToken`; kernel migration `0246_hashed_session_tokens` digested the sessions stored before), and a digest presented as a credential names no session (Better Auth's provider refuses it in `resolve`, before Better Auth reads it); the kernel's own credentials were hashed already (MO-8) | `packages/testing/test/session-tokens.test.ts` “keeps only a digest: a token read from the database does not authenticate, the token itself does”; `packages/testing/test/session-tokens.test.ts` “digests the sessions stored before in place, which keep working, and changes nothing when applied again” |
102
+ | ID-15 | S | Someone takes an invitation meant for another person, or an administrator adds an account registered first with the invitee's address | an invitation admits only its own address, once that address is verified, once; an administrator adds only an account that verified its address | `packages/testing/test/directory-admin.test.ts` “admits an invitation's own verified address once, and nobody else”; `packages/testing/test/member-admin-routes.test.ts` “never adds an account that has not verified the address, through the member route or Directory administration” |
103
+ | ID-16 | S | Anyone with an address at a domain joins an organisation that never proved the domain | a domain admits verified addresses only once DNS proves the organisation holds it, for that one organisation, when it says so | `packages/testing/test/directory-admin.test.ts` “admits a verified address at a domain only once DNS proves it, for one organisation, when it says so” |
104
+ | ID-17 | S/I | A password reset taken over, or used to learn which addresses have accounts | the reset only through the mailed link, which ends every session; the answer is the same, and as fast, for an unknown address | `packages/testing/test/account-security.test.ts` “resets a password through the mailed link only, ends every session, and answers alike for no account”; `packages/testing/test/account-security.test.ts` “answers a reset request before its mail is sent, so a known address answers as fast as an unknown one” |
105
+ | ID-18 | S | An account's address moved to one its owner does not hold (taking over what the address grants) | a change needs the current address's confirmation and a verification of the new one | `packages/testing/test/account-security.test.ts` “changes an address only once the current address confirms it and the new one is verified” |
106
+ | ID-19 | S | A provider sign-in joins an account registered with someone else's address, or signs up an address the provider did not verify | a provider joins an existing account only when both it and the account verified the address; an unverified provider address gets no session | `packages/testing/test/account-security.test.ts` “joins an existing account only when both the provider and the account verified the address”; `packages/testing/test/account-security.test.ts` “gives no session to a new person whose address the provider did not verify” |
107
+ | ID-20 | S | Two-factor authentication bypassed with the password alone, or its code guessed | a session needs a code or a backup code (each backup once); a challenge refuses even the right code after a few wrong ones | `packages/testing/test/account-security.test.ts` “with two-factor enabled gives a session for a code or a backup code (once), never for the password alone”; `packages/testing/test/account-security.test.ts` “refuses even the right code once a challenge has had a few wrong ones” |
108
+ | ID-21 | S | An SSO sign-in lands someone in an organisation that is not theirs: another organisation's identity provider, an unverified or unclaimed domain, an organisation that never turned SSO on, a flow started in another browser (login CSRF), or a WorkOS organisation linked by an organisation that does not own its domains | the address's domain must be one the organisation verified, with SSO on; WorkOS's profile must be of the organisation's own WorkOS organisation; the flow's state is bound to the browser that started it (cookie, hashed, single use); linking needs every domain WorkOS verified for the WorkOS organisation to be verified by the organisation; the session is issued under the credential fence as `sso:<connection>` and only where the organisation's methods admit it | `packages/testing/test/enterprise-auth.test.ts` “refuses an unverified domain, an organisation without SSO, another WorkOS organisation's profile, and a flow this browser did not start”; `packages/testing/test/enterprise-auth.test.ts` “links only a WorkOS organisation whose verified domains this organisation verified” |
109
+ | ID-22 | T | A forged, replayed or out-of-order Directory Sync event adds someone to an organisation, or brings back a deprovisioned person | each event's `WorkOS-Signature` (HMAC-SHA256 under the webhook secret over the raw body, three minutes' tolerance) is verified before it is read; each event applies once (`eloxiv.directory_event`, recorded with its changes in one transaction), never over a newer version of its resource (versions and tombstones, `eloxiv.directory_resource`); a person is provisioned only at a domain the organisation verified; deprovisioning ends their sessions | `packages/testing/test/enterprise-auth.test.ts` “refuses an event whose signature does not verify, and a replayed event changes nothing”; `packages/testing/test/enterprise-auth.test.ts` “refuses a Directory Sync event older than what the organisation applied: a stale active update restores nothing”; `packages/testing/test/enterprise-auth.test.ts` “creates a member, keeps their groups, and deactivation removes them and ends their sessions” |
110
+ | ID-23 | S | An agent, an API token or a device registers an app installation for the person, so their notifications (and decision tokens) go to a device the person does not hold | `notifications.registerInstallation` serves only a person's own signed-in session (origin person, credential a session); agents on every surface and agent sessions refused (`packages/kernel/src/notifications/Push.ts`) | `packages/testing/src/conformance/Push.ts` “refuses an agent registering for the person, on the agent surfaces and with an agent session” |
111
+ | ID-24 | I | A device signed out of the app, reassigned to another person, or of a person erased or no longer a member, keeps receiving their notifications (also a send queued before the change) | an installation is bound to the session that registered it: the session's deletion or revocation deletes it (triggers, migration 0250); each send is claimed just before it goes to the provider, reading the installation again (the recipient's, the same registration generation, its session valid and not revoked, the recipient still a member of the organisation), so a change committed before the claim stops it; erasure deletes every installation. Limit (accepted): a message the provider already accepted is past the kernel's reach, and so is the interval between a send's claim and the start of its provider request (a cold FCM send can spend it fetching an access token): a sign-out, reassignment or membership change committed in that interval does not stop that one send | `packages/testing/src/conformance/Push.ts` “removes what a session registered when it signs out, and only that”; `packages/testing/src/conformance/Push.ts` “erases every installation of the person”; `packages/testing/src/conformance/Push.ts` “sends nothing to an installation signed out while the delivery's earlier sends waited”; `packages/testing/src/conformance/Push.ts` “sends nothing once the recipient left the organisation, also on a retry” |
112
+ | ID-25 | T | A provider's dead-token answer, or another registration, removes or takes over an unrelated fresh installation | a dead token invalidates only the registration it was sent to (its generation), and an APNs `410` only when APNs's `timestamp` is newer than that registration (dated by its write, after its lock waits, a first registration too); a token is in one installation at a time (the latest registration), registrations of one token serialised (an advisory lock on the provider and the token's digest). Limit: someone who learns another person's device token can register it to themselves, so that device gets their notifications instead until its app registers again (a device token is the device's, and APNs and FCM tokens are not guessable) | `packages/testing/src/conformance/Push.ts` “leaves an installation alone when its token changed while the provider called the old one dead”; `packages/testing/src/conformance/Push.ts` “ignores a dead-token answer about an older registration of the token”; `packages/testing/src/conformance/Push.ts` “dates a first registration that waited for a lock by its write, not by when it began”; `packages/testing/src/conformance/Push.ts` “moves a token to whoever registers it last: it is in one installation at a time”; `packages/testing/src/conformance/Push.ts` “gives a token many people register at once to exactly one installation, every registration succeeding”; `packages/testing/src/conformance/Push.ts` “lets a 410 without a usable timestamp invalidate only the registration it was sent to” |
113
+ | ID-26 | I | The FCM service account's signed assertion, a device token or a decision token reaches a host the deployment did not configure (a redirect from the token endpoint or from `messages:send`) | neither FCM request follows a redirect (`redirect: "error"`): a redirect is a configuration failure, retried; APNs's client makes no redirects (HTTP/2 to the configured origin) | `packages/testing/test/push-providers.test.ts` “refuses to follow a redirect from the token endpoint or messages:send: neither the assertion nor the message leaves” |
114
+ | ID-27 | I | A provider's or a gateway's free-form error text (echoing a device token) reaches the delivery records, the outbox or a summary | an answer records only the kernel's own text: a provider's documented code or the HTTP status, never the provider's text, a transport's or the database's message (`notifications/Providers.ts`) | `packages/testing/src/conformance/Push.ts` “keeps provider-supplied text out of the delivery records”; `packages/testing/test/push-providers.test.ts` “records FCM's codes only as the kernel's own constants”; `packages/testing/test/push-providers.test.ts` “records APNs's reasons only as the kernel's own constants” |
115
+ | ID-28 | T | A send whose answer was lost (a timeout, a crash between the request and its record) is sent again and the person sees the notification twice | each send is recorded (`sending`) before the provider is called and its answer after, so an installation that accepted or was refused is never sent again; APNs collapses copies by `apns-collapse-id` (the notification's id); an FCM copy replaces a visible one by its `tag` (the notification's id), and the Expo host presents a notification id once while it runs. There is no FCM collapse key: FCM keeps four per offline device, so a key per notification would drop distinct requests. Limit (accepted): delivery is at least once; on Android in the background the notification library draws a data message natively, so a resend after the person dismissed the first copy shows again | `packages/testing/src/conformance/Push.ts` “records each send before the provider answers it”; `packages/testing/src/conformance/Push.ts` “retries an installation that failed without sending again to one that accepted”; `packages/testing/test/push-providers.test.ts` “keeps distinct FCM notifications apart: no collapse key, only the notification's own tag”; `registry/test/mobile-host.test.ts` “presents a notification id once, and every other one” |
116
+ | ID-29 | I | The mobile app's session lands on disk outside secure storage (the auth provider's cookie from a sign-in or a second factor, kept in Android's persistent cookie store), or a password, session or decision token travels over plain HTTP | every request of the Expo host omits cookies (`registry/app/mobile/src/transport.ts`; Expo 58's native fetch then neither sends nor stores them, on Android and iOS), in the app's process only, so web cookie sign-in is unchanged; a release build refuses a non-HTTPS kernel or Zero URL and allows no Android cleartext; a development build may use plain HTTP, and a build bundled for a local test run (`EXPO_PUBLIC_ELOXIV_ALLOW_HTTP=1`) only to loopback and emulator hosts (127.0.0.1, ::1, localhost, 10.0.2.2), Android cleartext scoped to exactly those hosts by a network security config (`registry/app/mobile/app.config.js`); no request follows a redirect unless it asks to, so none takes a credential outside this policy. Limit: `10.0.2.2` is the host machine only inside the Android emulator; a build bundled with `EXPO_PUBLIC_ELOXIV_ALLOW_HTTP=1` and installed on a physical device would send credentials over plain HTTP to whatever machine on the local network holds that address. The flag is for local test builds (CI's emulator lanes) only, never set in a normal release build ([mobile](../registry/mobile.md#guarantees-and-limits)) | `registry/test/mobile-host.test.ts` “omits cookies on every request unless one asks for them”; `registry/test/mobile-host.test.ts` “refuses plain HTTP servers in a release build; a test build reaches only loopback and emulator hosts over it”; `registry/test/mobile-host.test.ts` “refuses redirects unless a request asks to follow them”; `registry/test/mobile-host.test.ts` “allows Android cleartext only in a build bundled for a local test run, and only to loopback and emulator hosts”; `registry/test/mobile-host.test.ts` “sends the notification's token and the verdict pressed, with no session, and reads the outcome” |
117
+ | ID-30 | I | An offline start (the client core opening a replica from disk while the kernel cannot be reached to check the stored session) shows another person's or organisation's rows, or keeps a revoked session's replica open | the context is remembered with the token it was open with and recalled only for that token (`SessionStore.recall`; the Expo host's secure store forgets it with the session, when another token is saved and after a reinstall); only that person's replica of that organisation opens, never for a token a sign-out left pending or when the revocation store cannot be read; the check goes on, and a token the kernel refuses (on the check, late after the launch's bounded check, or with a 401 on the organisation listing) tears the context down as any refused session: views destroyed and the replica closed first, never waiting for the store, then the session and its context forgotten, retried until the store succeeds, and the token is never reopened again in this process; a sign-out while offline forgets the context, revokes the offline start's token even when the slot cannot be read, and keeps a confirmed revocation until the session or its context is forgotten; another person signing in closes the first person's context before their organisations are listed. Limit: until the kernel answers, rows already on the device show for a session that may have been revoked elsewhere meanwhile (as they would to the same person going offline while running); nothing new reaches them. Limit (accepted): a refusal leaves no durable record when the secure store can neither clear the session nor forget its context, so a restart of the app can reopen that context offline until the kernel is reached and refuses the token again | `packages/testing/test/client-runtime-offline.test.ts` “opens nothing for another token, a store that remembers nothing, or a token a sign-out left pending”; `packages/testing/test/client-runtime-offline.test.ts` “tears everything down when the kernel refuses the session on reconnect”; `packages/testing/test/client-runtime-offline.test.ts` “forgets the remembered context with the session when the person signs out offline”; `packages/testing/test/client-runtime-offline.test.ts` “opens the remembered replica after a short deadline when the connection stalls, and tears it down on a late refusal”; `packages/testing/test/client-runtime-offline.test.ts` “closes the replica on a refusal while the store stalls, and cleans the store up afterwards”; `packages/testing/test/client-runtime-offline.test.ts` “never reopens a refused token in this process when the store can neither clear it nor forget its context”; `packages/testing/test/client-runtime-offline.test.ts` “closes an offline start's context at once when another person signs in, before their organisations are listed”; `registry/test/mobile-host.test.ts` “remembers the context last open with the session, recalls it only for that token, and forgets it with it” |
118
+
119
+ ## 2. Policy
120
+
121
+ Entry points: the Cedar compiler (`packages/kernel/src/policy/Compiler.ts`) into SQL, row-level security (`policy/Rls.ts`) and sync's Zero conditions (`packages/kernel/src/Sync.ts`); the action contract checks in `Invocation.ts`; replay receipts; the query surface (`packages/kernel/src/QuerySurface.ts`, `packages/kernel/src/db/QueryViewCheck.ts`); setup's hardening (`packages/kernel/src/Release.ts`, `packages/kernel/src/db/Bootstrap.ts`).
122
+
123
+ | Id | STRIDE | Threat | Mitigation | Proof |
124
+ | --- | --- | --- | --- | --- |
125
+ | PO-1 | E | The compiled SQL filter admits more than the Cedar policy says (a construct compiled loosely) | typed compilation with Cedar's semantics; anything outside the supported subset fails closed; differential tests against Cedar | `packages/testing/test/policy-sql.test.ts` “selects exactly the records Cedar authorises (actor-bound)”; `packages/testing/test/policy-sql.test.ts` “selects exactly the records Cedar authorises in the symbolic (row-level security) form, from the live directory”; `packages/testing/test/policy.test.ts` “filters reads with the same policy: the compiled filter and Postgres row-level security agree” |
126
+ | PO-2 | E | An unconstrained permit for one action, or a read policy, reaches records not tied to the actor (another organisation's) | an action's filter reaches only the entities it declares; startup refuses a policy that reaches records not tied to the actor unless `organisationWide`, which confines it to the acting organisation | `packages/testing/test/action-scope.test.ts` “compiles an action's filter to FALSE on every table it does not declare”; `packages/testing/test/action-scope.test.ts` “refuses a read policy that admits records not tied to the reader”; `packages/testing/test/action-scope.test.ts` “confines an organisation-wide action to the acting organisation” |
127
+ | PO-3 | T | A handler writes beyond its target: another readable record through `UPDATE ... FROM`, a CTE or an upsert; an ownership change; a passing-shaped rewrite; a key moved onto the target | exact targets locked and authorised before the handler; row-level security on old and new rows; the write log checked against the contract; primary keys immutable | `packages/testing/src/conformance/Invocation.ts` “fails a targeted action that affects more than its target, and rolls it back”; `packages/testing/src/conformance/Invocation.ts` “denies an action that would change ownership of someone else's record”; `packages/testing/src/conformance/Invocation.ts` “does not let a side-effect update rewrite another record into a passing shape”; `packages/testing/src/conformance/Invocation.ts` “does not let an action move another record onto its target's key” |
128
+ | PO-4 | E | A handler leaves its module's role (`SET ROLE`, `RESET ROLE`), truncates, installs a deferred trigger, or passes through a forbidden state and restores it | the runtime role has plain DML only; the kernel checks the role afterwards; row-level security refuses the statement | `packages/testing/src/conformance/DbTx.ts` “may not leave the module's role: the call fails as Forbidden and is rolled back”; `packages/testing/src/conformance/DbTx.ts` “may not pass through a forbidden state: row-level security refuses the statement, even if restored”; `packages/testing/src/conformance/DbTx.ts` “may not install a deferred trigger that would run after authorisation” |
129
+ | PO-5 | I | A module reads or writes another module's tables, the kernel's or Better Auth's | one schema and two roles per module; nothing granted across; the isolation matrix over every module and every kind of object | `registry/test/isolation-all.test.ts` “has PostgreSQL refuse each module's roles reading, writing and deleting every other module's tables”; `packages/testing/src/conformance/DbTx.ts` “denies module roles the kernel's tables and the auth tables”; `registry/test/module-boundary.test.ts` “is refused any other way: the table hello's reference names is out of reach of notes' handlers” |
130
+ | PO-6 | E | A migration escalates: `RESET ROLE` back to setup's session, a cast or temporary catalogue view that hides a role switch, a forged logical-replication message, a schema or name the kernel owns | each module migrates on a session logged in as its owner role; setup's checks read `pg_catalog.*` with `pg_temp` last and run again on setup's session; dangerous catalogue functions revoked from PUBLIC; reserved schemas and names refused | `packages/testing/test/migration-session.test.ts` “runs as an owner role with no privileged attribute or membership, which cannot log in after setup”; `packages/testing/test/migration-session.test.ts` “refuses the cast a temporary pg_cast view hides”; `packages/testing/test/catalog-privileges.test.ts` “refuses a migration that emits a logical message, and records nothing”; `packages/testing/test/module-identity.test.ts` “refuses a module whose schema already exists under another owner, and leaves it as it was”; `packages/testing/src/conformance/Release.ts` “leaves no escalation behind when a migration becomes the superuser and returns to its role” |
131
+ | PO-7 | T | Someone with database access weakens the hardening (disables row-level security, grants across modules, replaces a kernel function) and the app keeps serving | every setup compares the live security state with the recorded one, repairs module drift or refuses, and refuses kernel-schema changes; Readiness reports not ready | `packages/testing/src/conformance/Release.ts` “reports a kernel function changed outside setup as insecure, and setup refuses it”; `packages/testing/test/kernel-state.test.ts` “cannot be removed by the kernel role to hide a change it made” |
132
+ | PO-8 | I | A replay of an idempotent call returns what the caller may no longer read (a revoked grant, a new forbid, a removed member) | replays return a receipt of the call's own effects, never cached output; identity and policy re-checked before release | `packages/testing/src/conformance/Invocation.ts` “returns only the receipt after the sharing grant that allowed the original call is revoked”; `packages/testing/src/conformance/Invocation.ts` “refuses a receipt to a caller who is no longer a member of the organisation”; `packages/testing/src/conformance/Invocation.ts` “does not conflict or replay across organisations” |
133
+ | PO-9 | I | A replica receives rows the person may not read: another organisation's, a related table no entity governs, a child whose grant was revoked, rows after a directory change | sync adds the entity's compiled read filter, per user and organisation; child queries carry their own entity's filter; directory facts evaluated live in zero-cache | `packages/testing/src/conformance/Sync.ts` “scopes per user and organisation: the organisation the client names, and no other”; `packages/testing/src/conformance/Sync.ts` “refuses a query that returns related rows of a table no entity governs”; `packages/testing/test/sync-revocation.test.ts` “removing a group membership stops new and existing rows the group granted (the review's case)”; `registry/test/sync.test.ts` “never exposes a private greeting's content through any readable projection” |
134
+ | PO-10 | E | A sharing grant reaches beyond its record's organisation, or answers for someone other than the acting principal | grants count only in the record's organisation and only for the caller (`eloxiv_ctx.has_grant` takes no grantee) | `packages/testing/test/policy-sql.test.ts` “answers a grant check only for the acting principal, never for another grantee”; `packages/testing/src/conformance/Sharing.ts` “a grant counts only while acting in the record's organisation, whoever made it and wherever”; `packages/testing/src/conformance/Sharing.ts` “a link: its token returned once and never listed, held by members who redeem it, until revoked” |
135
+ | PO-11 | I | The agent's read-only SQL (the query surface) or a published view escapes its filter: a function called by a quoted name, a cast that switches role, a helper view, a second statement | one SELECT parsed by PostgreSQL's grammar and checked against the analysed tree; views read only the module's tables with allowlisted built-ins and types; read as a role that sees only the surface's views | `packages/testing/test/query-view-escape.test.ts` “refuses the review's view at startup, and nothing returns another organisation's data”; `packages/testing/test/query-view-types.test.ts` “refuses the review's helper view at setup, and nothing returns another organisation's data”; `packages/testing/src/conformance/QuerySurface.ts` “gives each person exactly their authorised rows, the same rows sync gives them” |
136
+ | PO-12 | E | An agent reaches an action the policy hides, or one in a tool group the app disabled, on some surface | `Invocation.reach` decides listings; the invocation path refuses agent-originated calls to disabled groups on every surface | `packages/testing/test/surfaces-property.test.ts` “says why an agent's call to an action of a disabled tool group is refused, on any surface”; `registry/test/mcp-oauth.test.ts` “lists only the actions the policy lets the person reach, and refuses (and audits) a call to a hidden one” |
137
+ | PO-13 | E | Module code reaches kernel services or defines kernel code (a handler running as the kernel, a kernel workflow, a frozen module replaced) | module code runs without the kernel's services; kernel workflows and modules are recorded in kernel-only source and frozen | `packages/testing/test/kernel-boundary.test.ts` “none of them saw a kernel service, the database client or the HTTP request”; `packages/testing/test/kernel-boundary.test.ts` “offers registry and app code no way to define kernel code: none of the privileged constructors is public”; `packages/testing/test/workflow-trust.test.ts` “exports no way to define, recognise or reach a kernel workflow” |
138
+ | PO-14 | I | Constraint outcomes reveal unreadable records (a unique value, a referencing child, a caller-chosen key, a reference to an unreadable parent) | one rule, failing closed: a write's outcome may not depend on a record the caller cannot read. References are guarded (`eloxiv.guard_reference`: a missing and an unreadable record are refused alike, before the referential check); setup refuses unique keys a writer could meet unreadable records on (the kernel's own modules exempt); key changes and exact actions' undeclared inserts are refused before constraints run. For every action kind, secondary entities and MAKE modules | `packages/testing/src/conformance/Invocation.ts` “refuses an undeclared insert the same way whether or not an unreadable record holds the key”; `packages/testing/src/conformance/Invocation.ts` “refuses a reference to a record the caller cannot read the same way as one to a record that does not exist”; `packages/testing/test/setup.test.ts` “refuses a unique key whose conflicts would disclose records a writer cannot read, and accepts one confined to readable records”. Limits: a key the caller names in an untargeted or best-effort insert discloses whether a record holds it (closing it needs keys namespaced per caller, `recordKey`); deleting a record another references fails while the reference exists, readable or not, and says only that (`packages/testing/src/conformance/Invocation.ts` “refuses deleting a referenced record the same way whether or not the caller can read the reference (the stated limit)”) (scaffold known gap 11) |
139
+ | PO-15 | E | Hostile code inside a registry or app module (`RESET ROLE` on the kernel's connection, its own connections) | none by design: registry and app modules are the app's trusted code; untrusted code runs as MAKE modules | Limit: scaffold known gap 10; backlog 3 (resolved for untrusted code by the sandbox, area 6) |
140
+ | PO-16 | T | A module's own optimistic prediction (`optimistic.custom()`) changes what the replica shows beyond its action: it writes another module's or the kernel's synced table (a share grant, a notification), runs on the server, or leaves part of a failed prediction behind | the prediction's transaction holds only the synced tables of the entities its action declares (`writes`, `target`, `actsOn`), in its type and at run time; one that writes any other table, or throws, is rolled back whole and nothing is sent (the write rejects with `ActionFailed`); the kernel never runs it (a push runs the action's handler through the invocation path), the replica's read scope is unchanged, and the server's answer replaces it | `packages/testing/test/optimistic.test.ts` “refuses a prediction that writes a table its action does not declare, or throws: nothing stays, nothing is sent”; `packages/testing/test/optimistic.test.ts` “rolls a refused prediction back with the typed error”; `packages/testing/test/predictions.test.ts` “gives the prediction only its declared tables to write, in its type” |
141
+
142
+ ## 3. Approval
143
+
144
+ Two mechanisms: **consent** (`packages/kernel/src/inbox/consent.ts`, the Approvals stage in `packages/kernel/src/Approvals.ts`), the person's approval of what their agent does; and **business approval** (`packages/kernel/src/inbox/approvals.ts`, the `eloxiv.approval` workflow in `packages/kernel/src/inbox/Flow.ts`), an approver's decision on another person's call. Both raise work items and notifications, and both carry the call's authority chain.
145
+
146
+ | Id | STRIDE | Threat | Mitigation | Proof |
147
+ | --- | --- | --- | --- | --- |
148
+ | AP-1 | E | An agent (steered by text it read) makes a destructive call without the person | consent-marked actions (by default the destructive ones) hold an agent's call until the person approves its exact input | `packages/testing/src/conformance/ActionConsent.ts` “holds an agent's call, bound to its exact input, with a work item and a notification for the person”; `packages/testing/src/conformance/ActionConsent.ts` “runs the exact approved call once when the agent retries it; other input is held again”; `packages/testing/src/conformance/AgentRuntime.ts` “holds a destructive tool call for the person's consent, then resumes the run once approved” |
149
+ | AP-2 | E | The agent decides consent for itself | consent actions refuse agent-originated calls on every surface | `packages/testing/src/conformance/ActionConsent.ts` “never lets an agent decide consent for the person, on any surface” |
150
+ | AP-3 | E | The agent approves a business approval for the person it acts for, so a request's input (or any record it reads) can talk it into running another person's call | `approvals.approve` refuses agent-originated calls before reading the request; rejecting stays open (it runs nothing). The agent surfaces (agent tools, MCP) make a call an agent's whatever identity it carries, so `AgentTools.execute` with a caller identity and no agent session is refused too, here and for consent (AP-2). Fixed on build/threat-model: before, an eligible approver's agent could approve | `packages/testing/src/conformance/Approvals.ts` “refuses an eligible approver's agent the approval, on every agent surface; the approver decides”; `packages/testing/test/approvals-kernel.test.ts` “is an agent's call on the agent tools with a caller identity and no agent session: it neither approves nor decides consent” |
151
+ | AP-4 | E | The requester approves their own request, a member without the rule's permission approves, or an approver who lost it still decides | the rule checked against the live directory under the request's lock; self-approval only where the rule allows | `packages/testing/src/conformance/Approvals.ts` “refuses the requester and members without the rule's permission, on every surface, and audits it”; `packages/testing/test/approvals-races.test.ts` “refuses an approver who lost the role while the decision waited for the request”; `packages/testing/src/conformance/Approvals.ts` “lets the requester approve their own call only when the rule allows it” |
152
+ | AP-5 | T | What runs is not what was approved: the input changed after the request, the approval reused under another key, or named by a module's workflow | the request binds the decoded-then-encoded input and its sha256; the first execution pins its key; only kernel workflows may name an approved request | `packages/testing/src/conformance/Approvals.ts` “maps a retried call to the same request, and binds a different input to a different one”; `packages/testing/test/approvals-kernel.test.ts` “refuses to execute an approved request a second time, under another key”; `packages/testing/test/approvals-kernel.test.ts` “lets only the kernel's workflows name an approved request: a module workflow is asked for approval again” |
153
+ | AP-6 | E | Approval or scheduling widens a call or outlives what it was asked under (a revoked token, a revoked agent session, withdrawn consent, a narrower scope) | the call's provenance and authority chain are recorded and asserted again at execution | `packages/testing/test/provenance.test.ts` “keeps a scoped token's scope: what it schedules, and what an approval runs for it, stays within the scope”; `packages/testing/test/deferred-authority.test.ts` “refuses an approved call once its agent session is revoked”; `packages/testing/test/deferred-authority.test.ts` “refuses an approved agent's call once the person withdrew the consent it was asked under”; `packages/testing/test/deferred-authority.test.ts` “refuses, and records, an approved request whose provenance was never recorded” |
154
+ | AP-7 | E | A remembered permission covers more than the person meant, or survives its revocation | remembered per session or always, revocable; revoking withdraws approved calls that have not run; actions marked each-call are never covered | `packages/testing/src/conformance/ActionConsent.ts` “withdraws approved calls that have not run yet when the permission in their scope is revoked”; `registry/test/effects.test.ts` “asks the person for each message: a remembered permission never covers another call” |
155
+ | AP-8 | E | An agent gets later what it may not do now: it schedules the action, or runs it through an action that runs others later | an agent's schedule runs as the agent (consent and disabled groups apply then); actions that run others later need consent; `scheduler.create` is refused to agents | `packages/testing/test/daemon-review.test.ts` “S1: an agent cannot schedule what it may not do directly; an agent's schedule runs as the agent”; `packages/testing/test/scheduler-consent.test.ts` “refuses an agent's scheduler.create and lets the person's through”; `packages/testing/test/provenance.test.ts` “executes an agent's approved call as the agent's: its schedule runs as the agent, so a disabled group stays closed” |
156
+ | AP-9 | R | A decision or an execution is not attributable | the request (`approval-required`), each decision and the execution (surface `workflow`, as the requester) are audit records | `packages/testing/src/conformance/Approvals.ts` “runs exactly the approved call once, as the requester, and closes the work items” |
157
+ | AP-10 | D | A held call waits for ever, or a pending request runs long after its context changed | requests expire (seven days unless the rule says otherwise); requesters withdraw them | `packages/testing/src/conformance/Approvals.ts` “expires a request nobody decided in time, and never runs it”; `packages/testing/test/deferred-authority.test.ts` “lets the requester withdraw a pending approval, which then never runs” |
158
+ | AP-11 | S | A forged, altered, replayed or expired decision token (a push notification's Approve or Reject) decides a request | tokens are HMACs under the deployment's secret, one per notification and installation registration, stored only as their SHA-256, expiring after a day or with the approval (read again at the decision boundary, after every lock wait); the route holds the token's row in a transaction of its own and runs the decision in a savepoint, so the decision and the recorded answer commit together and a later redemption returns that answer, while the token is unexpired and its registration stands (`packages/kernel/src/notifications/Decide.ts`) | `packages/testing/src/conformance/DecisionTokens.ts` “refuses an unknown token, a verdict it does not offer, and a malformed request”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses an expired token”; `packages/testing/src/conformance/DecisionTokens.ts` “rejects an approval, and a second redemption answers what was decided and decides nothing”; `packages/testing/src/conformance/DecisionTokens.ts` “releases no recorded answer once the installation was signed out”; `packages/testing/src/conformance/DecisionTokens.ts` “releases no recorded answer once the token expired” |
159
+ | AP-12 | E | Opposite verdicts redeemed together (two devices' tokens, or an attacker racing the person) both decide, or a consent already decided in chat is decided again from a push | push decisions of one request by one person are serialised (an advisory lock on organisation, person, kind and request), the token's row held to the commit; a consent must still be pending, its row locked, so the second device's opposite verdict is refused (withdrawal stays the explicit `consent.reject`) | `packages/testing/src/conformance/DecisionTokens.ts` “decides once when opposite verdicts arrive together”; `packages/testing/src/conformance/DecisionTokens.ts` “decides a consent once when two devices answer with opposite verdicts”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses to reject from a push a consent the person already approved in chat” |
160
+ | AP-13 | E | A decision token outlives what it stands for: the approver's role removed, the membership ended, the device signed out, its session expired, the installation registered again | the token is no authority of its own: the decision runs the existing action through the invocation path as the person under the session that registered the installation (a link of its authority chain, held and valid at commit), under live membership, Cedar policy and eligibility; the token is bound to that session and the registration's generation, checked again under the installation's lock, which unregistering and registering again take exclusively; the organisation's sign-in methods are checked under its directory lock, held shared to the commit, so a change to them waits for the decision or refuses it | `packages/testing/src/conformance/DecisionTokens.ts` “approves an approval as the person, through the approval action, and answers no-store”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses a token once the person lost the approver's role, and spends it”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses a token whose installation's session signed out”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses a token once its installation was registered again from another session”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses a token once the session that registered its installation expired”; `packages/testing/src/conformance/DecisionTokens.ts` “refuses a token once the organisation no longer admits how its installation's session signed in”; `packages/testing/src/conformance/DecisionTokens.ts` “holds a change to the organisation's sign-in methods until a decision under the old ones commits” |
161
+ | AP-14 | E | An agent decides through a notification (approves a business approval, or consents to its own call) | the decide route is not an action: no agent tool, MCP tool or synced row reaches it; consent from a token never remembers a permission. Limit: the token is a bearer credential for its one decision until it expires or its installation signs out; software holding it can redeem it (it lives only in the APNs payload on an iOS device; Android gets none, AP-19) | `packages/testing/src/conformance/DecisionTokens.ts` “gives an agent no way to redeem a token: no action, no MCP tool”; `packages/testing/src/conformance/DecisionTokens.ts` “approves and rejects consent, remembering nothing beyond the one call” |
162
+ | AP-15 | I | A decision token leaks where others (or the agent) can read it: a synced row, the delivery log, the audit log, the outbox, a URL | its plaintext is only in the provider payload; audit records a hash of its hash; the route takes it in a `no-store` POST body | `packages/testing/src/conformance/DecisionTokens.ts` “keeps the token out of the replicated notification, the delivery log, the audit log and the outbox” |
163
+ | AP-16 | I | A lock screen, or the push provider, shows a consent request's input (what the agent wants to send, to whom) | a consent notification's push body is fixed text; the record link names only the request | `packages/testing/src/conformance/Push.ts` “keeps a consent request's input off the lock screen” |
164
+ | AP-17 | S | An ordinary notification (an agent's `notifications.notify`, module code) names a pending request the person may decide, with misleading text, and gets real Approve and Reject buttons | a decision is offered only when the kernel's own approval and consent producers say so (`TrustedSend`, never part of `SendNotification`), for a request still pending, and its push text is derived from the request (its action and requester) | `packages/testing/src/conformance/DecisionTokens.ts` “gives an ordinary notification no decision, whatever category and link its sender gives it” |
165
+ | AP-18 | T | A token's recorded answer disagrees with what committed (a replay racing the first redemption, a crash between the decision and its record), or a transient failure spends the token | the decision and the token's answer commit in one transaction (the action in a savepoint of the route's); a transient failure rolls both back and leaves the token unspent (`503`); the person's same decision made elsewhere (a chat decision with its comment too) answers the request's status read once under the route's lock; a storage failure in the route answers `503` `no-store`, also a lost connection whose rollback fails | `packages/testing/src/conformance/DecisionTokens.ts` “answers every redemption racing the first one with the answer that committed”; `packages/kernel/test/push-decisions.test.ts` “spends the token only on a definitive answer”; `packages/testing/src/conformance/DecisionTokens.ts` “answers a decision the person already made elsewhere with the request's recorded status”; `packages/testing/src/conformance/DecisionTokens.ts` “answers a consent decided elsewhere from one state, even when it is withdrawn while the redemption runs”; `packages/testing/src/conformance/DecisionTokens.ts` “answers an approval the person already gave in chat with a comment as the same decision”; `packages/testing/src/conformance/DecisionTokens.ts` “answers a failure to record the decision with a no-store 503, deciding nothing until a retry”; `packages/testing/src/conformance/DecisionTokens.ts` “answers a connection lost while recording the decision with a no-store 503, deciding nothing until a retry”; `packages/kernel/test/push-decisions.test.ts` “is recognised failed or died with, as a failed rollback dies” |
166
+ | AP-19 | I, E | An Android app granted notification access, or a debug build's log, reads a decision credential from a posted notification's extras and decides without the person; or such an app invokes the notification's Approve or Reject action itself (Android's delegated actions) and the app decides under the person's session | an FCM payload carries no decision token (`PayloadTarget` in `packages/kernel/src/notifications/Push.ts`), and nothing is minted for an FCM installation; an Android notification action decides nothing by itself: it opens that exact request with the verdict preselected, the confirmation is on that request's own card once it is read and can be decided (`registry/app/mobile/src/requests.ts` `confirmsOn`), and the decision is sent only when the person confirms it in the app, through their own session with the chat's actions, after the link gate checked the signed-in person, the installation and the organisation, for the organisation and generation the request was opened in, checked again as it is sent (`registry/app/mobile/src/linkGate.ts` `decisionStep` and `stillAccepted`, `App.tsx`); a consent's Reject sent this way rejects only a pending consent, so an approval made meanwhile in chat or on another device stands (`consent.rejectPending`, decided with the request's row locked; a distinct action, so a kernel of an earlier revision refuses it instead of withdrawing the approval) | `packages/testing/src/conformance/DecisionTokens.ts` “offers an FCM installation the decision without a token, and mints none for it”; `packages/testing/test/push-providers.test.ts` “gives an FCM installation the decision without a token, and names the recipient and the installation”; `registry/test/mobile-host.test.ts` “never decides an Android button by itself: it waits for the person's confirmation; an iOS button sends its token”; `registry/test/mobile-host.test.ts` “shows an Android notification's confirmation only on its own request's card, once a slow consent.get found it pending”; `registry/test/mobile-host.test.ts` “lets a decision be sent only for the organisation, generation, person and installation it was accepted for”; `registry/test/mobile-host.test.ts` “decides on Android through the person's session, with the chat's actions (consent remembered once)”; `packages/testing/src/conformance/ActionConsent.ts` “rejects only a pending request with consent.rejectPending (a notification's Reject): an approval from another device stands”; the Android emulator journey (`tools/scripts/mobile-harness.ts`, “the Approve button alone decides nothing”) |
167
+ | AP-20 | S | After a sign-out on the phone (also while its revocation waits offline), another person's sign-in, or a reinstall, a previous person's notification opens their request or decides it | every payload names its recipient and installation; the Expo host opens or decides a notification only for that person signed in on that installation, also at a cold start; a sign-out, as it begins, closes the push context synchronously (the account epoch moves on, the installation id is forgotten in memory, an iOS decision's queued retries are cancelled), then forgets the installation and the opt-in in secure storage, clears the shade, the last response and what waits, and starts the client core's durable sign-out without waiting for that cleanup; push registration is fenced to the account that began it before the installation id is written, before the kernel is called and before the id or status is published, and its writes take turns with the sign-out's removal, so it never writes the id back; an iOS decision is bound to the sign-in, installation and organisation it was accepted for, checked before every attempt; a reinstall's cleanup keeps the old session as a pending revocation, and the install is marked initialized only after the cleanup succeeded | `registry/test/mobile-host.test.ts` “refuses a notification for another person, or for an installation this device no longer has, also at a cold start”; `registry/test/mobile-host.test.ts` “forgets what waits when a sign-out begins”; `registry/test/mobile-host.test.ts` “stops turning notifications on when the person signs out while the OS asks, and registers nothing for the next one”; `registry/test/mobile-host.test.ts` “never writes back, registers or publishes an installation whose registration a sign-out overtook”; `registry/test/mobile-host.test.ts` “starts the core's durable sign-out at once, closing the push context first, without waiting for the device's cleanup”; `registry/test/mobile-host.test.ts` “cancels an iOS decision's retry when a sign-out begins, and sends nothing once it is no longer bound”; `registry/test/mobile-host.test.ts` “forgets a previous install's session and push association, signing that session out, keeping pending sign-outs”; `registry/test/mobile-host.test.ts` “fails a reinstall's cleanup it could not finish, so the next launch runs it again and the session is never restored” |
168
+
169
+ ## 4. MCP and OAuth
170
+
171
+ Entry points: `/mcp` (`packages/kernel/src/surfaces/Mcp.ts`), the OAuth 2.1 authorisation server (`packages/kernel/src/machine/OAuth.ts`, `machine/Pages.ts`, `machine/Tokens.ts`), API tokens and service principals (`machine/MachineIdentity.ts`), and the OAuth client flow for Connections (`packages/kernel/src/connections/Connections.ts`).
172
+
173
+ | Id | STRIDE | Threat | Mitigation | Proof |
174
+ | --- | --- | --- | --- | --- |
175
+ | MO-1 | S | An MCP client calls tools without a grant | every `/mcp` request authenticates; without a credential, 401 with the RFC 9728 challenge | `packages/testing/src/conformance/MachineIdentity.ts` “publishes authorisation server and protected resource metadata, and challenges unauthenticated MCP requests” |
176
+ | MO-2 | S | An intercepted authorisation code is exchanged by someone else | PKCE S256 required (plain and missing refused), the code bound to the client and redirect URI, single use, short-lived | `packages/testing/src/conformance/MachineIdentity.ts` “refuses a wrong PKCE verifier, and the code is spent”; `packages/testing/src/conformance/MachineIdentity.ts` “refuses plain PKCE, a missing challenge and a missing resource”; `packages/testing/src/conformance/MachineIdentity.ts` “refuses a reused code and revokes what its first exchange issued”; `packages/testing/src/conformance/MachineIdentity.ts` “refuses an expired code” |
177
+ | MO-3 | S | A malicious client registers a redirect URI it controls, or swaps it at the token endpoint | unregistered redirect URIs refused without redirecting; mismatches refused; unsafe URIs refused at registration, which is rate limited | `packages/testing/src/conformance/MachineIdentity.ts` “refuses an unregistered redirect URI without redirecting, and a mismatched one at the token endpoint”; `packages/testing/src/conformance/MachineIdentity.ts` “limits dynamic client registration and refuses unsafe redirect URIs” |
178
+ | MO-4 | S | The consent page is framed (clickjacking) or its form posted cross-site, so the person grants a client unknowingly | OAuth pages send `frame-ancestors 'none'` and `X-Frame-Options: DENY`; the consent form carries a CSRF token and the cookie guard checks the origin | `packages/testing/test/machine-identity.test.ts` “forbids framing the sign-in, consent and device pages (clickjacking)”; `packages/testing/test/cookie-guard.test.ts` “refuses a forged cookie request on every listed route, and on a route the kernel does not have” |
179
+ | MO-5 | E | A token reaches a resource or organisation it was not granted (a token for `/api` used on `/mcp`, an organisation switch) | access tokens bound to their resource (RFC 8707) and the organisation picked at consent | `packages/testing/src/conformance/MachineIdentity.ts` “binds access tokens to their resource (RFC 8707) and to the organisation picked at consent” |
180
+ | MO-6 | E | A scoped token calls or lists more than its scope | scope checked on every call and listing | `packages/testing/src/conformance/MachineIdentity.ts` “a token scoped to one action cannot call another (API token and OAuth scope)”; `registry/test/mcp-oauth.test.ts` “lists and calls no more than the token's scope, even what the policy allows” |
181
+ | MO-7 | S | A stolen refresh token is replayed; a revoked grant or a departed member's token keeps working | refresh tokens rotate and a reused one revokes the grant; revocation and membership are checked on the next call | `packages/testing/src/conformance/MachineIdentity.ts` “rotates refresh tokens, and a reused refresh token revokes the whole grant”; `registry/test/mcp-oauth.test.ts` “stops at the next call once the grant is revoked, and cannot refresh”; `packages/testing/src/conformance/MachineIdentity.ts` “refuses a token's next call once its user is no longer a member, for OAuth and API tokens alike” |
182
+ | MO-8 | I | Tokens leak from the database | API tokens, authorisation codes, and access and refresh tokens stored only as their hashes (agent sessions and device credentials too, `token_hash`); API tokens shown once | `packages/testing/test/machine-identity.test.ts` “stores every secret only as its hash”; `packages/testing/src/conformance/MachineIdentity.ts` “API tokens: shown once, listed by prefix only, last use tracked, revocable and expiring” |
183
+ | MO-9 | S | Device-flow user codes are guessed | lookups per address bounded, even concurrently | `packages/testing/test/machine-identity.test.ts` “bounds wrong user codes from one address even when they arrive all at once” |
184
+ | MO-10 | T | A parameter repeated so two parsers disagree; malformed client credentials crash the server | repeated parameters refused at every endpoint; malformed credentials answered `invalid_client` | `packages/testing/src/conformance/MachineIdentity.ts` “refuses a repeated parameter with invalid_request at every endpoint (RFC 6749 section 3.1)”; `packages/testing/src/conformance/MachineIdentity.ts` “answers malformed client credentials as invalid_client, never as a server error” |
185
+ | MO-11 | E | An external MCP client's call skips consent, being a person's credential | an MCP call's origin is `agent`, so consent holds it like the in-kernel agent's | `packages/testing/test/surfaces-property.test.ts` “gives the same identity, policy result, consent, idempotency, audit record and outbox event on every surface” |
186
+ | MO-12 | E | Service principals created or removed by non-administrators, or the organisation left without a directory manager | admin-only, audited; the last manager cannot be deleted | `packages/testing/src/conformance/MachineIdentity.ts` “service principals: created, disabled and deleted by organisation admins only, audited, acting through the invocation path”; `packages/testing/test/machine-identity.test.ts` “refuses to delete a service principal that is the organisation's last directory manager” |
187
+ | MO-13 | S | The Connections OAuth flow (the kernel as client) is hijacked: an attacker's callback completes in the victim's session, or a state is replayed | PKCE S256; the state bound to the opening session and single use | `packages/testing/src/conformance/Connections.ts` “binds the state to the session that opened the consent: another session's callback is refused and creates nothing, and a state works once”; `packages/testing/test/session-commit.test.ts` “binds and completes no flow when another person's real flow id or state is followed in the victim's browser” |
188
+ | MO-14 | S | The Connections flow's `returnTo` sends the browser to an attacker (open redirect) | only the app or a trusted origin | `packages/testing/src/conformance/Connections.ts` “never sends the browser to another origin, whatever form returnTo takes” |
189
+ | MO-15 | E | A reconnect signs in a different provider account and takes over a Connection | a reconnect must be the same account | `packages/testing/src/conformance/Connections.ts` “refuses a reconnect that signs in a different provider account, leaving the Connection as it was” |
190
+ | MO-16 | E | An MCP client (or the app's or a browser's agent) is offered, and calls, an action only a person may take (deciding consent or an approval, registering push, starting or steering agent runs, setting the agent's budget or model) | those actions' handlers refuse every agent-originated call (since 2026-11-22 `agent.setBudget` and `agent.configureModel` too: a manager's MCP grant can no longer clear a budget or redirect the organisation's model; the model-setup HTTP routes keep requiring the person's own session) (an MCP call's origin is `agent`); since 2026-11-22 they are also left out of MCP's `tools/list`, the agent's tools and WebMCP (`exposure: { agent: false, mcp: false }`), so a model never sees them offered; a call by name stays refused. An agent session's credential (a browser agent's WebMCP bearer) calling over HTTP, RPC or the CLI is held to the agent surface's exposure too, before consent and idempotent replay, so the four person-only actions whose handlers do not refuse agents are not reachable through that route either | `packages/testing/test/person-only-actions.test.ts` “are not listed on MCP where they are refused, and a call by name is refused as Forbidden”, “are not the app's agent's tools, and a call by name is refused”, “are not a browser agent's tools (WebMCP), and its call by name is refused as Forbidden”, “are refused to a browser agent's credential over HTTP even where its handler would not refuse, for a member and a manager”; `packages/testing/test/proposals.test.ts` “groups proposed edits, decides an exact observed set all or none, and applies an accepted item once” |
191
+ | MO-17 | I | The CLI's stored sign-in (an OAuth access and refresh token) is read from disk by another user, a backup or a stray copy of the config directory | the tokens in the OS keychain (`eloxiv-cli`, per grant and absolute config directory, a relative `XDG_CONFIG_HOME` ignored), the file holding no secret; where no keychain answers, a 0600 file in a 0700 directory, said at login (written through an exclusively created 0600 temporary file removed on failure; a directory others may use tightened, one another user owns refused; on Windows the inherited ACL, as Node cannot set an owner-only one); an older CLI's tokens moved out of the file on the next command; `logout` removes both, including a keychain entry the file no longer records, and reports a malformed one instead of signing out; `login` refuses to replace a keychain sign-in from a command that cannot reach the keychain, so no grant is left valid out of `logout`'s reach | `packages/cli/test/credentials.test.ts` “keeps the tokens in the OS keychain and the rest of the sign-in in the file, and says so”; “moves an older CLI's tokens from the file into the keychain on the next command, and removes them from the file”; “logout revokes the grant and removes it from the keychain and the file”; “refuses to replace a keychain sign-in (%s) where the keychain is unavailable, so its grant is not left valid”; “logout revokes and removes a keychain grant the file no longer records”; “logout does not report a sign-out when the keychain entry is not a pair of tokens”; “tightens a config directory its group or others may use to 0700 before writing there”; “refuses a config directory another user owns”; “never writes the tokens through a file planted at a temporary path”; “removes its temporary file when the write fails”; “ignores a relative XDG_CONFIG_HOME, so two working directories never share a keychain account name”; `registry/test/cli-surface.test.ts` “logs in with the device flow, storing the token readable by the user alone” |
192
+
193
+ ## 5. Webhooks
194
+
195
+ Entry point: `POST /ingress/<source>` (`packages/kernel/src/ingress/Ingress.ts`, verifiers in `ingress/Verifiers.ts`), processed by the `eloxiv.ingress` workflow; linked platform identities and link codes. Connectors add sources (Slack's Events API).
196
+
197
+ | Id | STRIDE | Threat | Mitigation | Proof |
198
+ | --- | --- | --- | --- | --- |
199
+ | WH-1 | S | A forged delivery (wrong secret, tampered body, no signature) | verified before anything is stored, with any of the source's secrets during rotation; refusals audited, nothing stored | `packages/testing/src/conformance/Ingress.ts` “refuses bad signatures (wrong secret, tampered body, none) and audits them without storing the delivery”; `packages/testing/test/ingress.test.ts` “never stores a refused delivery, its payload or its signature” |
200
+ | WH-2 | T | A captured delivery replayed, or its signed payload sent under another delivery id | timestamp tolerance; delivery ids kept to refuse a replay with another body; GitHub deliveries keyed on the signed body's hash | `packages/testing/src/conformance/Ingress.ts` “refuses a stale timestamp and a replayed delivery id with another body, and audits both”; `packages/testing/test/ingress.test.ts` “backfills the signed hash of GitHub deliveries stored before it existed, so their replays join them”; `registry/test/connector-slack.test.ts` “answers a signed url_verification with its challenge, and refuses one with a bad signature or an old timestamp” |
201
+ | WH-3 | E | A verified delivery from an unlinked sender acts as someone | an unlinked sender is accepted, then refused and audited; nothing written | `packages/testing/src/conformance/Ingress.ts` “an unlinked sender cannot act: the delivery is accepted, then refused and audited, and nothing is written”; `packages/testing/src/conformance/Messaging.ts` “receives a message through Ingress as the sender's linked actor; an unlinked sender never acts” |
202
+ | WH-4 | S | Someone links a platform identity to another person's account | linking only through a one-time code issued to a signed-in member; edited messages never carry a code; another app's post is never a person's | `packages/testing/src/conformance/Ingress.ts` “links an identity only through a one-time code from a signed-in member, and unlinking stops it acting”; `registry/test/connector-slack.test.ts` “takes no edited or changed message or mention as anyone's, so an edit can never carry a link code”; `registry/test/connector-slack.test.ts` “never takes another app's post as a person's, whatever its bot profile omits” |
203
+ | WH-5 | E | A delivery from another organisation's workspace (Slack Connect) acts in this organisation | a delivery acts only in the organisation of the receiving workspace's Connection | `registry/test/connector-slack.test.ts` “acts only in the organisation of the receiving workspace's Connection: a Slack Connect message from another org's workspace is unlinked” |
204
+ | WH-6 | E | A linked sender does more than their actor may | the delivery acts as the linked actor through the invocation path, under the actor's policy | `packages/testing/src/conformance/Ingress.ts` “a linked sender acts as their actor and the actor's policy applies” |
205
+ | WH-7 | D | Oversized or slow bodies, unknown sources, retries processed twice | the source's body limit counted as it arrives (413), 408 for slow bodies, 404 for unknown sources; processed exactly once, also across a crash | `packages/testing/src/conformance/Ingress.ts` “answers 404 for an unknown source and 413 for an oversized body”; `packages/testing/src/conformance/Ingress.ts` “accepts a well-signed delivery and processes it exactly once, also when it is delivered twice”; `packages/testing/test/ingress-restart.test.ts` “processes a delivery exactly once when the kernel dies after its handler acted, and a redelivery joins” |
206
+ | WH-8 | T | A sender's headers smuggle what the handler trusts | a source acting as a service principal keeps only its declared headers | `packages/testing/src/conformance/Ingress.ts` “a source acting as a declared service principal acts as it once it exists, and keeps only declared headers” |
207
+
208
+ ## 6. Sandbox
209
+
210
+ MAKE modules (`packages/kernel/src/make/`) are untrusted: drafted by a person or their agent, previewed, approved by an administrator, installed by setup. Their handlers and subscribers run in QuickJS in WebAssembly (`packages/kernel/src/sandbox/Sandbox.ts`, `sandbox/worker.ts`) in worker threads, with only the host functions their capability profile grants; their SQL goes through a guard over PostgreSQL's parse tree (`make/SqlGuard.ts`) on a session logged in as their runtime role (`make/Session.ts`). Their views' code runs in the same sandbox (`make/ViewStep.ts`) and reaches the browser only as a view tree the shell draws in a frame where nothing runs or loads (`registry/app/shell-foldkit/src/makeView.ts`). Document extraction (`ingestion`) runs in child processes with limits.
211
+
212
+ | Id | STRIDE | Threat | Mitigation | Proof |
213
+ | --- | --- | --- | --- | --- |
214
+ | SB-1 | E | Sandboxed code reaches ambient authority (network, timers, modules, process, host globals) or a host function it was not granted | QuickJS with no ambient authority; host functions only as granted, by name or through the bridge | `packages/testing/src/conformance/Sandbox.ts` “cannot call a host function it was not granted, by name or through the bridge”; `packages/testing/src/conformance/Sandbox.ts` “shares nothing between runs, nor with the host”; `packages/testing/src/conformance/Sandbox.ts` “passes only JSON out: a function becomes null, a cycle fails the run” |
215
+ | SB-2 | D | Hostile code exhausts the kernel (busy loop, memory, recursion, host-call floods, promises that never settle) | time, step, memory, stack, host-call and output limits per run; workers off the kernel's event loop | `packages/testing/src/conformance/Sandbox.ts` “stops a busy loop at its time limit”; `packages/testing/src/conformance/Sandbox.ts` “stops at its memory limit”; `packages/testing/src/conformance/Sandbox.ts` “never blocks its host: the host answers while code loops”; `packages/testing/test/make-sandbox.test.ts` “stays responsive while hostile calls run: the kernel answers throughout each”; `packages/testing/test/make-load.test.ts` “limits each person's calls of a module per minute” |
216
+ | SB-3 | E | A MAKE module escalates in the database: role changes, `set_config`, other modules', kernel or auth tables, a forged invocation context | statements through the SQL guard, on a session logged in as the module's runtime role with nothing more privileged to return to | `packages/testing/test/make-sandbox.test.ts` “is its own role, with nothing more privileged to return to”; `packages/testing/test/make-sandbox.test.ts` “reaches no other module's, kernel's or Better Auth's tables, and cannot forge the invocation context”; `packages/testing/test/make-isolation.test.ts` “finds a violation planted for a MAKE module's role” |
217
+ | SB-4 | E | A MAKE module's profile is a confused deputy: it calls a kernel governance action, an action needing consent, or writes through another module | the profile may call only other modules' read-only actions, never the kernel's, never consent-marked ones; refused at draft and at run time | `packages/testing/test/make-manifest.test.ts` “refuse a capability to call a kernel module's action (a confused deputy), or one that writes”; `packages/testing/test/make-manifest.test.ts` “refuse a capability to call an action that needs consent, or that no module declares” |
218
+ | SB-5 | E | A MAKE module is installed or upgraded without an administrator, or with other content than the approver saw | install and version bumps are business approvals showing the source hash and profile; the requester cannot approve; only what was approved installs | `packages/testing/test/make-lifecycle.test.ts` “the requester cannot approve their own install; an administrator's approval installs it once”; `packages/testing/test/make-lifecycle.test.ts` “installs only what the approver saw: the draft's module, version, hash and capability profile”; `packages/testing/test/make-lifecycle.test.ts` “only an administrator rolls back; the previous version's code runs over the same schema” |
219
+ | SB-6 | E | A MAKE module's text (descriptions) steers the agent as if it were the app's | its actions are offered marked as the module's own untrusted text; listed only to the installing organisation | `packages/testing/test/make-lifecycle.test.ts` “offers the agent its actions with their descriptions marked as the module's own untrusted text”; `packages/testing/test/make-surfaces.test.ts` “are listed to the organisation's members, marked untrusted, and to no one else” |
220
+ | SB-7 | I | A hostile MAKE view reaches the shell or the person's session, calls actions it did not list, or sends out data it was given (navigating its frame to an attacker's URL carrying what its actions returned) | the view's code never reaches the browser: it runs in the sandbox (`make.renderView`: nothing granted, no DOM or network) and returns a view tree held to the contract's elements and properties, none naming a URL; the shell draws it in an iframe sandboxed without scripts or forms (`allow-same-origin` only, so the host draws and reads it) under a CSP that loads nothing (no script, image, media, font, frame, object, connection or form submission); its controls are links to the frame's own fragments, which the host routes to the view; only listed actions are called, through the invocation path, and each result goes back to the view's code in the kernel | `packages/testing/test/make-view-step.test.ts` “gives the code nothing to send data out with”; `packages/testing/test/make-view-step.test.ts` “refuses a tree with anything the shell does not draw: another element, a URL property, too many nodes”; `e2e/make-view.spec.ts` “never lets a view's tree, or what its action returned, reach the network or move the frame”; `e2e/make-view.spec.ts` “calls only the view's listed actions, each under the view's idempotency key within its mount”; `e2e/make-view.spec.ts` “draws a view's tree where nothing runs, and routes its controls to the view” |
221
+ | SB-8 | E | A MAKE module of one organisation serves another, or a caught refusal lets its later writes commit | served only to the installing organisation; a refusal fails the call and nothing after it commits | `packages/testing/test/make-sandbox.test.ts` “serves only the organisation that installed it”; `packages/testing/test/make-sandbox.test.ts` “fails a call whose code caught a refusal, and nothing it wrote afterwards commits” |
222
+ | SB-9 | D | A hostile document (a zip bomb spreadsheet, a crashing parser) takes the kernel down during extraction | extraction in child processes with time and memory limits, replaced when they crash | `packages/kernel/test/extract-isolated.test.ts` “kills a job past its memory limit, and the kernel's process goes on”; `packages/kernel/test/extract-isolated.test.ts` “holds an amplifying spreadsheet to the text limit (one shared string in every cell)” |
223
+ | SB-10 | R | A MAKE module's refused attempts go unrecorded | every refusal audited as the module's action | `packages/testing/test/make-sandbox.test.ts` “audits every refusal as the module's action” |
224
+ | SB-11 | S | An installed MAKE module names a consequential action with a harmless title, so the person deciding a held call (a consent or approval prompt, its push with an approve button, its email) approves what they did not mean to; or a long title breaks the email's subject line | where a person decides, a MAKE action is always shown by the kernel's label of its id (`decisionLabel`: the module's id first, never cut away by the 80-character bound, then the action's words; recorded on the request, used in work items, notifications, push and email, and recomputed from the id by the chat SDK, the Expo and Rune hosts when they render a stored request or event, so a title held before is never shown), never its authored title; every title is one line of at most 80 characters, refused at `defineAction` and at MAKE draft, and bounded where a subject uses one (also titles of versions installed earlier and requests held before) | `packages/testing/test/make-surfaces.test.ts` “are called through the invocation path: a scoped token is refused, an agent needs consent”; `packages/testing/test/action-titles.test.ts` “of a MAKE module's action are never its own words where a person decides: always the kernel's name”, “are one line of at most 80 characters: defineAction refuses another, and every label is bounded”; `packages/testing/test/make-manifest.test.ts` “load a version installed before titles were bounded with its title as one bounded line” |
225
+
226
+ ## 7. Daemon
227
+
228
+ The device daemon (`packages/daemon/src/`) runs on a person's own machine: it pairs with the kernel (`packages/kernel/src/devices/Devices.ts`, `devices/Http.ts`), keeps the device credential in the OS store, serves a loopback relay (`packages/daemon/src/Http.ts`, `LocalAuth.ts`) for local clients and harness turns, and runs Claude Code or Codex turns (`Harness.ts`), as a desktop sidecar or a headless runner. An app's own sidecar composed with a `clientApp` also serves **LocalClient** (decision 14; `packages/daemon/src/Client.ts` over `ClientRuntime`, `packages/client/src/Runtime.ts`): the client core for a native desktop host, under `/client/v1`, holding a second identity, the person's session from a desktop sign-in through the daemon's own loopback callback, beside the device credential.
229
+
230
+ | Id | STRIDE | Threat | Mitigation | Proof |
231
+ | --- | --- | --- | --- | --- |
232
+ | DM-1 | S | A device is paired to someone's account without them | pairing needs a code a signed-in person confirms in the kernel; codes expire, are single use, limited per address and per person; the credential is issued once | `packages/testing/src/conformance/Daemon.ts` “pairs with a code a signed-in person confirms; the credential is issued once and kept in the secret store”; `packages/testing/src/conformance/Daemon.ts` “refuses wrong, expired and reused codes, and a second claim of the credential”; `packages/testing/test/daemon-limits.test.ts` “limits the wrong codes one person enters, sequentially and in parallel”; `packages/testing/test/daemon-limits.test.ts` “limits the pairings one address starts, also when they arrive at once” |
233
+ | DM-2 | S | A web page or local process drives the daemon (DNS rebinding, cross-origin requests, an unpaired local client) | loopback only; Host and Origin checked; a client token on every route but health and pairing; local clients paired only with the host's approval and a code, under a global wrong-code lockout | `packages/daemon/test/daemon.test.ts` “listens on loopback only”; `packages/daemon/test/daemon.test.ts` “refuses a request that names the daemon by a non-loopback host (DNS rebinding)”; `packages/daemon/test/daemon.test.ts` “allows the shell's origins by CORS, and refuses other origins outright”; `packages/daemon/test/daemon.test.ts` “needs a client token on every route but /health and the pairing handshake”; `packages/daemon/test/review.test.ts` “needs the host's approval: the right code alone is refused”; `packages/daemon/test/review.test.ts` “locks every pairing out after a few wrong codes, across pairings, for exponentially longer” |
234
+ | DM-3 | I | The device credential or the person's tokens leak to a local client or a harness | no response to a local client carries a kernel credential; harnesses get per-turn tokens, never in argv, with an allow-listed environment; the host secret taken out of the environment once read | `packages/testing/src/conformance/Daemon.ts` “relays a local client's call as the person; no response to a local client carries a kernel credential”; `packages/daemon/test/harness.test.ts` “never puts the turn's token in argv”; `packages/daemon/test/harness.test.ts` “passes only the variables a CLI needs (an allow-list): no keys, tokens or the daemon's secrets”; `packages/daemon/test/review.test.ts` “takes the host secret out of the environment once read” |
235
+ | DM-4 | E | A harness turn does more than it was given: other actions, built-in shell tools, the daemon's state | per-turn tool scope; Claude Code gets no built-in tools and Codex no shell unless a turn asks for workspace tools; workspaces outside the state directory | `packages/daemon/test/review.test.ts` “limits a turn to the actions it was given (per-turn tool scope)”; `packages/daemon/test/review.test.ts` “Claude Code gets no built-in tools and no user or project settings; Codex no shell”; `packages/daemon/test/review.test.ts` “keeps the default workspace outside the state directory” |
236
+ | DM-5 | E | A relayed call skips consent or acts beyond the person | the relay acts as the person's agent through the invocation path; consent holds destructive calls | `packages/testing/src/conformance/Daemon.ts` “consent holds a destructive relayed call until the person decides”; `packages/testing/src/conformance/Daemon.ts` “a fake-harness turn calls an Eloxiv action through the relay as the person's agent (both stream formats)” |
237
+ | DM-6 | E | A revoked device, or a cancelled run, keeps acting | revocation cuts a running daemon off at its next request with its relay sessions; a cancelled run refuses the turn's calls before the next heartbeat | `packages/testing/src/conformance/Daemon.ts` “revoking a device cuts a running daemon off at its next request, with its relay sessions”; `packages/testing/test/agent-device.test.ts` “refuses the turn's calls once the run is cancelled, before the runner's next heartbeat”; `packages/testing/test/daemon-review.test.ts` “cancelling a running turn stops its harness; revoking the device mid-turn fails the turn and stops the runner”. Limit: a harness that calls nothing can keep working locally until the runner's heartbeat (scaffold known gap 18) |
238
+ | DM-7 | E | A turn is addressed to someone else's device, or a token scoped to sending turns does more | only the device's person may address it; a `devices.sendTurn`-only token neither widens nor outlives its scope | `packages/testing/src/conformance/Daemon.ts` “serves a turn sent by a browser-side SDK call; only the device's person may address it”; `packages/testing/test/deferred-authority.test.ts` “does not widen or outlive a devices.sendTurn-only token” |
239
+ | DM-8 | S | The daemon pairs with a kernel an attacker runs, or over plain HTTP off the machine | it refuses a second kernel while paired and plain HTTP that is not loopback | `packages/daemon/test/review.test.ts` “refuses to pair with another kernel while paired”; `packages/daemon/test/review.test.ts` “refuses a plain-http kernel that is not on loopback” |
240
+ | DM-9 | I | Pairing codes or the credential are left where other users of the machine (or readers of its collected logs) see them | codes never logged, a local client's or the kernel's: the kernel's is shown only to the authenticated host or control channel (`/status`, `eloxiv-daemon pairing-code`) and in interactive output (`eloxiv-daemon pair`, a terminal); the credential in libsecret, Keychain or Credential Manager, or a 0600 file keyed by state directory | `packages/daemon/test/review.test.ts` “S6: never writes a pairing code to its log, a local client's or the kernel's; the host reads the kernel's from /status”; `packages/daemon/test/secrets.test.ts` “the file store keeps secrets in a 0600 file and deletes them”; `packages/daemon/test/secrets.test.ts` “keys the credential by state directory, so daemons on one machine never share it” |
241
+ | DM-10 | T | A stale runner settles a turn twice, or a large event batch drops events | turns settle under the current lease only; oversized batches refused | `packages/testing/test/daemon-review.test.ts` “settles under the current lease only: a stale lease is TurnLeaseLost, the same report twice is a duplicate”; `packages/testing/test/daemon-review.test.ts` “refuses an event batch larger than the limit instead of dropping events” |
242
+ | DM-11 | E | A release build trusts a development origin | the Vite dev server's origin is trusted only in development builds | `packages/daemon/test/binary.test.ts` “is a release build: the Vite dev server's origin is not trusted, the Tauri webview's is” |
243
+ | DM-12 | E | A device command reaches outside the device's workspace, or the daemon's own state | terminal and file commands run only inside the workspace and only of the kinds the device offers; the state directory starts inside it, out of every file command's reach | `packages/testing/src/conformance/DeviceControl.ts` “runs terminal and files commands only inside the device's workspace, and only kinds it offers”; `packages/testing/src/conformance/DeviceControl.ts` “starts with its state directory inside the workspace, and no file command reaches it” |
244
+ | DM-13 | E | Someone other than the device's person drives it, an agent acts on it unasked, or a revoked device keeps running commands | only the device's person sends it commands; an agent's wait for consent; revoking fails what is left | `packages/testing/src/conformance/DeviceControl.ts` “only the device's person sends it commands; an agent's waits for consent; revoking fails what is left” |
245
+ | DM-14 | E | Device control used where the organisation turned it off, or browser commands reaching a page other than the paired companion's | an organisation can turn commands and workspace tools off, and a tools-only device refuses workspace tools; browser commands go only to the paired browser-extension companion | `packages/testing/src/conformance/DeviceControl.ts` “a tools-only device refuses workspace tools; an organisation can turn commands and workspace tools off”; `packages/testing/src/conformance/DeviceControl.ts` “hands browser commands to the paired browser-extension companion and its answer back” |
246
+ | DM-15 | S | A page or process forges LocalClient's sign-in callback (login CSRF: the person's daemon signed in with an attacker's code), or replays one already used | the callback (`/client/v1/sign-in/callback`, the one route without a token) accepts only the state the daemon issued for the sign-in it started, compared in constant time, once and within 60 s; anything else answers 400 before redeeming, so the code is not spent; the PKCE verifier never leaves the daemon, so an intercepted code is useless elsewhere; the redirect is the daemon's own on `127.0.0.1` | `packages/testing/src/conformance/LocalClient.ts` “signs in through the daemon's callback; a wrong and a replayed state are refused and redeem nothing”; `registry/test/client-runtime.test.ts` “finds a stored session at start and refuses a code redeemed with the wrong state” |
247
+ | DM-16 | E | A harness, a companion, the shell or a CLI acts with the person's own session (no consent, every organisation) through LocalClient | `/client/v1` accepts only the host's per-launch secret and paired `desktop-app` clients; every other token kind is `403 Forbidden`, none is `401`; a local client's kind is the one the host approved when it paired, and a confirmation naming another kind is refused (`403 PairingKindMismatch`) and discards the pairing, so an approved companion cannot become a `desktop-app`; a daemon without an app serves none of it (`404 ClientNotConfigured`) | `packages/daemon/test/review.test.ts` “refuses a confirmation that turns an approved companion into a desktop-app”; `packages/testing/src/conformance/LocalClient.ts` “refuses every other kind of caller, and a missing or unknown token”; `packages/testing/src/conformance/LocalClient.ts` “answers 404 ClientNotConfigured on a daemon without an app”; `registry/test/app-daemon.test.ts` “serves LocalClient for hello-app; the generic daemon answers ClientNotConfigured” |
248
+ | DM-17 | I | The person session or the device credential reaches a native client | no LocalClient answer, event or page carries a kernel credential (each is also scrubbed of every credential the daemon holds); the person session is kept in the secret store under its own key, never in `state.json`; sign-out revokes it at the kernel and forgets it, and a sign-in still completing when the person signs out (or it is cancelled or replaced, or the daemon stops), also while its account is checked or when that check fails, stores and reports nothing and has the session it redeemed revoked; the kernel and zero-cache URLs the session goes to must be https or loopback http (the daemon's pairing rule, one validator), checked before the session is loaded; the Rune host's outstanding-sends file (`outstanding-sends.json` in its data directory) holds only a send's text, conversation and key, never a credential, written readable by the person only (its lock file too) and removed once nothing is outstanding | `packages/daemon/test/client-transport.test.ts` “refuses a composed plain-http kernel before loading the person session” (and zero-cache, both environment defaults); `packages/testing/test/client-runtime-races.test.ts` “adopts nothing when the person signs out while redeeming its code, and revokes the redeemed session” (and while checking its account, after a cancellation, after `close`), “adopts nothing after cancelSignIn while its account is checked, and revokes the redeemed session once” (and after `replace`, after `close`), “adopts nothing when the account check fails while the sign-out waits, and revokes the redeemed session”, “leaves nothing to sign in with at the next start after the account check failed during a sign-out”; `packages/testing/src/conformance/LocalClient.ts` “never carries a kernel credential in an answer or an event”; `registry/app/desktop-rune/app/src/outstanding.rs` `sends_are_kept_per_person_and_organisation_across_a_restart_and_leave_on_a_definitive_outcome`, `two_hosts_sharing_the_data_directory_keep_each_others_sends`; `registry/app/desktop-rune/app/tests/chat.rs` `a_send_whose_answer_was_lost_is_resent_under_its_key_after_the_host_restarts`; `packages/testing/src/conformance/LocalClient.ts` “signs out: the context resets, the session is revoked, and nothing is served until a new sign-in” |
249
+ | DM-18 | I | Late events cross organisations or sessions: rows of the organisation left (or of a signed-out person) reach the client after a switch; a send or another action made in one organisation runs in the next | each context has a generation; a write or call names the generation it was made in (LocalClient 1.1.0) and the daemon refuses it with `StaleGeneration`, running nothing, when another is current (after any context change asked before it), and the Rune host sends every send, decision, write and MAKE call with its generation, a retry keeping the first, and clears its unsent drafts on every context change or sign-out, whoever made it; a switch, a sign-out or `needs-auth` destroys every view, stops every followed run (its request to the kernel aborted) and closes the replica before the `context` reset is sent; every `rows`, `write` and `run` event carries its generation and one of an older generation is dropped; a run is followed with the organisation selected when it was asked, so the kernel refuses another organisation's run; the Rune host takes the session only from the stream (its first event), never from a separate read that could answer late, and ignores a signed-in session of an older generation | `registry/app/desktop-rune/app/src/model.rs` `a_session_of_an_older_generation_changes_nothing`; `registry/app/desktop-rune/app/tests/screens.rs` `the_session_comes_only_from_the_stream`; `packages/testing/src/conformance/LocalClient.ts` “switches organisation: the reset before any row of the new one, and nothing of the old one after it” (a followed run of the first organisation included); `packages/testing/test/client-runtime-runs.test.ts` “stops every run on a context reset: its request aborted, nothing of it after the context event”, “is refused with StaleGeneration naming the current one, and never runs in the new organisation”; `packages/testing/src/conformance/LocalClient.ts` “refuses a call or a write made in the generation before the switch, running nothing (1.1.0)”; `registry/app/desktop-rune/app/tests/chat.rs` `a_send_made_in_one_organisation_never_runs_in_the_next`, `a_draft_never_crosses_a_reset_the_daemon_made`; `registry/test/client-runtime.test.ts` “switches organisation: the reset comes before anything of the new one, and nothing of the old one follows” |
250
+ | DM-19 | D | A closed or replaced event stream keeps its subscriptions (and the replica's rows) flowing to nobody, or one client's rows reach another's stream | one stream per client token (a new one closes the old); closing it destroys the client's subscriptions and stops its followed runs, dropping any of their events already queued for delivery; `rows`, `write` and `run` events go only to the client that made them; a runtime stopped (`close`) while it adopts a session or changes context opens no replica afterwards (late continuations and queued resets do nothing, and `close` waits for a running one) | `packages/testing/test/client-runtime-races.test.ts` “opens no replica after close, and advances no context”; `packages/testing/test/client-runtime-runs.test.ts` “is dropped when the stream closed (unfollowAll)”, “is dropped when unfollowed”, “still delivers run-finished after the run ended by itself”; `packages/testing/src/conformance/LocalClient.ts` “keeps one stream per client, and closing a stream destroys its subscriptions” |
251
+ | DM-20 | S | The person is tricked into approving a desktop sign-in that is not theirs (a link to the approval page with an attacker's challenge, a redirect to a web address, a framed or auto-submitted page), so a code reaches someone else | the reference shell's `/desktop/sign-in` approves only on the person's click, never on load, as the signed-in session by bearer token (no cookie: a cross-site post cannot approve); it names where the code goes (the redirect's loopback host and port, or its app scheme) and the challenge's fingerprint, and offers nothing to approve for a malformed request or a redirect that is not a loopback address or an app scheme; it follows only a redirect to the address the request named; the kernel refuses any other redirect and binds the code to the challenge, so only the verifier's holder (the daemon that started it) redeems it; the shell is served with `frame-ancestors 'none'`. Limit: an attacker process on the person's own machine can listen on a loopback port it names; the page says what is asking, and the code is useless without the verifier | `registry/test/shell-foldkit-desktop.test.ts` “reads only a well-formed request: a challenge, a state, a loopback or app-scheme redirect”; `registry/test/shell-foldkit-desktop.test.ts` “follows no redirect but the one asked for, takes only the answer in flight, and says why one failed”; `e2e/desktop-sign-in.spec.ts` “a desktop sign-in: signed in first, approved by keyboard, redeemed by the verifier's holder”; `e2e/desktop-sign-in.spec.ts` “a request whose redirect is a web address is not offered for approval”; `packages/cli/test/deploy.test.ts` “serves the built shell with its security headers and client routes, and nothing outside dist” |
252
+
253
+ ## 8. Secrets
254
+
255
+ Secrets (`packages/kernel/src/connections/Secrets.ts`, `connections/Crypto.ts`): envelope encryption under a key ring, scoped to a person or an organisation, managed over `POST /kernel/secrets/*`. Connections keep provider tokens through a custody adapter (Secrets by default). Telemetry is allowlist-only.
256
+
257
+ | Id | STRIDE | Threat | Mitigation | Proof |
258
+ | --- | --- | --- | --- | --- |
259
+ | SE-1 | I | A database dump or backup exposes secret values or provider tokens | ciphertext only, in no column in any encoding; provider tokens only in custody, none in kernel tables | `packages/testing/src/conformance/Secrets.ts` “stores only ciphertext: the value is in no column in any encoding, and reads back exactly”; `packages/testing/src/conformance/Connections.ts` “keeps tokens only in Secrets, as ciphertext: no issued token appears in any kernel table” |
260
+ | SE-2 | T | Someone with database access moves one secret's ciphertext into another's row (another scope or name) | each ciphertext bound to its scope and name | `packages/testing/src/conformance/Secrets.ts` “binds each ciphertext to its scope and name: moved to another secret's row, it does not decrypt” |
261
+ | SE-3 | E | A module's code or role reads the secret store | module roles have no access; module code runs without the Secrets service | `packages/testing/src/conformance/Secrets.ts` “keeps module roles away from the storage”; `packages/testing/test/kernel-boundary.test.ts` “none of them saw a kernel service, the database client or the HTTP request” |
262
+ | SE-4 | E | A member reads or manages the organisation's secrets, or reads any value over HTTP | a person manages their own; the organisation's need `eloxiv.secrets.manage`; values are never returned | `packages/testing/src/conformance/Secrets.ts` “lets a person manage their own secrets over HTTP, the organisation's only with eloxiv.secrets.manage, and never read a value”; `packages/testing/test/session-hold.test.ts` “refuses a secret's write once a sign-out committed while it waited” |
263
+ | SE-5 | R | Secret access is not attributable, or the audit trail itself carries values | every read and write audited by name and scope, never by value | `packages/testing/src/conformance/Secrets.ts` “audits every read and write by name and scope, never by value”; `packages/testing/test/session-commit.test.ts` “audits a secret's write refused after sign-out (Sol: a 401 with no audit row)” |
264
+ | SE-6 | I | A compromised key keeps decrypting after rotation | rotation re-encrypts every secret; the retired key can go and alone reads nothing | `packages/testing/src/conformance/Secrets.ts` “rotates: every secret is re-encrypted under the current key with new ciphertext, the retired key can go, and it alone no longer reads” |
265
+ | SE-7 | I | A provider token is sent to an origin the connector does not declare, or follows a redirect off it | requests only to declared origins; a redirect off them is followed without the token | `packages/testing/test/connections-http.test.ts` “refuses a request to an origin the connector does not declare, sending nothing”; `packages/testing/test/connections-http.test.ts` “follows a redirect off the declared origins without the token” |
266
+ | SE-8 | E | A member who left keeps using their Connection, or another member uses it | membership re-checked on every use; only the owner uses it; disconnect deletes the tokens at once | `packages/testing/src/conformance/Connections.ts` “re-checks the owner's membership on every use: a member who left cannot use the Connection, and nothing reaches the provider”; `packages/testing/src/conformance/Connections.ts` “lets only the owner use a Connection”; `packages/testing/src/conformance/Connections.ts` “disconnects: its tokens are deleted at once and it is never used again; only its owner or an administrator may disconnect it” |
267
+ | SE-9 | I | Credentials, record values or emails leave through telemetry, error reports or data exports | span attributes, errors and analytics allowlist-only; exports carry no credential material | `packages/testing/src/conformance/Telemetry.ts` “never exports a credential, a record value, an e-mail address or a user id, and only allowlisted attributes”; `packages/testing/src/conformance/Telemetry.ts` “reports an unexpected failure to Sentry with only its tag, the invocation id and the tag's fixed message”; `packages/testing/test/kernel-inventory.test.ts` “exports no credential material” |
268
+ | SE-10 | S | Tokens of a consent whose session ended during the code exchange are saved, or revoked in a way that destroys another active Connection's grant | nothing is saved after sign-out; such tokens are revoked at the provider only where that ends nothing else | `packages/testing/test/session-hold.test.ts` “saves no credentials once a sign-out committed while it exchanged the code (Sol: tokens saved after sign-out)”; `packages/testing/test/session-hold.test.ts` “discards, never revokes, such tokens when an active Connection holds the same provider account (Sol: a completed consent destroyed)” |
269
+ | SE-11 | I | Setup's one-time owner passwords leak into traces | setup sends a SCRAM verifier, in no traced statement | `packages/testing/test/owner-login.test.ts` “sends only a SCRAM verifier, in no traced statement” |
270
+ | SE-12 | I | Server-side request forgery: an endpoint someone chose (an endpoint Connection's server, an MCP server, an OpenAPI base, a model key's base URL) reaches a private or link-local address, by name or by redirect | only https to public addresses, judged on the literal address and on what a name resolves to (IPv4-mapped and NAT64 forms included), unless the deployment allows the host; each redirect hop judged again | `packages/kernel/test/destinations.test.ts` “refuses every address that is not public, in either family and in IPv4-mapped or NAT64 form”; `packages/kernel/test/destinations.test.ts` “allows https to a public address, refuses http, credentials, and a name resolving anywhere private”; `packages/testing/src/conformance/ToolSource.ts` “refuses an endpoint that is not public unless the deployment allows its host, sending nothing”; `packages/testing/src/conformance/HttpApi.ts` “refuses a redirect to an address that is not public” |
271
+ | SE-13 | I | A request to an endpoint someone chose follows a redirect to another origin, carrying the endpoint's credential or body there (distinct from SE-7, which covers connector-declared provider origins) | the guarded fetch of endpoint Connections and model endpoints refuses a redirect to another origin outright (`connections/Destinations.ts`), so the second origin receives neither; the OpenAPI connector follows one only without its secret | `packages/kernel/test/destinations.test.ts` “refuses a redirect to another origin, so the second endpoint receives neither the credential nor the body”; `packages/testing/src/conformance/HttpApi.ts` “follows a redirect to another origin without the secret” |
272
+ | SE-14 | E | An agent (or a prompt that steers one) sends the person's secret to an endpoint it picks, or a member uses a secret that is not theirs | each add and grant an agent makes waits for the person's consent; a secret is sent only if it is the caller's and its destinations allow the endpoint | `packages/testing/src/conformance/ToolSource.ts` “never lets an agent send the person's secret to an endpoint it picks: each add and grant waits for the person”; `packages/testing/src/conformance/ToolSource.ts` “refuses a secret that is not the caller's, missing, or restricted to other origins, before anything is sent” |
273
+ | SE-15 | E | A shared Connection keeps serving a member whose grant was revoked, or tools it does not allow | a request checks its grant again when it runs, sending nothing once revoked; only allowed tools are listed or sent | `packages/testing/src/conformance/ToolSource.ts` “refuses a request that waited for a slot once the grant it waited under is revoked, sending nothing”; `packages/testing/src/conformance/ToolSource.ts` “exposes only the tools the Connection allows: others are neither listed nor sent” |
274
+ | SE-16 | E | An external MCP server's tools (their descriptions, their results) steer the agent into acting | an agent's tool call is held for the person's consent and sends nothing until approved; an OpenAPI write likewise | `packages/testing/src/conformance/ToolSource.ts` “holds an agent's tool call for the person's consent, sending nothing until approved”; `packages/testing/src/conformance/HttpApi.ts` “holds every agent's write for the person's consent” |
275
+ | SE-17 | I | The deployment's push credentials (the APNs key, the FCM service account) leak to a device, a log or an error, or are sent to an endpoint a caller chose | configuration only (redacted), signed into short-lived provider and access tokens; endpoints are the deployment's; no channel message, delivery error or audit record carries a credential or a device token | Limit: proven by construction and review (`packages/kernel/src/notifications/Providers.ts`); no test reads the kernel's logs for them |
276
+
277
+ ## Merged since the first version
278
+
279
+ These branches were being built when this map was first written; each has merged into build/main, and its threats are in the tables above.
280
+
281
+ - **build/identity** (sign-up, invitations and joining, password reset, email verification, provider sign-in, two-factor): ID-13 (verified-only identity in policy) and ID-15 to ID-20.
282
+ - **build/connections-mcp** (endpoint and shared Connections, the outbound destination policy, ToolSource over an `mcp` connector, HttpApi over `http-openapi`, managed secrets): SE-12 to SE-16. SE-7 stays as it was, for connector-declared provider origins; SE-13 is the endpoint Connections' own refusal of a redirect to another origin.
283
+ - **build/daemon-devices** (device control: terminal, files, browser-extension companion, push): DM-12 to DM-14.
284
+ - **build/push-kernel** (push installations, the APNs and FCM channel, decision tokens): ID-23 to ID-25, AP-11 to AP-16, SE-17.
285
+ - **build/harness-lifetime** (the test harness's process lifetimes, `packages/testing` and `tools/vitest`): it concerns the tests' own processes, not the daemon's harness turns, so DM-6 is unchanged.
286
+
287
+ ## Open items for the security review
288
+
289
+ - **SB-7** (blocking in the review; closed on build/make-view-isolation): a view's code now runs in the sandbox and reaches the browser only as a tree drawn where nothing runs or loads, so it cannot navigate its frame or load a URL; the regression sends what a listed action returned into every URL-bearing element and property and asserts that no request reaches the attacker's server. Narrowing: views are code returning a tree of a fixed element set (no images, external links, file inputs or submitted forms), and views written as HTML no longer render.
290
+ - **AP-3 changed behaviour** on this branch: an agent can no longer approve a business approval (MAKE installs included). The [Approvals](../contracts/approvals.md) contract recorded this as an open question; the review should confirm the choice (refusal rather than a consent hold) and that rejecting stays open to agents.
291
+ - **ID-13** (resolved): only a verified address is identity in policy, claims and joins (see ID-13, ID-15, ID-19).
292
+ - **ID-14** (resolved, backlog 44): session tokens are stored as their digests; a token read from the database signs no one in.
293
+ - **PO-14** is closed but for two limits the owner accepted (owner decision, 2026-11-16; backlog 1; scaffold known gap 11): a key the caller names discloses whether a record holds it (optimistic inserts take keys scoped to the caller from `recordKey`; closing it for every insert needs keys namespaced per caller); deleting a referenced record fails while the reference exists, whether or not the caller can read it (closing it needs cascades under the referencing records' policies or tombstones). **PO-15** is an accepted limit (scaffold known gap 10).
294
+ - **Agent prompt injection beyond consent.** Consent holds destructive and externally visible actions (sending mail, inviting, sharing), and governance is the person's own (AP-2, AP-3, ID-6, AP-8). A non-destructive action that is not consent-marked still runs on an agent's word; whether every module's consent marks are right is a per-module review (`registry/app/modules/*/contract.ts`).
295
+ - **Backlog 13** (resolved): an erasure replaces a person's mentions in the organisation's agent memory and resources, and purges export copies of them (`packages/testing/test/privacy-org-memory.test.ts`); a mention by other means (a one-word name, a paraphrase) is the stated limit.
296
+
297
+ ## Changing this document
298
+
299
+ Add a row when you add a mechanism that stops a plausible attacker, or find a threat; cite the test that would fail if the mitigation broke, or say why there is none after `Limit:`. Run `mise exec -- bun --bun vitest run --project done tools/done/test/threat-model.test.ts` to check the citations. Never weaken a mitigation to make a row pass; a row whose proof no longer holds is a finding.