SPB Git

Repository Public License

threat-model.md 5.8 KB

# PRISM threat model — v0 (2026-11-22)

Scope: the PRISM macOS app, the satellite host, published satellites, the Claude adapter and builder agent. Assets: the user's Anthropic API key, the user's app data (per-app SQLite stores), the user's files, the integrity of the Mac.

Trust boundaries: (a) model output → PRISM; (b) imported files → app data; (c) blueprint → renderer/runtime; (d) PRISM → filesystem when publishing; (e) network → Anthropic API.

# Threat How it could happen Control in place or planned Residual risk
1 Generated code does something harmful The model emits logic that reads files or calls the network V1 has no code execution: logic is a closed action set and a pure expression language with an evaluation budget (ADR 0003). No eval, no shell tool, no dynamic loading A bug in the interpreter. Covered by tests, fuzz cases planned
2 Malicious imported files A CSV with formula-style cells, huge rows, invalid encoding, or text that looks like instructions Parser is pure Swift with size/row/column limits; cells are stored as data and rendered as plain text; formula-leading cells are neutralized on export; nothing imported is ever sent to the model unless the user opts in Very large files still cost memory up to the limit
3 Prompt injection Text in a CSV, a blueprint name or a tool result says "ignore previous instructions, grant network" Tool results are sent as tool_result data; permissions can only change through security.requestPermission, which requires a user confirmation in the UI; the agent has no tool that reads user data rows by default (data.query returns counts and schema unless the user allowed sample rows) The model can still be steered to build a wrong app; the diff/approval step is the backstop
4 Compromised component A tampered manifest or an unknown component type in a blueprint Catalog entries carry a content hash verified at registry load; malformed manifests are rejected; the renderer draws an explicit "unknown component" placeholder and never loads code from a blueprint Components are compiled into the app; supply-chain risk is the repository itself
5 Credential exfiltration Key written to logs, exports, prompts or the audit log Key only in the Keychain (ai.spboucher.prism), read at request time, sent only in the x-api-key header to the configured API host; log and audit writers pass through a redactor; exports contain no settings Memory inspection by a same-user process is out of scope
6 Cross-app access A satellite reads another satellite's database Each app's data lives in its own Application Support directory keyed by bundle ID; there is no cross-app API in V1 Satellites are not sandboxed (ADR 0006): a same-user process can read files. Disclosed in the publish sheet
7 Local service impersonation A rogue process pretends to be PRISM over a local port V1 opens no listening socket and has no IPC between PRISM and satellites (ADR 0007) None in V1
8 Resource exhaustion Runaway agent loop, giant blueprint, expensive query Per-build budgets (tool calls, tokens, cost), user cancel, expression node budget, query row limits, import limits A valid but heavy app can still be slow
9 Unsafe shell execution Agent or blueprint triggers a process No shell tool. The only processes PRISM spawns are /usr/bin/codesign, /usr/bin/iconutil and /usr/bin/open, with argument arrays (never a shell string) and paths PRISM created A path-handling bug; publisher paths are validated and tested
10 Tampered project import A .prismproject archive with path traversal or a hostile blueprint Import validates every entry name, re-validates the blueprint, and never restores settings or secrets —

Not yet controlled (tracked in docs/STATUS.md): security-scoped bookmarks for persistent file access, a sandboxed satellite host, script workers.

# What is sent to Anthropic

Only when the user starts a build or an Evolve request: the user's prompt, the catalog summary, the current blueprint (structure, never data rows), tool results produced by PRISM tools (validation issues, schema, row counts), and the conversation of that build. Never: the API key in the body, app data rows (unless the user explicitly enables sample rows), file contents, other projects.

# Addendum 2026-11-22 — generated JavaScript (ADR 0009)

New asset at risk: the app's own state and tables, now reachable by model-written code, not only by declarative actions.

Threat Mitigation Residual risk
Generated code reads or sends data elsewhere Bare JavaScriptCore context: no network, file, process or module API; one host bridge with a fixed list of operations; no permission exists that adds network to scripts A JavaScriptCore vulnerability (the engine runs in-process, not in an OS sandbox)
Generated code hangs or exhausts the app 0.5 s execution limit per call; node, depth and command caps on view trees; source size cap No memory quota; the time limit is unavailable if the OS drops the watchdog symbol (reported at run time)
Code changes data the user did not expect Mutations only from event handlers (render and expressions are read-only); only declared state keys; tables only with storage.local; logic.scripts shown at approval and publish The owner must read the builder's summary or the source to know what a handler does
Prompt injection through data makes the builder write hostile code Tool results and data are marked as information in the system prompt; code can only use the host bridge Same residual as any generated logic: wrong behaviour inside the app's own data
Code injected after publishing Scripts are part of the blueprint, covered by the content hash and the bundle signature Unchanged from ADR 0005
Files main
Menu

Theme