diff --git a/v3/docs/validation/adr-450-open-items-triage-2026-10.md b/v3/docs/validation/adr-450-open-items-triage-2026-10.md new file mode 100644 index 0000000000..f983ec185f --- /dev/null +++ b/v3/docs/validation/adr-450-open-items-triage-2026-10.md @@ -0,0 +1,138 @@ +# ADR-450 open items T2, T7, T10, T11, T14, T15: triage (2026-10-05) + +Read-only triage of the six threats that [ADR-450](../adr/ADR-450-mod-system-threat-model.md) section 9 lists as Open and that have no owner. T5 (PR #3777) and T13 (a worker) are excluded. Checked against `origin/main` at `040c70326`. No code was changed. + +How to read the evidence: **Reproduced** means I ran something. **Code-read** means I read the lines named and the behaviour follows from them without running. **Not tried** means exactly that. **(inference)** marks a claim I did not check. Scratch tests ran from the worktree against the main checkout's vitest and were deleted; nothing from them is committed. + +## Summary + +| T | Threat in one sentence | Still true on main | Fix size | Risk of fix | Who | +|---|---|---|---|---|---| +| T2 | A symlink or FIFO named `status.json` is read through the engine's `fs.read` | Not tried (needs the live engine); the code has no guard | ~10 lines + 1 test, if the engine exposes link kind | Low | Worker, after one engine probe | +| T7 | Nothing forbids a mod from forwarding another mod's status file into a prompt | Code-read: true, and no mod does it today | ~40-line test, no product change | None | Worker | +| T10 | A committed policy projection can switch ruflo's own rules off, and the band says nothing | Code-read: true | Two layers; the cheap one is ~15 lines, the real one needs signing | Cheap: low. Signing: medium | Cheap part worker; signing is a human decision | +| T11 | Any file writer can fake "guard on" for a mod that is not running | **Reproduced** | Cannot be closed inside this threat model; a labelling change is ~10 lines | Low | Human decision (accept or relabel) | +| T14 | In `ask` mode the model's own text sits in the confirm prompt the person answers | Code-read: true | ~50 lines across 5 files + spec | Low-medium (UI) | Worker, then drive the console | +| T15 | A prompt-injected Claude stores an instruction that a later session recalls as memory | Code-read: true; **a provenance mechanism already exists and is unused by recall** | ~30 lines for the plumbing | Medium (drops legacy memories unless decided) | Worker for plumbing, human for the `unknown` default | + +Recommended order: **T7, T14, T15 (plumbing), T10 (cheap layer), T2 (probe first), T11 (decision, no code).** The reasoning is under each item. + +## T2. Hostile `status.json` that is a link or a FIFO + +**Threat.** F (a process or file writer in the project) makes `.claude-flow/-mod/status.json` a symlink to a huge or blocking file, or a FIFO, and the console reads it through the engine. + +**Reproduces on main?** Not tried. The 14-payload content tests in ADR-450 T2 still stand (read in `hooks/data/mods.ts`: folder pattern, 60-folder cap, 8192-byte cap, `version === 1`, numeric coercion), so this item is only about the file's kind. What I verified: + +- `readBounded` (`ruflo-console/hooks/data/files.ts:68`) calls `fs.stat` and refuses a `size` above the cap before it reads. `ReaderFs.stat` is typed `{ mtimeMs?, size? }`: **no file kind and no `lstat`**. The ADR's "lstat if the host exposes it" is therefore not available through the type the console uses. +- `fs.list` entries do carry a `kind` string, and `data/mods.ts:113` already uses it (`entry.kind !== 'file'` for the folder level). Listing the mod folder and checking that the `status.json` entry's `kind` is `'file'` would be a link-free check, **if** the engine reports a symlink as something other than `'file'`. (inference: I did not find the engine's contract in the repo and did not try it.) +- Because `stat` follows a link, a link to a huge file reports the target's size and is refused; a link to a FIFO or a device reports size 0 and goes on to `fs.read`. Whether that blocks is engine behaviour (unverified, as in ADR-450). + +**Smallest fix.** In `data/mods.ts`, list each mod folder and require a `kind === 'file'` entry named `status.json` before reading it. About 10 lines plus one fake-fs test. Needs a one-time probe first: a throwaway mod calling `$.fs.list` on a folder holding a symlink and a FIFO, to see what `kind` says. + +**Risk.** Low. Failure mode is a mod row disappearing if the engine labels real files oddly, which the test and the probe cover. + +**Decision.** Worker, but only after the probe; if the engine reports a link as `'file'`, the fix does not exist at this layer and T2 moves to "engine behaviour, record and close". + +## T7. Cross-mod injection by forwarding + +**Threat.** One mod's status or command output reaches another mod's prompt context or the model. + +**Reproduces on main?** Code-read: the guard is still absent, and the hazard is still absent too. Facts: + +- Exactly two sources attach prompt context: `ruflo-agentdb/hooks/register.ts:180` and `ruflo-mods/hooks/route/index.ts:42` (`grep` for `context: [` over `plugins/*/hooks`). Neither names a `-mod/` path. +- Every `.claude-flow/-mod/` string in `plugins/*/hooks` is a writer's own `STATUS_PATH` (35 `status.ts` files) or the console's reader (`data/mods.ts`, `data/files.ts`). The console shows those rows to the model only through `console_state`, which runs every line through `plain(...)`. +- There is no test that would fail if a future mod began reading a neighbour's status file into `context`. + +**Smallest fix.** A conformance test (in `ruflo-console/tests/conformance.spec.ts` or the CLI `__tests__/mods` set) that walks `plugins/*/hooks/**/*.ts`, finds files that build `context` for `prompt.submit` or `session.start`, and fails if one also reads a `*-mod/` path other than its own `STATUS_PATH`. About 40 lines. It is a grep-level test and can be defeated by building the path from pieces; it is a tripwire, not a proof. + +**Risk.** None for product behaviour. It can only fail a build. + +**Decision.** Worker. Do it first: it is the cheapest and it holds the line while the others are decided. + +## T10. Policy projection written by A or F + +**Threat.** A committed `.claude-flow/policy/claude-code.json` makes ruflo's added rules inert and nothing tells the person. + +**Reproduces on main?** Code-read: yes. Facts: + +- `policyOpinion` (`ruflo-mods/hooks/guard/policy.ts:166`) returns `{}` for `mode === 'legacy'` or an empty rules list, and `{ wouldBe }` (no verdict) for `observe`. A valid `legacy` file parses (`parseProjection` accepts it). +- The projection is read from the project root (`under(state, PROJECTION_PATH)`, `guard/index.ts:53`), which A controls. +- The status band hides the mode for `none` and `legacy` (`state.ts:128`), so the spoofed case shows nothing; `observe` shows `policy observe` only when `statusLine` is on. +- **The CLI never writes a legacy file.** `projectionOf` returns `null` for legacy (`cli/src/mods/policy-projection.ts:38`) and `syncPolicyProjection` then *deletes* the file. So a projection that exists with `mode: "legacy"` was hand-written by definition. +- A file that is merely deleted, set to `observe`, or given an empty rules list is indistinguishable from a legitimate state. That part cannot be closed without a signature. + +**Smallest fix, two layers.** +1. Cheap (worker, ~15 lines + test): in `parseProjection`, reject `mode: "legacy"` so it takes the existing fail-closed path (`state.policy = 'unreadable'`, the call is put to the person), and show `policy ` in the band whenever a projection file exists and the mode is not `enforce`, not only when `statusLine` is on. This closes the one shape that is provably not CLI-written and makes the others visible. +2. Real (human decision): sign the projection with the config signing key, or read it only from user scope. The ADR names `ruflo-config-signing-key`; `cli/src/config/proven-config.ts` and `scripts/sign-proven-config.mjs` are the existing signing code (I read their names, not their contents). User scope conflicts with the CLI writing the projection per project (`syncPolicyProjection(projectRoot, ...)`), so it is a design change, not a patch. (inference on the conflict) + +**Risk.** Layer 1: low; a person who hand-wrote a legacy file now gets an ask prompt (a behaviour change they would notice, so say it in the release note). Layer 2: medium, it touches CLI and mod together and the release train (the CLI is bundled, `ruflo-mods` is not). + +**Decision.** Layer 1 worker; layer 2 human. + +## T11. Status-file spoof + +**Threat.** F writes `{"version":1,"guard":true,"blocked":0,"updatedMs":}` for a mod that is not running and the console shows "guard on". + +**Reproduces on main?** **Reproduced.** A scratch vitest calling `parseModStatus('foo-mod', '{"version":1,"guard":true,"blocked":0,"updatedMs":1}')` returned `{"name":"foo","guard":true,"calls":null,"blocked":0,"updatedMs":1,"startedMs":null}`: accepted, `guard: true`. Also: all 35 `ruflo-*/hooks/status.ts` writers are identical in shape and none carries a nonce or signature (`grep -L nonce`). + +**Smallest fix.** The ADR's per-session nonce cannot work as stated: the console and each mod are separate hook modules and the console has no channel to learn the mod's in-memory nonce except a file, and F can read that file too. Any secret F can read is not a secret. (inference from the architecture; I did not find a shared in-memory channel between mods and did not try one.) A real fix is a signature F cannot forge, which means a key F cannot read, which is outside what a same-user file writer is denied today. What is achievable and honest: label the Mods rows "reported by file, unauthenticated" and show file age (the console already does stale at 6 h), about 10 lines in `views/mods.ts`. + +**Risk.** Low for the relabel. A nonce would add 35 plugin edits (every `status.ts`) for no real gain. + +**Decision.** Human: accept the residual and relabel, or fund a signing design. I would recommend accepting. No worker until then. + +## T14. Confirmation prompt shows attacker-chosen text + +**Threat.** In `ask` mode the person answers a prompt whose label embeds model-written text, and nothing says the model asked or what class of action it is. + +**Reproduces on main?** Code-read: yes. Facts: + +- `confirmRow` (`ruflo-console/hooks/views/common.ts:351`) draws `Confirm: ?` and the argv. The one-line forms (`views/pane.ts:194`, the Room banner via `pendingBanner` in `data/room.ts:86`) draw `confirm needed: