@mago-foundation/mago-ski 0.2.0 → 0.3.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.
- package/README.md +30 -3
- package/dist/hosts/github/run.d.ts +3 -1
- package/dist/hosts/github/run.js +29 -9
- package/dist/hosts/pi/index.js +48 -5
- package/dist/src/admin.d.ts +136 -1
- package/dist/src/admin.js +221 -84
- package/dist/src/cli.js +335 -10
- package/dist/src/fs-safe.d.ts +15 -2
- package/dist/src/fs-safe.js +32 -3
- package/dist/src/gate/adapters/claude-code-hook.d.ts +1 -0
- package/dist/src/gate/adapters/claude-code-hook.js +4 -0
- package/dist/src/gate/adapters/claude-code-settings.d.ts +13 -0
- package/dist/src/gate/adapters/claude-code-settings.js +49 -0
- package/dist/src/gate/adapters/claude-code.d.ts +33 -0
- package/dist/src/gate/adapters/claude-code.js +193 -0
- package/dist/src/gate/adapters/client.d.ts +13 -0
- package/dist/src/gate/adapters/client.js +57 -0
- package/dist/src/gate/adapters/codex-hook.d.ts +1 -0
- package/dist/src/gate/adapters/codex-hook.js +5 -0
- package/dist/src/gate/adapters/codex-requirements.d.ts +19 -0
- package/dist/src/gate/adapters/codex-requirements.js +56 -0
- package/dist/src/gate/adapters/codex.d.ts +16 -0
- package/dist/src/gate/adapters/codex.js +574 -0
- package/dist/src/gate/adapters/hook-main.d.ts +7 -0
- package/dist/src/gate/adapters/hook-main.js +35 -0
- package/dist/src/gate/adapters/host-pid.d.ts +1 -0
- package/dist/src/gate/adapters/host-pid.js +20 -0
- package/dist/src/gate/admission.d.ts +54 -0
- package/dist/src/gate/admission.js +490 -0
- package/dist/src/gate/contract.d.ts +51 -0
- package/dist/src/gate/contract.js +94 -0
- package/dist/src/gate/decision-log.d.ts +38 -0
- package/dist/src/gate/decision-log.js +251 -0
- package/dist/src/gate/generations.d.ts +67 -0
- package/dist/src/gate/generations.js +518 -0
- package/dist/src/gate/proc.d.ts +31 -0
- package/dist/src/gate/proc.js +79 -0
- package/dist/src/gate/refresh.d.ts +11 -0
- package/dist/src/gate/refresh.js +30 -0
- package/dist/src/gate/run-verifier.d.ts +23 -0
- package/dist/src/gate/run-verifier.js +89 -0
- package/dist/src/gate/service.d.ts +80 -0
- package/dist/src/gate/service.js +722 -0
- package/dist/src/gate/strict-json.d.ts +11 -0
- package/dist/src/gate/strict-json.js +190 -0
- package/dist/src/gate/trust-store.d.ts +36 -0
- package/dist/src/gate/trust-store.js +251 -0
- package/dist/src/gate/verifier-worker.d.ts +8 -0
- package/dist/src/gate/verifier-worker.js +66 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/keys.d.ts +4 -0
- package/dist/src/keys.js +23 -14
- package/dist/src/policy.d.ts +145 -0
- package/dist/src/policy.js +554 -35
- package/dist/src/recovery-admin.d.ts +173 -0
- package/dist/src/recovery-admin.js +400 -0
- package/dist/src/root-events.d.ts +107 -0
- package/dist/src/root-events.js +376 -0
- package/dist/src/timestamp.d.ts +61 -0
- package/dist/src/timestamp.js +107 -0
- package/dist/src/tree-digest.d.ts +1 -0
- package/dist/src/tree-digest.js +1 -1
- package/dist/src/verify.d.ts +33 -0
- package/dist/src/verify.js +4 -2
- package/docs/hosts/adapter-interface.md +8 -2
- package/docs/hosts/github-action.md +1 -1
- package/docs/hosts/pi.md +2 -0
- package/docs/spec/gui-admin-rack-v1.md +289 -0
- package/docs/spec/root-recovery-v1.md +33 -12
- package/docs/spec/trust-documents-v1.md +8 -2
- package/docs/spec/verification.md +9 -2
- package/docs/threat-model.md +4 -2
- package/package.json +3 -1
|
@@ -28,6 +28,12 @@ const current = await hashFile(absolutePath, relativePath); // compare with res
|
|
|
28
28
|
await appendDecision(policy.decisionLogPath, decisionRecord(result, policy.mode, 'advertise'));
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
When `loadPolicyTrust` fails, report it once for the host (`trustFailureRecord`), not once per Skill. If the failure has `rootRevoked: true`, block every Skill **whatever the policy mode** (`effectiveMode(policy.mode, trust)` returns `enforce`): a root key revoked by a root event blocks in shadow mode too ([Root recovery](../spec/root-recovery-v1.md#revoked-root-blocked-in-every-mode)).
|
|
32
32
|
|
|
33
|
-
Claude Code
|
|
33
|
+
## Claude Code (built, not yet tested live)
|
|
34
|
+
|
|
35
|
+
The [Claude Code spike](../spikes/claude-code-interception.md) found that no hook can change the Skill list (H1) and that a project's settings can turn user hooks off, so enforcement needs managed settings. Without them, only shadow mode is possible.
|
|
36
|
+
|
|
37
|
+
The company gate (`src/gate/`, Linux only, not yet released) follows that finding with one change of store. Instead of a mago-ski plugin holding verified copies (the spike's proposal), the gate service installs approved Skills into Claude Code's admin-managed Skill folder (each `<folder>/<name>` is a link to the verified, read-only copy, removed on uninstall or revocation), and the generated managed settings (`src/gate/adapters/claude-code-settings.ts`) set `strictPluginOnlyCustomization: ["skills", "hooks", "agents", "mcp"]`, an empty `strictKnownMarketplaces` and `disableSideloadFlags`, so only managed-folder Skills load. Managed `PreToolUse` (Skill tool) and `UserPromptExpansion` (`/name`) hooks ask the service about every use (H2–H5) and block when it cannot answer. The plugin store stays a possible alternative; both kinds of Skill ran under the lock in our earlier tests. The [live test](../spikes/claude-code-gate-live.md) ran this setup against the real Claude Code 2.1.318 in non-interactive mode (`-p`), with the real service and hook: only gate-installed Skills (symlinks in the managed folder) were listed and loaded, planted and revoked Skills were denied by the hooks, and with the service stopped every use was denied. It passed as root and with Claude Code running as an unprivileged user. Interactive sessions and subagents are not covered by it yet.
|
|
38
|
+
|
|
39
|
+
The same gate serves Codex through `/etc/codex/requirements.toml` and the Codex hook adapter. Its [live test](../spikes/codex-gate-live.md) (codex-cli 0.163.0 and 0.166.0) shows weaker coverage. Codex has no Skill lock, and `deny_read` does not hide user Skills from its catalog, so repo and user Skills stay listed and only the hooks stop their use. The hooks did block every route tested, and failed closed. Because Codex always installs its own bundled Skills, an admin Skill can be invoked only by its linked mention `[$name](/etc/codex/skills/name/SKILL.md)`, never by a bare `$name`.
|
|
@@ -40,6 +40,6 @@ On pull requests, `policy.json`, `trust-root.json` and `revocations.json` are re
|
|
|
40
40
|
|
|
41
41
|
Symlinked Skill directories and symlinked `SKILL.md` files are reported as `UNVERIFIABLE`, not skipped (Pi follows such links). Discovery searches up to 16 directory levels below each `skill_dirs` entry. Anything deeper is reported as `UNVERIFIABLE` instead of being skipped: it fails the check in `enforce` mode and is reported in `shadow` mode. Discovery is bounded (1,000 Skills, 50,000 directory entries); a larger tree is reported as a single failure and no Skill is checked. Policy, trust and Skill directories must resolve inside their checkout.
|
|
42
42
|
|
|
43
|
-
The action writes a summary table to the job summary (at most 200 Skills, failures first) and an annotation on each failing Skill's `SKILL.md` (at most 50; a notice says when more were omitted, and the summary has the rest). In `shadow` mode it reports but does not fail. CI keeps no state file; rollback protection comes from reading trust documents from the protected base revision.
|
|
43
|
+
The action writes a summary table to the job summary (at most 200 Skills, failures first) and an annotation on each failing Skill's `SKILL.md` (at most 50; a notice says when more were omitted, and the summary has the rest). In `shadow` mode it reports but does not fail. When the trust documents fail (trust root, revocation list, root event log, timestamp), the summary has one line and no per-Skill rows; a root key revoked by a root event fails the check in `shadow` mode too. CI keeps no state file; rollback protection comes from reading trust documents from the protected base revision.
|
|
44
44
|
|
|
45
45
|
Run it alongside a capability scanner such as SkilLock: the scanner explains what changed, mago-ski makes sure someone approved exactly that.
|
package/docs/hosts/pi.md
CHANGED
|
@@ -27,6 +27,8 @@ Start in `"mode": "shadow"` to see what would be blocked (the decision log recor
|
|
|
27
27
|
| `grep` | Refused when it searches in or over an unverified Skill, or a verified Skill that has files excluded from its certificate (`.git`, ignored files, or an in-tree `.mago-ski-cert.json` that is not the certificate that verified the Skill). Otherwise the Skill is re-verified first and its exclusions checked again | Logged |
|
|
28
28
|
| `bash`, `powershell` | Refused when the command names an unverified Skill's directory; verified Skills it names are re-verified first. Best-effort (see the [threat model](../threat-model.md)) | Logged |
|
|
29
29
|
| Verification error | A Skill that cannot be checked is `UNVERIFIABLE`. If checking crashes outright, no Skills are advertised and file and shell tools touching any Skill path are blocked for that run | Logged |
|
|
30
|
+
| Trust documents fail (trust root, revocation list, root event log, timestamp) | Every Skill is blocked. One notice when the failure starts or changes, the status bar shows it, and one `trust-unavailable` decision record; no per-Skill notices or records | Same report, nothing blocked (`would-block`) |
|
|
31
|
+
| Root key revoked by a root event | Every Skill is blocked. Status bar: `mago-ski: ROOT KEY REVOKED - all Skills blocked`; one error notice and one `root-revoked` record | **Blocked as in enforce mode.** Switching to shadow mode does not help; only a rotate root event does |
|
|
30
32
|
|
|
31
33
|
Skill paths are shown to the model in Pi's Skill list and in the `/skill:` block, but the certificate does not cover the Skill directory, so a contributor can rename it. Below your working directory and your home directory, a Skill path may therefore use only `A-Z a-z 0-9 . _ / ~ @ + -`. A verified Skill with any other character in its path (spaces, non-ASCII letters, newlines, quotes, angle brackets) is not advertised and `/skill:` refuses it with a notice; rename or move the directory. The working and home directories themselves may contain spaces, but not control, quote or angle-bracket characters. Skill names are already limited to ASCII letters, digits, `.`, `_` and `-`.
|
|
32
34
|
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# GUI administration rack v1
|
|
2
|
+
|
|
3
|
+
Status: **draft.** Phase 1, hardened in phase 1.1 ([design](../design/gui-admin-hardening.md)), (the organisation pin, identity, the template framework and the *Approve a Skill version* template) and phase 2a ([design](../design/gui-admin-phase2.md): the engine for every root and timestamp write, and the *Manage approvers* template) are implemented in the GUI proof of concept (`gui/src/service/admin.ts`, `gui/src/renderer/admin.ts`, tests in `gui/tests/admin.test.ts`). Phase 2b (*Revoke*, *Refresh revocation list*, *Sign timestamp*) and phase 3 are specified here and not yet implemented. The CLI stays the reference for every operation: each device calls the same engine functions as the CLI command it names.
|
|
4
|
+
|
|
5
|
+
The [GUI](../../gui/README.md) began as a read-only companion: it showed how installed Skills change and what the host policy decides, and never signed anything. This document adds an **administration rack**, so approvers and administrators can do in the GUI everything they can do with the CLI, in fixed chains of devices (templates), next to the observation rack.
|
|
6
|
+
|
|
7
|
+
The GUI shows every text in Korean or English (see [the i18n design](../design/gui-i18n.md)); the Korean texts quoted in this spec are the Korean catalog entries in `gui/src/i18n/messages.ts`.
|
|
8
|
+
|
|
9
|
+
## Principles
|
|
10
|
+
|
|
11
|
+
1. **Authority is cryptographic.** What an approver or administrator can do is decided by the private keys they hold and by the signed trust documents, exactly as for the CLI. Hosts accept a certificate, trust root, revocation list or root event only if its signature verifies against the organisation's root. The GUI recognising a role is guidance and a safety interlock, never a source of authority: a modified GUI that shows an employee the root devices still cannot produce a document any host accepts.
|
|
12
|
+
2. **The organisation is identified by an admin-owned pin**, never by a file the person at the keyboard can edit (see [Organisation pin](#organisation-pin)).
|
|
13
|
+
3. **Fixed templates, not free patching.** The order of operations is part of a procedure (inspect before approving, check the policy after changing it). Each template is a fixed chain; devices cannot be reordered, skipped or added. This follows the ontology's rule that editing "must not allow arbitrary execution ordering that breaks mandatory gates" ([ontology §24.2](../mago-ski-ontology.md)).
|
|
14
|
+
4. **Enforcement is untouched.** The observation rack's APPROVAL GATE stays a locked device. Nothing in the administration rack changes what a host blocks except through signed documents, which hosts verify as before.
|
|
15
|
+
5. **Every signature binds what was shown, and needs two human answers.** A certificate is signed only for the exact digest and name a native review dialog recorded (the engine's `expectDigest` and `expectName`), and only after a second native dialog shows everything that is signed. Both dialogs belong to the main process; the page can ask, never answer. A changed Skill must be reviewed again.
|
|
16
|
+
|
|
17
|
+
## Organisation pin
|
|
18
|
+
|
|
19
|
+
The organisation pin is a **policy file** (`mago.policy/v1` or `mago.policy/v2`, [trust documents](trust-documents-v1.md)) at a fixed, admin-owned location:
|
|
20
|
+
|
|
21
|
+
| Platform | Path |
|
|
22
|
+
|---|---|
|
|
23
|
+
| Linux, macOS | `/etc/mago-ski/policy.json` |
|
|
24
|
+
|
|
25
|
+
The GUI reads the organisation's identity only from this file: `root_fingerprint`, and for a v2 policy the recovery set, `root_events_after`, `root_events` and `freshness`. There is no environment variable, setting or dialog to point it elsewhere, because anything the person at the keyboard can change could name a root they own.
|
|
26
|
+
|
|
27
|
+
**Ownership rules.** The pin is used only if:
|
|
28
|
+
|
|
29
|
+
- it is a regular file, not a symbolic link;
|
|
30
|
+
- it and every directory above it are owned by root (uid 0) and are not writable by group or others;
|
|
31
|
+
- no component of its path is a symbolic link;
|
|
32
|
+
- it loads as a valid policy;
|
|
33
|
+
- on Linux, the process is not in a user namespace: `/proc/self/uid_map` and `/proc/self/gid_map` each read exactly `0 0 4294967295` (whitespace aside). An unreadable map refuses too.
|
|
34
|
+
|
|
35
|
+
Otherwise admin roles are not recognised, and the administration rack says which rule failed and how to install the pin. Its documents (`trust_root`, `revocations`, `root_events`, `freshness.timestamp`) may live anywhere, because they are signed: a *forged* document fails verification against the pinned root. A genuine but *older* document still verifies; see [Replay and this computer's memory](#replay-and-this-computers-memory).
|
|
36
|
+
|
|
37
|
+
**macOS.** `/etc` is a symbolic link to `private/etc`. When `/etc` is a link whose target is exactly `private/etc`, the ownership walk runs on `/private/etc/mago-ski/policy.json` (and `/private` must be root-owned like any directory); the GUI shows that path. Any other `/etc` link is refused as a symbolic link.
|
|
38
|
+
|
|
39
|
+
**The user-namespace check is a hurdle, not a boundary.** A user in their own user namespace can map themself to uid 0 and own files that look root-owned, and can bind-mount over the map files inside that namespace. The check refuses the accidental and casual cases, and it refuses Flatpak, rootless containers and CI runners that use user namespaces: the administration rack is **not supported** in those. The pin's protection against the person at the keyboard ends where the operating system's does.
|
|
40
|
+
|
|
41
|
+
**NixOS.** `environment.etc` links files into the store, which the no-symbolic-link rule refuses. Install the pin as a real file: `environment.etc."mago-ski/policy.json".mode = "0644"`.
|
|
42
|
+
|
|
43
|
+
**Why a separate location.** The Pi host reads `$MAGO_SKI_POLICY` or `~/.mago-ski/policy.json`, which the user can edit. An employee who writes their own policy pinning their own key would be, to a GUI reading that file, the root of an organisation of their own. A root-owned pin removes that. A deployment that wants the employee's Pi to follow the same organisation sets `MAGO_SKI_POLICY=/etc/mago-ski/policy.json` for them. The GUI's observation rack keeps reading the policy Pi reads; when that differs from the pin, the administration rack says so.
|
|
44
|
+
|
|
45
|
+
Admin mode never reads or writes the policy's own host state (`state_file`) or the decision log. It keeps its own rollback memory in the GUI's user data folder; see [Replay and this computer's memory](#replay-and-this-computers-memory).
|
|
46
|
+
|
|
47
|
+
## Roles
|
|
48
|
+
|
|
49
|
+
The **role** of a key is computed from the pin and the signed documents each time it is needed:
|
|
50
|
+
|
|
51
|
+
| Role | The key is | Read from |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| **Root administrator** | the active root key: `root_fingerprint`, replaced by each rotate root event; and not revoked by a root event | pin; root event log |
|
|
54
|
+
| **Approver** | an approver in the trust root, verified under the active root; not expired; key not revoked in the revocation list | trust root; revocation list |
|
|
55
|
+
| **Recovery trustee** | in the active recovery set | pin; root event log |
|
|
56
|
+
| **Timestamp signer** | the active timestamp key | pin; root event log |
|
|
57
|
+
| none | none of the above | |
|
|
58
|
+
|
|
59
|
+
The trust documents already forbid one key from holding two of these roles, so a key has at most one. An approver role carries the approver's name, scopes and expiry. A root administrator whose trust root or revocation list does not verify is still recognised, because fixing those documents is that role's job.
|
|
60
|
+
|
|
61
|
+
## Identity: the IDENTITY device
|
|
62
|
+
|
|
63
|
+
Every administration template starts with an IDENTITY device. It is the only place a private key enters the app.
|
|
64
|
+
|
|
65
|
+
1. The user chooses a private key file in a **native file dialog owned by the main process**. The dialog counts as a dialog like the others: it is refused while another dialog is open, counts as open while it is shown, and a cancel starts the cooldown (the refusal texts are those under *Cooldown and timeout*). The renderer never sends a path and never receives key material.
|
|
66
|
+
2. The main process loads it with the engine's rules: regular non-symlink file, mode `0600` (no group or other access), PKCS#8 Ed25519.
|
|
67
|
+
3. **Proof of possession.** The main process signs a fresh 32-byte random challenge with the loaded key, under the domain-separated message `mago-ski gui identity v1\n<pinned root fingerprint>\n<challenge hex>\n`. It verifies the signature with the public key the documents name for the candidate role: the trust root's root or approver entry, a root event's `new_root`, a recovery or timestamp key's revealed public key. If no document carries the public key yet, it verifies with the public key derived from the private key, which must hash to the pinned fingerprint. A public key file, a key for another organisation, or a corrupt file fails here.
|
|
68
|
+
4. The device shows the role, the key id and, for an approver, the name, scopes and expiry. The key is now **armed**.
|
|
69
|
+
|
|
70
|
+
**Armed key lifetime.** The key object stays in the main process's memory only. It is never written to disk, logged, put on the clipboard or sent to the renderer. It is dropped when the user ejects it, when the template is closed or changed, after 15 minutes without an operation, when the pin changes or the key loses its role, when the window navigates, reloads, crashes or is destroyed, and when the app quits. Zeroing is best effort: the buffer the file was read into is zeroed after parsing; copies inside the crypto library cannot be.
|
|
71
|
+
|
|
72
|
+
**Synchronous disarm.** Dropping the key is one synchronous step: no key, a new *generation* number, no recorded reviews, no idle timer. It is never queued, so it cannot arrive after a signature. `disarm` (the eject button, a window event, the idle timer) calls it directly.
|
|
73
|
+
|
|
74
|
+
**Generations and the queue.** `arm`, `review`, `approve` and `reset-memory` run one after another through a queue. Each operation notes the armed key and the generation before its first wait and compares them after every later wait; a mismatch ends it with "키가 빠졌어요" and writes nothing. `status`, `inspect` and `check` are not queued and never wait for a dialog.
|
|
75
|
+
|
|
76
|
+
**Idle.** Only `arm`, `review` and `approve` count as use. `status`, `inspect` and `check` do not extend the idle time.
|
|
77
|
+
|
|
78
|
+
**Status re-check and polling.** `status` reads the pin and recomputes the role of the armed key; a change of the pin's bytes, or of the role's kind, key, scopes or expiry, drops the key. The page asks for the status every 5 seconds while the 관리 tab is visible, so a changed pin or a removed approver disarms within about 5 seconds without any operation.
|
|
79
|
+
|
|
80
|
+
**Window events.** The main process disarms on every navigation start, render-process crash, window destruction and every page load after the first.
|
|
81
|
+
|
|
82
|
+
**Re-check before every signature.** Before the signing dialog, and again inside the engine immediately before the certificate file is written (`beforeSign`), the main process recomputes the role from the current documents and the generation. An approver removed or revoked since arming cannot sign.
|
|
83
|
+
|
|
84
|
+
**Keys outside Skills.** A key whose real path is inside a discovery root, a discovered Skill folder, the pin's `skill_dirs` or the host policy's `skill_dirs` is refused when loading, as the CLI refuses it at signing ("Skill 폴더 안에 있는 키는 쓸 수 없어요. 키를 Skill 밖으로 옮기세요."); the same check runs again against the stored path, with the roots as they are then, before the signing dialog and in `beforeSign`. A key folder that became a discovery root after arming refuses with the same text.
|
|
85
|
+
|
|
86
|
+
**One key file.** `arm` resolves the chosen path to its real path, opens that with `O_NOFOLLOW`, checks on the open handle that it is a regular file, reads at most 64 KiB from that handle and loads the key from those bytes; it remembers the real path with the file's device and inode. The key file must be the same file, and must not be inside a Skill, both before the dialog and immediately before signing: `approve` checks that the path is still a regular file with the same device and inode (before the Skill-location checks, and again in `beforeSign`); otherwise the key is dropped and approve says "키 파일이 바뀌었어요. 다시 불러오세요."
|
|
87
|
+
|
|
88
|
+
**Lifetime.** The lifetime check uses the approver's expiry as the status re-check has just refreshed it, not the expiry seen at arming. Key load errors are fixed text and never carry the file's path.
|
|
89
|
+
|
|
90
|
+
**Root and recovery keys.** The root key's protection is that it stays offline. Arming a root or recovery key asks, in a native dialog, whether this is the offline administration computer; answering no or closing it does not arm the key. The dialog is shown after proof of possession and the role check, and before the key is armed. It counts as a dialog for the one-dialog and cooldown rules. A computer cannot prove it is offline: the dialog is a prompt, and an organisation should not load its root key on a machine used for everyday work.
|
|
91
|
+
|
|
92
|
+
## Templates
|
|
93
|
+
|
|
94
|
+
A template is a fixed chain of devices. Each device has typed inputs, produced by the device before it, and shows one of these states:
|
|
95
|
+
|
|
96
|
+
| State | Meaning |
|
|
97
|
+
|---|---|
|
|
98
|
+
| locked | The armed key does not hold the role this device needs (says which role) |
|
|
99
|
+
| waiting | An input is missing (says which, e.g. "inspect a version first") |
|
|
100
|
+
| ready | All inputs are present; the device can run |
|
|
101
|
+
| done | It ran; shows the result (a digest, a file written, a verdict) |
|
|
102
|
+
| failed | It ran and failed; shows the engine's error |
|
|
103
|
+
|
|
104
|
+
Changing an input (another Skill, a new digest) resets every device after it.
|
|
105
|
+
|
|
106
|
+
| Template | Chain | Role | CLI | Phase |
|
|
107
|
+
|---|---|---|---|---|
|
|
108
|
+
| **Approve a Skill version** | IDENTITY → INSPECT → APPROVE → POLICY CHECK | Approver | `digest --explain`, `diff`, `inspect`, `approve --expect-digest`, `verify` | 1 |
|
|
109
|
+
| **Manage approvers** | IDENTITY → TRUST ROOT → POLICY CHECK | Root | `root show`, `root add-approver`, `root remove-approver`, `root renew`, `policy check` | 2a |
|
|
110
|
+
| **Revoke** | IDENTITY → TARGET → REVOKE → POLICY CHECK | Root | `revoke key`, `revoke digest`, `policy check` | 2b |
|
|
111
|
+
| **Refresh revocation list** | IDENTITY → REVOCATION REFRESH → POLICY CHECK | Root | `revoke refresh`, `policy check` | 2b |
|
|
112
|
+
| **Sign timestamp** | IDENTITY → TIMESTAMP → POLICY CHECK | Timestamp signer | `timestamp sign`, `policy check`, `verify-all` | 2b |
|
|
113
|
+
| **Set up an organisation** | KEYS → ROOT INIT → RECOVERY SET → POLICY CHECK | none (creates the keys) | `keygen`, `root init`, `recovery init`, `root-events init`, `policy check` | 3 |
|
|
114
|
+
| **Root incident** | IDENTITY → ROOT EVENT → ADOPT → POLICY CHECK | Recovery trustees, then the new root | `root-events prepare-revoke`, `prepare-rotate`, `show`, `sign`, `append`, `root adopt`, `policy check` | 3 |
|
|
115
|
+
|
|
116
|
+
Every CLI command has a device: the observation rack's APPROVAL GATE already covers `verify`. *Set up an organisation* is the only template that runs without a pin, because there is no organisation yet; it ends by showing how to install the pin.
|
|
117
|
+
|
|
118
|
+
### Approve a Skill version (phase 1)
|
|
119
|
+
|
|
120
|
+
**IDENTITY** needs the Approver role.
|
|
121
|
+
|
|
122
|
+
**INSPECT** takes one Skill the GUI has discovered. It shows:
|
|
123
|
+
|
|
124
|
+
- the current tree digest and every covered file with its SHA-256, size and executable bit, plus the paths excluded from the digest (`digest --explain`);
|
|
125
|
+
- the change from the version the GUI remembered, when there is one (`diff`);
|
|
126
|
+
- the certificate the Skill carries, if any, decoded and verified (`inspect` and `verify`).
|
|
127
|
+
|
|
128
|
+
The digest, the name and the verdict are taken from one read of the Skill; if the verdict was computed for different bytes than the digest shown, the verdict is hidden ("읽는 동안 바뀌었어요 · 다시 검토하세요").
|
|
129
|
+
|
|
130
|
+
**Review dialog.** The page's *I reviewed this version* button only asks (`admin:review`). The main process re-reads the Skill and opens a **native dialog** (Skill name, folder, full digest, number of covered files; "이 정확한 버전의 파일을 모두 검토했나요?"; buttons 취소, the default, and 검토함). Only 검토함 records the review for that key, generation and Skill. If the Skill's bytes change afterwards, the review is void.
|
|
131
|
+
|
|
132
|
+
**APPROVE** takes the inspected digest. It shows the Skill name the certificate will carry (from `SKILL.md`, as `approve` does) and refuses to run if the approver's scopes do not cover that name. The approver picks a lifetime (30, 90 or 180 days, never past the approver key's own expiry) and writes a reason (trimmed; at most 1024 characters; plain text; at least 3 letters or digits, where Hangul fillers and the Braille blank do not count).
|
|
133
|
+
|
|
134
|
+
**Order inside `approve`.** (1) Note the armed key and generation; refuse if none is armed, if a dialog is open or in the cooldown. (2) Find the review record for this key, generation and Skill with the requested digest. (3) Check the reason and lifetime. (4) Re-check the role and the scopes against the reviewed name; the key file must be the same file and still outside every Skill. (5) Read the Skill once; its digest and name must equal the review's. (6) Check again that no dialog is open, claim the record (so a second approve cannot use it) and open the **signing dialog**: Skill, folder, reviewed digest, digest to be signed, lifetime and expiry, reason, and the key's role, name and id; buttons 취소 (default) and 서명. (7) On cancel or timeout, restore the record if the generation is unchanged and start the cooldown. (8) On 서명, call the engine's `approveSkill` with `expectDigest`, `expectName`, `outDir` and `beforeSign`. (9) A failure returns the engine's message, or fixed text if it could carry a path; the record stays consumed.
|
|
135
|
+
|
|
136
|
+
`expectName` refuses a Skill whose signed `SKILL.md` yields another name; `outDir` writes `<outDir>/<signed name>.cert.json` (the first `certificate_dirs` entry of the pin) from the name that was signed; `beforeSign` runs after the certificate is built and just before the file is written, and a throw writes nothing. Without `certificate_dirs` the certificate is written to `<Skill>/.mago-ski-cert.json`. The device shows the certificate id and path.
|
|
137
|
+
|
|
138
|
+
**Cooldown and timeout.** After a cancel or a timeout of either dialog, `review`, `approve` and `reset-memory` are refused for 10 seconds ("잠시 후 다시 시도하세요"), and while any dialog is open ("다른 확인 창이 열려 있어요"), so a compromised page cannot spam dialogs until one is clicked by mistake. A dialog unanswered for 120 seconds counts as a cancel; it may stay on screen, and a late answer is ignored. A dialog still open 5 seconds after that (125 seconds after it opened) no longer counts as open, so it cannot block other dialogs for ever.
|
|
139
|
+
|
|
140
|
+
**The remaining window.** `writeFileAtomic` awaits a few file operations after `beforeSign` returns. A disarm in that window does not stop the write. The certificate binds the reviewed digest, so the effect is a certificate the approver authorised a moment earlier.
|
|
141
|
+
|
|
142
|
+
**POLICY CHECK** verifies the Skill under the pin's policy, without recording versions, and shows the verdict. After a successful APPROVE it should be `VERIFIED`; anything else is shown with the engine's reason. It also shows the policy's trust status.
|
|
143
|
+
|
|
144
|
+
## Manage approvers (phase 2a)
|
|
145
|
+
|
|
146
|
+
Chain: IDENTITY → TRUST ROOT → POLICY CHECK. It needs the root role, which is also the role that may *review* (the review record format is the approve one: armed key, generation, instance). The online timestamp key is never armed in this session, which is why timestamps are their own template.
|
|
147
|
+
|
|
148
|
+
**Prepare, confirm, commit.** Every root and timestamp write is two engine calls. `prepare*` reads the current document once, verifies it under the active root, applies the change and returns the exact unsigned payload (version, `issued_at`, `expires_at` included), the SHA-256 of the bytes it read and what the dialog needs; it never signs or writes. After the native dialog, `commit*` re-reads the document and refuses if its SHA-256 changed (*The document changed in the meantime. Prepare it again.*), signs exactly the prepared payload, awaits the generation and role re-check (`beforeWrite`), and writes with `writeFileAtomic(..., { expectSha256 })`, which hashes the current file immediately before the rename. The documents named in the dialog are bound at commit. The GUI also hashes the pin, trust root, revocation list, root event log and timestamp when it prepares and again in `beforeWrite`.
|
|
149
|
+
|
|
150
|
+
**The remaining window.** A process that can write the document folder can still replace the file in the instant between the last hash check and the rename. Its write is then lost, or a later write replaces it. Hosts verify every document's signature and version, so the result is never an unsigned or older-than-memory document being accepted by this computer.
|
|
151
|
+
|
|
152
|
+
**TRUST ROOT** shows the approvers (name, scopes, expiry, key id), the version and the expiry, read directly from the file under the active root (no expiry check, so an expired trust root can be renewed). It offers:
|
|
153
|
+
|
|
154
|
+
- **Add**: the public key is chosen in a native open dialog (*Choose the approver's public key (PEM)*; it counts as a dialog), then name, scopes and a lifetime (90, 180 or 365 days, default 90). A key that is already an approver is *replaced*, and the dialog says so with the old and new name, scopes and expiry. A scope `*` adds *This scope lets the approver approve every Skill*.
|
|
155
|
+
- **Remove**: removing the last approver asks a second native confirmation (*No approvers will remain...*).
|
|
156
|
+
- **Renew**: re-signs the trust root with a new expiry (180 or 365 days, default 365) and the same approvers (`root renew` in the CLI).
|
|
157
|
+
- **Trust root lifetime** for add and remove: *Keep* (the default while the trust root has not expired), 180 or 365 days. While the trust root has expired, *Keep* is not offered, no value is preselected, and Add and Remove stay disabled until a lifetime is picked (the engine refuses a request without one). The choice returns to *Keep* after every successful write.
|
|
158
|
+
|
|
159
|
+
**Role separation.** The trust root may not list the root key, a recovery key, the timestamp key, a key that left the root or timestamp role in the walked root events, a key that left a recovery set in them, or a revoked key. The GUI computes this list (`forbiddenApproverKeys`) and refuses an add, a remove of another approver and a renew while such a key is listed; TRUST ROOT marks it (*<why>: this approver must be removed*) and offers only Remove for it. The CLI's `root add-approver --policy FILE` computes the same list; without `--policy` it behaves as before. When the root event log cannot be walked (rollback, fork, unreadable log, revoked root), every trust-root, revocation and timestamp write is refused before any dialog (*Cannot check the root event log, so the trust root is not changed* / *The root key is revoked...*).
|
|
160
|
+
|
|
161
|
+
**Versions and memory.** `prepare*` refuses a document older than this computer's memory (*This document is older than one this computer has already seen...*); an equal version is the normal case. The new version is the document's version plus one. After a successful commit the GUI records the new version in its memory (`recordDocumentVersions`), even when the organisation's trust cannot fully load yet. A failure to record gives *The signature was made, but this computer's memory could not be updated.* The memory reset dialog says that root document writes then take the documents now on disk as their base, and the first root or timestamp signature after a reset adds *This is the first signature since this computer's memory was reset...* to its dialog.
|
|
162
|
+
|
|
163
|
+
**Consequence.** Before signing, the dialog shows what the change does to the Skills this computer can see, computed the way hosts compute verdicts: one `loadPolicyTrust`-equivalent load of the current documents (*from*), one with the prepared document substituted in memory (*to*), and, when the pin has `freshness`, a third with the timestamp check skipped (the result once a new timestamp exists). The Skill set is every discovery root, the pin's `skill_dirs` and the host policy's `skill_dirs`, plus certificates from the pin's `certificate_dirs` and each Skill's own folder. The head reads *Skills affected: N (of M)*, followed by at most 5 lines `name: from → to` sorted by name and *and K more*. In an organisation with `freshness`, every Skill is blocked until a new timestamp: each line reads `name: from → blocked until a timestamp (after the timestamp: X)`, and the dialog adds *This organisation uses timestamps: hosts in enforce mode block every Skill until a new timestamp is signed.* When the current documents do not verify, the dialog shows *The current documents do not verify: <reason>* instead and Sign stays enabled. When the documents after the change would not verify for a reason a timestamp does not fix, the dialog is not opened and the write is refused with *After signing, the documents would not verify: <reason>*. Removing the last forbidden approver makes the *to* side pass, so this never blocks that fix.
|
|
164
|
+
|
|
165
|
+
**Dialog texts** are quoted in Korean in [the design](../design/gui-admin-phase2.md#decisions-v8); the English values are in the catalog. The signing dialog's lines, in order: document, current SHA-256, version, expiry, the action lines, the key line, the consequence, the permanence line (revoke only) and the freshness line.
|
|
166
|
+
|
|
167
|
+
**Expired and previous-root states.** An expired trust root shows *The trust root has expired* and Renew first. Documents signed by a previous root key (after a rotation they were not adopted) disable every writer before any dialog: *These documents are signed by a previous root key. Move them to the new root key with root adopt in the CLI. (GUI support comes in phase 3.)*
|
|
168
|
+
|
|
169
|
+
**POLICY CHECK** shows the counts by verdict over the same Skill set, the trust note, and, in an organisation with `freshness` whose timestamp does not name the new documents, *The timestamp does not name the new documents. Run the Sign timestamp template.*
|
|
170
|
+
|
|
171
|
+
## Revoke, Refresh revocation list and Sign timestamp (phase 2b)
|
|
172
|
+
|
|
173
|
+
The engine for these is complete in phase 2a (`prepareRevocationsChange`, `commitRevocations`, `prepareTimestamp`, `commitTimestamp`, `signPrepared*`). Every signing follows *Prepare, confirm, commit* above, with the same checks in the same places: the D9 refusals, the role check, the key file and key location checks, an input snapshot taken first, the root-walk refusal, the memory minimums, the consequence, the native dialog, and `beforeWrite` repeating the checks. Dialog texts are quoted in Korean in [the design](../design/gui-admin-phase2.md#decisions-v8) (v8 S3 and v12 P6/P8); the English values are in the catalog.
|
|
174
|
+
|
|
175
|
+
**When the current documents do not verify** (the normal state after a root write in a freshness organisation, and for an expired document the write fixes), every signing dialog shows *The current documents do not verify: <reason>* and then the result under the documents as they will be after signing: *VERIFIED n · other m* and one line per other verdict. It shows no consequence head, no lines and no *and K more* line. Sign stays enabled. For a trust-root or revocation write in a freshness organisation the counts are taken with the timestamp check skipped, and the freshness line is still shown.
|
|
176
|
+
|
|
177
|
+
### Revoke
|
|
178
|
+
|
|
179
|
+
Chain: IDENTITY → TARGET → REVOKE → POLICY CHECK. Role: root.
|
|
180
|
+
|
|
181
|
+
**TARGET** offers, and REVOKE accepts, only:
|
|
182
|
+
|
|
183
|
+
- **A current approver** in the trust root (label: the approver's name).
|
|
184
|
+
- **A digest the armed key reviewed in this generation.** The list shows every discovered Skill (`admin:revocation-skills`: instance id, name, tree digest or the read error, and whether a review record exists for the armed key, the generation, the instance and that digest), sorted by name and then id. Choosing one that is not reviewed shows its digest and a *Review* button, which opens the same native review dialog as *Approve* (the root role may review). After that the digest is offered. The digest revoked is the reviewed digest, not the Skill's current one.
|
|
185
|
+
- **Another key**, chosen with *Revoke another key...*: the button only chooses this target; the public-key picker opens (it counts as a dialog) when Revoke is pressed, after the refusals, and the target is that key's id, labelled *<key id> · not a current approver*. The dialog adds *Certificates naming this key: n*, the number of certificates found in the configured folders whose `approver_key_id` is that key. Targets are not taken from certificates: a certificate names only a key id, so the GUI cannot tell that a key it names is genuine, and a planted certificate must not be able to put a key on the list. The administrator chooses the key file deliberately.
|
|
186
|
+
|
|
187
|
+
The root, the recovery keys and the timestamp key are refused (*Root, recovery and timestamp keys cannot be revoked here.*); so is a key or digest that is already revoked (*Already revoked*) and a target that is none of the three above. A former root, timestamp or recovery key that signs certificates is revocable. A revoked approver stays in the trust root; TRUST ROOT then marks it and offers Remove.
|
|
188
|
+
|
|
189
|
+
**REVOKE** takes a reason (at most 512 characters, trimmed, display-safe, at least three letters or digits) and the new list's lifetime (7 or 30 days, default 30). Its dialog quotes the document, version, expiry, the key or version being revoked, the reason, the key line, the consequence and the permanence line (*Revocation cannot be undone. Every certificate this key signed will permanently fail verification.* or *... for this version ...*). Revoking a digest **claims** the review record before the dialog; if the dialog is cancelled, or the commit is refused while the generation is unchanged, the record is restored; a successful commit consumes it. *Approve* restores its claimed record in the same way.
|
|
190
|
+
|
|
191
|
+
### Refresh revocation list
|
|
192
|
+
|
|
193
|
+
Chain: IDENTITY → REVOCATION REFRESH → POLICY CHECK. Role: root. It re-signs the revocation list with the same entries, the next version and a new expiry (7 or 30 days, default 30; `revoke refresh` in the CLI). An expired list is accepted as the base, since refreshing is how it is fixed. The dialog shows the previous expiry, and in a freshness organisation the freshness line.
|
|
194
|
+
|
|
195
|
+
### Sign timestamp
|
|
196
|
+
|
|
197
|
+
Chain: IDENTITY → TIMESTAMP → POLICY CHECK. Role: timestamp signer. It is its own template because the online timestamp key must not be armed in the offline root session. The method refuses in this order, and the first failure decides:
|
|
198
|
+
|
|
199
|
+
1. the armed key does not hold the timestamp role;
|
|
200
|
+
2. the pin has no `freshness` (*This organisation does not use timestamps.*; the template is disabled);
|
|
201
|
+
3. the root is revoked (*The root key is revoked...*);
|
|
202
|
+
4. the trust root has expired (*The trust root has expired. Renew it in Manage approvers first.*);
|
|
203
|
+
5. the revocation list has expired (*...Run Refresh revocation list first.*);
|
|
204
|
+
6. no lifetime among 6, 12 and 24 hours is within `max_lifetime` (*The organisation's maximum timestamp lifetime is under 6 hours. Use the CLI.*; the template is disabled);
|
|
205
|
+
7. `prepareTimestamp` with the memory minimums: an unreadable current timestamp gives *The current timestamp cannot be read. Sign it in the CLI with --version.*, and a document older than memory gives the stale text;
|
|
206
|
+
8. the documents after signing would not verify (*After signing, the documents would not verify: <reason>*).
|
|
207
|
+
|
|
208
|
+
The root event walk used is the memory-checked one (`loadPolicyRoot` with `recordVersions: false`), repeated in `beforeWrite`. The dialog shows, for the root events, the trust root and the revocation list, a counter and the SHA-256, each marked *(first seen by this computer)* when the counter is above this computer's memory. The root-event counter is the walk's last sequence number; the trust root and revocation counters are their versions. A timestamp previously signed by another key is named (*The previous timestamp was signed by another key (<id>), version <n>.*) and the version line reads `none → memory + 1`. The dialog never shows the freshness line. The lifetime choices are those of 6, 12 and 24 hours within `max_lifetime` (default: the largest); the engine refuses a lifetime above the maximum.
|
|
209
|
+
|
|
210
|
+
After a timestamp commit the GUI records the timestamp version and then root-event progress by calling `loadPolicyRoot` once with `recordVersions: true`, so the first-seen marker for root events clears. If recording fails, the result says *The signature was made, but this computer's memory could not be updated.*
|
|
211
|
+
|
|
212
|
+
**TIMESTAMP** shows the key id, version and expiry parsed from the file without any key check, whether it parses, whether the documents it names are those on disk (`loadTrustForPreview` with the timestamp check on), and the maximum lifetime.
|
|
213
|
+
|
|
214
|
+
### Common to the three
|
|
215
|
+
|
|
216
|
+
**TRUST ROOT, REVOCATIONS and the preview never write.** A preview (`loadTrustForPreview`) and a refused write leave `admin-state.json` unchanged; only reads of the pin (`pin()`) record versions, as phase 1.1 decided, and signing methods use `recordVersions: false` for their own checks.
|
|
217
|
+
|
|
218
|
+
**POLICY CHECK** is the same view as in *Manage approvers*. When the timestamp does not name the new documents it says *The timestamp does not name the new documents. Run the Sign timestamp template.*
|
|
219
|
+
|
|
220
|
+
**Limits.** The consequence is a preview (see Limits). A planted certificate cannot make a key appear in TARGET; it only changes the certificate count for a key the administrator picked.
|
|
221
|
+
|
|
222
|
+
## Replay and this computer's memory
|
|
223
|
+
|
|
224
|
+
Signed documents say what was true when they were signed; a genuine older copy still verifies. A third party who can replace the documents (a share, a mirror) could replay an older trust root, revocation list or root event log, and bring back a removed approver or a rotated-out root key.
|
|
225
|
+
|
|
226
|
+
The GUI therefore keeps its own memory of the highest versions it has seen: `<user data folder>/admin-state.json`, in the engine's host state format (`mago.host-state/v1|v2`), written only by the engine. Every read of the pin records the versions of the root event log, trust root, revocation list and (with `freshness`) timestamp it accepted, and refuses older ones as a rollback. The organisation's own `state_file` is never read or written by admin mode.
|
|
227
|
+
|
|
228
|
+
- **First run.** The folder is created with mode `0700`; the first load records whatever the documents are.
|
|
229
|
+
- **Corrupt memory.** A memory file that does not parse, has the wrong format or counters, is over the size limit or is not a regular file is *corrupt*: it is renamed to `admin-state.json.unreadable-<time>`, the 관리 tab shows "이 컴퓨터의 관리 기록을 읽을 수 없어서 따로 보관하고 새로 시작했어요 (<path>)" until dismissed (`admin:dismiss-memory-reset`), and loading starts again with an empty memory.
|
|
230
|
+
- **Unreadable memory.** Any other read error (an I/O error, a permission error, a file that changes while being read) is *unreadable*, and nothing is renamed. The whole read is retried 3 times, after 50, 100 and 200 ms; if it still fails, the pin is invalid with "이 컴퓨터의 관리 기록을 지금 읽을 수 없어요. 잠시 후 다시 시도하세요."
|
|
231
|
+
- **Writes record versions.** After a successful trust root, revocation list or timestamp write the GUI records the new version in the memory (`recordDocumentVersions`: merge before write; a counter is not lowered within the retry budget described under *Writes*, and the write fails closed otherwise), so the next write starts from it. Admin checks use this memory (`loadPolicyTrust` with the memory as state file), not "without recording versions". A reset says that root document writes then take the documents now on disk as their base, and the next root or timestamp signature after it shows a warning in its dialog.
|
|
232
|
+
- **Legitimate reset.** If an organisation is re-initialised with the same root key, versions restart and the documents look older. The tab then says "이 컴퓨터가 이미 본 것보다 오래된 문서예요. 조직이 문서를 다시 만들었다면 기록을 초기화하세요." with a 기록 초기화 button, which asks in a native dialog and renames the memory aside.
|
|
233
|
+
- **A memory that cannot be written** makes the pin unusable ("이 컴퓨터의 기록을 저장하지 못했어요") and drops the armed key.
|
|
234
|
+
- **What it protects.** Accidental replay and replay by someone who can change the documents but not this user's profile. It does not protect against the user, who can delete or move it (including with `MAGO_SKI_GUI_DATA`). With `freshness` in the pin, the timestamp bounds replay for everyone.
|
|
235
|
+
- **Writes.** Writes to one memory file are serialised within the process (keyed by the file's canonical path, so two spellings of one file share a queue). Across processes each write is a compare-and-swap: it reads the raw bytes once, merges, and replaces the file only if it still has those bytes; if another process changed it, the write re-reads, merges and retries, up to 5 times with 10 to 80 ms jittered waits, then fails (the pin is unusable, as for any memory that cannot be written). Only a missing file counts as no memory when writing; any other read error fails the write.
|
|
236
|
+
- **Known limit.** The retry budget can run out under sustained contention from other processes; the write then fails rather than lowering a recorded version. Within one process, an unqueued status poll that overlaps a load while the root event log grows can report a transient rollback.
|
|
237
|
+
|
|
238
|
+
## Process boundaries
|
|
239
|
+
|
|
240
|
+
The window is sandboxed as before (context isolation, no Node integration, CSP `default-src 'none'; script-src 'self'; style-src 'self'`). Phase 1 adds these IPC calls; each checks that the call comes from the app's own page:
|
|
241
|
+
|
|
242
|
+
| Call | Arguments | Effect |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| `admin:status` | none | The pin's state and the armed role (never key material) |
|
|
245
|
+
| `admin:arm` | none | Opens the key dialog in the main process (refused like any dialog); returns the role or why it failed |
|
|
246
|
+
| `admin:disarm` | none | Drops the armed key at once (synchronous; ends any operation in progress) |
|
|
247
|
+
| `admin:inspect` | instance id | The INSPECT view of that Skill's current version |
|
|
248
|
+
| `admin:review` | instance id | Opens the native review dialog; records the review only if the human answers 검토함 |
|
|
249
|
+
| `admin:approve` | instance id, digest, lifetime, reason | Opens the native signing dialog and signs only after it is confirmed, if the digest is the recorded reviewed digest and the role re-check passes |
|
|
250
|
+
| `admin:check` | instance id | POLICY CHECK for that Skill |
|
|
251
|
+
| `admin:reset-memory` | none | Opens a native confirmation, then moves this computer's admin memory aside, drops an armed key; a refusal returns its message; `ok` means "not refused", so a cancel is `ok: true` |
|
|
252
|
+
| `admin:dismiss-memory-reset` | none | Clears the notice that the memory was moved aside |
|
|
253
|
+
| `admin:trust-root` | none | The TRUST ROOT view (unqueued; does not extend the idle time) |
|
|
254
|
+
| `admin:add-approver` | `{ name ≤ 128, scopes (1 to 64, each valid per the engine's scope rules), lifetime: 90d \| 180d \| 365d, trustRootLifetime?: 180d \| 365d }` | Opens the public-key picker, then the native signing dialog; writes the trust root only after it is confirmed |
|
|
255
|
+
| `admin:remove-approver` | `{ keyId, trustRootLifetime? }` | The same, for a removal (a second dialog for the last approver) |
|
|
256
|
+
| `admin:renew-trust-root` | `{ lifetime: 180d \| 365d }` | The same, for a renewal |
|
|
257
|
+
| `admin:verify-all` | none | POLICY CHECK over every Skill (unqueued) |
|
|
258
|
+
| `admin:revocations` | none | The revocation list view (unqueued) |
|
|
259
|
+
| `admin:revocation-skills` | none | The discovered Skills for TARGET: instance id, name, digest or error, reviewed (unqueued) |
|
|
260
|
+
| `admin:revocation-targets` | none | The targets REVOKE accepts: current approvers and reviewed digests (unqueued) |
|
|
261
|
+
| `admin:revoke` | `{ target: { kind: 'key', keyId } \| { kind: 'digest', digest, instanceId } \| { kind: 'other' }, reason ≤ 4096 raw, lifetime: 7d \| 30d }` | Opens the native signing dialog (and, for `other`, the public-key picker first); writes the revocation list only after it is confirmed |
|
|
262
|
+
| `admin:refresh-revocations` | `{ lifetime: 7d \| 30d }` | The same, for a refresh |
|
|
263
|
+
| `admin:timestamp` | none | The TIMESTAMP view (unqueued) |
|
|
264
|
+
| `admin:sign-timestamp` | `{ lifetime: 6h \| 12h \| 24h }` | The same, for a timestamp; needs the timestamp role |
|
|
265
|
+
|
|
266
|
+
The renderer cannot name a file, a key or a directory in any of them. A compromised renderer cannot cause a signature without both native dialogs being answered by a human: it can ask for them, and after a cancel or a timeout it is refused for 10 seconds.
|
|
267
|
+
|
|
268
|
+
## Limits
|
|
269
|
+
|
|
270
|
+
- **A compromised machine sees an armed key.** Same-user malware can read the main process's memory while a key is armed. Arm keys briefly; never arm the root key on a machine used for everyday work.
|
|
271
|
+
- **The pin's protection is file ownership.** Anyone with root on the machine can replace the pin, as they can replace the host policy.
|
|
272
|
+
- **Pi with a user-writable policy stays user-trusted.** The pin protects the GUI's notion of the organisation, not a Pi host whose own policy the employee controls; point Pi at the pin (`MAGO_SKI_POLICY`) or use the [gate](../hosts/adapter-interface.md).
|
|
273
|
+
- **Key holders can always use the CLI.** The GUI's dialogs and checks bind the GUI, not the key: whoever holds an approver key can sign with `mago-ski approve`. Authority is cryptographic.
|
|
274
|
+
- **The user-namespace check is a hurdle**, not a boundary (see [Organisation pin](#organisation-pin)); Flatpak, rootless containers and user-namespace CI runners are unsupported.
|
|
275
|
+
- **A copy or hard link of the key inside a Skill is not detected.** A moved key fails the stored-path check at signing. The private-key scan at signing covers the files the digest covers, as in the CLI.
|
|
276
|
+
- **The memory does not protect against the user** (see above).
|
|
277
|
+
- **Retired keys are known only from walked events.** A key retired before `root_events_after` is not known to a host or to the GUI. The host check refuses a trust root that lists a key retired in the events the host walked (`trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`); the gate's trust store (`src/gate/trust-store.ts`) calls `loadTrustContext` directly and does not check this.
|
|
278
|
+
- **Former recovery keys.** The GUI and `root add-approver --policy` refuse a key that left a recovery set in the walked events as an approver; hosts do not check this. For former recovery keys, no host refuses a document it accepted before. While a former recovery key is listed as an approver, the GUI marks it and allows only removing it, hosts keep accepting the trust root, and `root renew` and `root remove-approver` in the CLI do not check it.
|
|
279
|
+
- **Upgrade note for retired keys.** The host check for retired root and timestamp keys is the one deliberate exception to "no host refuses a document it accepted before":
|
|
280
|
+
|
|
281
|
+
> Before upgrading hosts, open the TRUST ROOT view in a GUI of the new version: it marks any approver whose key has held the root or timestamp role. Remove those approvers (`mago-ski root remove-approver`), and in an organisation that uses timestamps, sign a new timestamp afterwards (`mago-ski timestamp sign`). In an organisation that uses timestamps, remove the approvers and sign the new timestamp in one sitting: between the two, hosts block every Skill. Hosts that use `loadPolicyTrust` (the CLI, Pi, the GitHub Action and the gate's verifier) refuse a trust root that still lists such an approver, and in enforce mode block every Skill. The gate's trust store does not check this.
|
|
282
|
+
- **The consequence is a preview.** The consequence shown before signing is computed when the change is prepared, from the Skill folders and certificates found then, and with this computer's memory as the version minimums. A host with its own newer state, or with other certificate folders, can report different verdicts. Only the documents named in the dialog are bound at commit.
|
|
283
|
+
- **No hardware keys yet.** Keys are PEM files, as for the CLI.
|
|
284
|
+
|
|
285
|
+
## Phases
|
|
286
|
+
|
|
287
|
+
1. This document; the organisation pin; IDENTITY; the template framework; *Approve a Skill version*.
|
|
288
|
+
2. **2a:** the engine for every root and timestamp write (prepare, commit, `root renew`, `root add-approver --policy`, retired-key host check), these spec changes, and *Manage approvers*. **2b:** *Revoke*, *Refresh revocation list*, *Sign timestamp* (GUI only; the engine is complete in 2a; built).
|
|
289
|
+
3. *Set up an organisation*, *Root incident*.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Root recovery v1
|
|
2
2
|
|
|
3
|
-
Status: **
|
|
3
|
+
Status: **normative, implemented in mago-ski 0.3** (unreleased; `src/root-events.ts`, `src/timestamp.ts`, `src/policy.ts`, `src/recovery-admin.ts`). Hosts that read policy v2: the CLI, the Pi host and the GitHub Action. The E3 gate service keeps its own pinned root for now (see [Not covered yet](#not-covered-yet)).
|
|
4
4
|
|
|
5
5
|
In v1, every host trusts one pinned root key and nothing above it. If the root private key leaks, whoever holds the copy can sign trust roots and revocation lists that every host accepts, and the only remedy is to edit the policy on every host by hand ([threat model](../threat-model.md)).
|
|
6
6
|
|
|
@@ -146,7 +146,7 @@ Envelopes are DSSE, as for [certificates](skill-certificate-v1.md), with one dif
|
|
|
146
146
|
| `action` | `revoke` or `rotate` |
|
|
147
147
|
| `root_key_id` | The root key the host trusts just before this event (see [Host processing](#host-processing)). A revoke names the key it revokes; a rotate names the key it replaces |
|
|
148
148
|
| `issued_at` | UTC timestamp. Not more than 5 minutes in the future, and not earlier than the previous event's `issued_at` |
|
|
149
|
-
| `reason` | Non-empty text, at most 1024 characters, no control characters
|
|
149
|
+
| `reason` | Non-empty text, at most 1024 characters. Shown in verdict reasons, notifications and block messages the model reads, so it must be plain text: no control, format (bidirectional marks, zero-width and tag characters, soft hyphens), surrogate, private-use or unassigned code points, no line or paragraph separators and no variation selectors |
|
|
150
150
|
| `signers` | The recovery keys that sign: sorted by `key_id`, unique. Each `public_key` must hash to its `key_id` |
|
|
151
151
|
| `new_root` | Rotate only. The new root key; `public_key` must hash to `key_id` |
|
|
152
152
|
| `new_recovery` | Rotate only. The recovery set trusted after this event, with the same rules as the policy's `recovery`. It may equal the current set |
|
|
@@ -171,6 +171,7 @@ Let *current set* be the recovery set in force just before the event.
|
|
|
171
171
|
- `new_root.key_id` must not be any key that an earlier event revoked or replaced. A key that has left the root role never returns.
|
|
172
172
|
- `new_root.key_id` may equal `root_key_id` only if that key is not revoked. This changes the recovery set or the timestamp key without changing the root (for example, when a trustee leaves or the timestamp key leaks).
|
|
173
173
|
- `new_timestamp.key_id` must not be the current or new root key, must not be in the current or new recovery set, and must not be a timestamp key that an earlier event replaced.
|
|
174
|
+
- `new_root.key_id` must not be the current or new timestamp key, and `new_recovery` must not contain the current root key, the current timestamp key, or any key that an earlier event revoked or replaced. **A key that has left the root or timestamp role never takes any role again**, so a leaked key cannot come back as a recovery key. Hosts only know the keys replaced by events they walk (after `root_events_after`).
|
|
174
175
|
|
|
175
176
|
### Rules for a revoke
|
|
176
177
|
|
|
@@ -257,7 +258,9 @@ Walking the full log keeps hosts without state correct, but hosts load trust doc
|
|
|
257
258
|
2. Check rollback and forks against the host state. Otherwise `UNVERIFIABLE`.
|
|
258
259
|
3. If the active root is revoked, every Skill is blocked: see [Revoked root](#revoked-root-blocked-in-every-mode). Nothing else is read.
|
|
259
260
|
4. With `freshness`, check the timestamp against the files. Otherwise `UNVERIFIABLE`.
|
|
260
|
-
5. Check the trust root and the revocation list as in v1, except that they must be signed by the **active root** instead of `root_fingerprint`. The trust root is also `UNVERIFIABLE` if any approver's key is in the active recovery set or is the
|
|
261
|
+
5. Check the trust root and the revocation list as in v1, except that they must be signed by the **active root** instead of `root_fingerprint`. The trust root is also `UNVERIFIABLE` if any approver's key is in the active recovery set, is the active timestamp key, or is a key that has held the root or timestamp role in the walked events (`trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`). Only events after `root_events_after` are walked, so only keys retired in them are known. Hosts do not refuse a former recovery key listed as an approver; the GUI and `root add-approver --policy` refuse it as a new approver. The gate trust store (`src/gate/trust-store.ts`) does not run this check.
|
|
262
|
+
|
|
263
|
+
Before upgrading hosts, an organisation removes such approvers; see the upgrade note in the CHANGELOG.
|
|
261
264
|
6. Record the new state.
|
|
262
265
|
|
|
263
266
|
### Revoked root: blocked in every mode
|
|
@@ -267,6 +270,8 @@ When the active root is revoked:
|
|
|
267
270
|
- Every Skill is blocked, in **both `enforce` and `shadow` mode**. No policy setting changes this.
|
|
268
271
|
- The reason names the event, for example `root key sha256:... was revoked by root event 1 (root.pem appeared in a public CI log); waiting for a rotation`.
|
|
269
272
|
- The only way back is a rotate event. Switching the policy to shadow mode does not help.
|
|
273
|
+
- **A revoke the host has applied stays in force while the log cannot be checked.** The host state records that the last applied event left the root revoked. If the log later goes missing, becomes malformed, shorter (rollback) or forked, the host still reports `root-revoked`, not `trust-unavailable`, so damaging the log cannot lift a revoke on a shadow-mode host. Only a valid log that ends in a rotate clears it.
|
|
274
|
+
- Hosts load trust before anything the checked content can influence: the Pi host before expanding a `/skill:` command it has not seen yet, the GitHub Action before Skill discovery (whose budget a pull request controls).
|
|
270
275
|
|
|
271
276
|
Shadow mode means "approvals may be incomplete, so observe instead of blocking". It assumes the trust anchor is sound. A revoke is a signed statement by the organization's trustees that the anchor is not, so observing is no longer a safe choice. Making the block independent of the mode also removes the tempting shortcut during the outage, "switch to shadow so people can work", which would let through anything the leaked key signed.
|
|
272
277
|
|
|
@@ -303,7 +308,10 @@ Host state version 2:
|
|
|
303
308
|
}
|
|
304
309
|
```
|
|
305
310
|
|
|
306
|
-
(Written as canonical JSON; shown indented here.)
|
|
311
|
+
(Written as canonical JSON; shown indented here.) A `root_events` entry also carries `"revoked": true` when the last applied event left the root revoked (see [Revoked root](#revoked-root-blocked-in-every-mode)); the field is absent otherwise.
|
|
312
|
+
|
|
313
|
+
- **When progress is recorded.** Root event progress is recorded as soon as the log passes the walk and the rollback and fork checks (step 2 of [Order of checks](#order-of-checks)), even if a later step fails or the root is revoked: the events are signed by recovery keys, and remembering a revoke is what stops a host being moved back to a log without it. Trust root, revocation list and timestamp versions are recorded only when every step passes. Only events the host checked are recorded: with `root_events_after` = N, nothing is recorded until the log has more than N events, so an unchecked event cannot be pinned and later reported as a fork.
|
|
314
|
+
- **Shared state files.** Several processes on one host may share a state file (two Pi sessions, Pi and the CLI). Before writing, a host re-reads the file and merges: every version keeps its highest value, the `root_events` entry with the higher `sequence` wins (on a tie with a different digest, the entry already in the file stays, so the fork is reported on the next load), and a v2 file is never written back as v1. If the merged state has applied more events than the log this load read, the load fails as a rollback.
|
|
307
315
|
|
|
308
316
|
- `root_events` has one entry per pinned `root_fingerprint`. `event_digest` is `sha256:` + the hex SHA-256 of the last applied event's envelope, serialized as canonical JSON with its trailing LF.
|
|
309
317
|
- **Rollback:** if the log has fewer events than the recorded `sequence`, it is `UNVERIFIABLE`. This stops a host from being moved back to a log without the revoke.
|
|
@@ -352,9 +360,9 @@ Recovery private keys never sit next to `root.pem`, never in CI, and are used on
|
|
|
352
360
|
|
|
353
361
|
For freshness, run the timestamp job every 6 hours with a 24-hour lifetime, and keep the timestamp key in a different system from the root key.
|
|
354
362
|
|
|
355
|
-
## Commands
|
|
363
|
+
## Commands
|
|
356
364
|
|
|
357
|
-
|
|
365
|
+
Rotations need several trustees who may be in different places, so signing is split into *prepare*, *sign* and *append*, like a TUF root signing ceremony. Every command that reads the log takes the organization's policy (`--policy`), which names the log and the starting keys. A proposal lists its signers up front, because the signatures cover that list.
|
|
358
366
|
|
|
359
367
|
```
|
|
360
368
|
mago-ski recovery init --public-key a.pub --public-key b.pub --public-key c.pub \
|
|
@@ -362,24 +370,32 @@ mago-ski recovery init --public-key a.pub --public-key b.pub --public-key c.pub
|
|
|
362
370
|
mago-ski root-events init --out root-events.json # empty log
|
|
363
371
|
|
|
364
372
|
# Revoke: one trustee is enough with revoke_threshold 1
|
|
365
|
-
mago-ski root-events prepare-revoke --
|
|
373
|
+
mago-ski root-events prepare-revoke --policy policy.json --signer-public a.pub --reason TEXT --out proposal.json
|
|
366
374
|
mago-ski root-events sign proposal.json --key a.pem
|
|
367
|
-
mago-ski root-events append proposal.json --
|
|
375
|
+
mago-ski root-events append proposal.json --policy policy.json
|
|
368
376
|
|
|
369
377
|
# Rotate: the new root and two trustees sign the same proposal
|
|
370
|
-
mago-ski root-events prepare-rotate --
|
|
378
|
+
mago-ski root-events prepare-rotate --policy policy.json --new-root-public r1.pub \
|
|
379
|
+
--signer-public a.pub --signer-public b.pub \
|
|
371
380
|
[--new-recovery-public KEY.pub ... --rotate-threshold N --revoke-threshold N] \
|
|
372
381
|
[--new-timestamp-public t2.pub] --reason TEXT --out proposal.json
|
|
373
382
|
mago-ski root-events sign proposal.json --key r1.pem
|
|
374
383
|
mago-ski root-events sign proposal.json --key a.pem
|
|
375
384
|
mago-ski root-events sign proposal.json --key b.pem
|
|
376
|
-
mago-ski root-events append proposal.json --
|
|
385
|
+
mago-ski root-events append proposal.json --policy policy.json
|
|
386
|
+
|
|
387
|
+
# Keep a key that held another role out of the trust root: pass the policy
|
|
388
|
+
mago-ski root add-approver --policy policy.json --root-key r1.pem --trust-root trust-root.json --public-key alice.pub --name Alice --scope '*' --expires 180d
|
|
389
|
+
|
|
390
|
+
# After a rotate: re-sign the trust root and revocation list with the new root (approvers and entries are kept)
|
|
391
|
+
mago-ski root adopt --root-key r1.pem --from-root-fingerprint sha256:<R0> \
|
|
392
|
+
--trust-root trust-root.json --revocations revocations.json
|
|
377
393
|
|
|
378
394
|
# Freshness: run by the timestamp job every 6 hours
|
|
379
395
|
mago-ski timestamp sign --policy policy.json --key timestamp.pem --expires 24h
|
|
380
396
|
```
|
|
381
397
|
|
|
382
|
-
`append` checks every rule a host would check, so a log that `append` accepts is a log hosts accept. `timestamp sign` reads the files the policy names, signs their digests with the next `version`, and writes the policy's `freshness.timestamp` file.
|
|
398
|
+
Before signing, each trustee runs `mago-ski root-events show PROPOSAL --policy policy.json`, which prints what the event does (action, number, root key, new keys, thresholds, reason) and checks that it is the next event of the published log, and compares it with what was agreed through a channel other than the one that delivered the proposal. `sign` prints the event it signed, refuses a key the event does not list, and with `--policy` refuses a proposal that is not the next event of the published log. `append` checks every rule a host would check, on the whole new log, so a log that `append` accepts is a log hosts accept; it refuses an event with a missing signature. `timestamp sign` reads the files the policy names, checks that the trust root and revocation list are signed by the active root, signs their digests with the next `version`, and writes the policy's `freshness.timestamp` file. `root adopt` keeps every approver of the old trust root: review them before publishing, because a leaked root key may have been used to add some.
|
|
383
399
|
|
|
384
400
|
Before rolling a v2 policy out to hosts, or after appending an event, the organization checks it the way a host would:
|
|
385
401
|
|
|
@@ -389,9 +405,14 @@ mago-ski policy check --policy policy.json
|
|
|
389
405
|
|
|
390
406
|
`policy check` loads the policy, walks the root event log, checks the timestamp if `freshness` is set, verifies that the trust root and revocation list are signed by the active root and that no approver holds another role, and prints the active keys and both thresholds. It exits non-zero on any problem, so it can gate the rollout.
|
|
391
407
|
|
|
408
|
+
## Not covered yet
|
|
409
|
+
|
|
410
|
+
- **E3 gate service** (`src/gate/`): its trust store pins one root fingerprint and accepts trust roots and revocation lists from its inbox, without root events or timestamps. A follow-up adds both to the inbox and the trust-state manifest. Its verifier worker (`src/gate/verifier-worker.ts`, not yet wired into the service) already loads v2 policies through `loadPolicyTrust`, but turns `rootRevoked` into a per-Skill `UNVERIFIABLE`; the follow-up must make it block in every mode.
|
|
411
|
+
- **Early warning** before a timestamp expires (open question 2) is not implemented.
|
|
412
|
+
|
|
392
413
|
## Changes to other documents
|
|
393
414
|
|
|
394
|
-
|
|
415
|
+
Applied with the implementation:
|
|
395
416
|
|
|
396
417
|
- **[Trust documents](trust-documents-v1.md):** the root-key line under *Key rotation* points here. The host policy and host state sections gain the v2 fields. The decision log section gains the `root-revoked` and `trust-unavailable` records.
|
|
397
418
|
- **[Verification](verification.md):** *Order of checks* starts with the steps in [Order of checks](#order-of-checks) above, and step 1 checks against the active root instead of the pinned fingerprint. The note on shadow mode gains the revoked-root exception.
|
|
@@ -24,7 +24,7 @@ An organization's trust is anchored in one **root key**, kept offline. Hosts pin
|
|
|
24
24
|
|
|
25
25
|
- `version`: positive integer, increased on every change. Hosts with a configured state file reject versions lower than those recorded there.
|
|
26
26
|
- `root.public_key` must hash to `root.key_id`, which must equal the pinned fingerprint and the envelope's `keyid`.
|
|
27
|
-
- `approvers`: sorted by `key_id`, unique, at most 256. The root key may not also be an approver.
|
|
27
|
+
- `approvers`: sorted by `key_id`, unique, at most 256. The root key may not also be an approver. With root recovery, a host also refuses (`UNVERIFIABLE`) a trust root that lists an approver whose key has held the root or timestamp role in the root events the host walked: `trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`. Only keys retired in events after `root_events_after` are known, and the gate trust store does not check it. Before upgrading, remove such approvers (see the CHANGELOG).
|
|
28
28
|
- `scopes`: sorted, unique, 1–64 per approver. `*` matches every Skill name; `prefix*` matches names starting with `prefix`; anything else matches one exact name.
|
|
29
29
|
|
|
30
30
|
## Revocation list
|
|
@@ -75,6 +75,8 @@ Hand-edited JSON, read by hosts and the CLI. Paths are relative to the policy fi
|
|
|
75
75
|
| `state_file` | no | Rollback protection (below). Strongly recommended on hosts. Must resolve to a file inside the policy file's directory |
|
|
76
76
|
| `decision_log` | no | JSON Lines file of decisions, one JSON object per line. Must resolve to a file inside the policy file's directory (after following symbolic links); it is opened without following symbolic links and must be a regular file. Records are data, not shell syntax: do not source them |
|
|
77
77
|
|
|
78
|
+
Policy `mago.policy/v2` adds `recovery`, `root_events`, `root_events_after` and `freshness` for root recovery; see [Host policy v2](root-recovery-v1.md#host-policy-v2). Without `recovery`, a v2 policy behaves exactly as v1. `root_events` and `freshness.timestamp` are inputs too: `state_file` and `decision_log` must not be either of them.
|
|
79
|
+
|
|
78
80
|
The policy itself decides who is trusted, so it must live where the code under review cannot change it. The Pi host and the CLI read it only from `MAGO_SKI_POLICY` (an absolute path) or `~/.mago-ski/policy.json`, and the CLI also accepts an explicit `--policy FILE`; the GitHub Action reads it from the pull request's base revision.
|
|
79
81
|
|
|
80
82
|
## Host state (rollback protection)
|
|
@@ -87,6 +89,8 @@ Canonical JSON written by the host:
|
|
|
87
89
|
|
|
88
90
|
The host records the highest versions it has accepted for each root and rejects older documents as `UNVERIFIABLE` (rollback). Without a state file, a host can be given an older, still-unexpired trust root or revocation list.
|
|
89
91
|
|
|
92
|
+
With root recovery, the host writes `mago.host-state/v2`, which adds the root event progress per pinned root and the timestamp version per timestamp key ([Rollback and forks](root-recovery-v1.md#rollback-and-forks)). A host keeps writing v1 until it applies its first root event or timestamp, and never goes back to v1 once it has written v2.
|
|
93
|
+
|
|
90
94
|
## Decision log
|
|
91
95
|
|
|
92
96
|
One JSON object per line:
|
|
@@ -97,7 +101,9 @@ One JSON object per line:
|
|
|
97
101
|
|
|
98
102
|
`action` is `allow`, `block` or `would-block` (shadow mode). `certificate_id` is the SHA-256 of the certificate file.
|
|
99
103
|
|
|
104
|
+
A failure of the trust documents (trust root, revocation list, root event log or timestamp) affects every Skill, so hosts write **one** record when it starts or changes, instead of one per Skill: `event` is `root-revoked` or `trust-unavailable`, `skill` and `skill_dir` are empty, `digest` and `certificate_id` are null, and `verdict` is `UNVERIFIABLE`. `root-revoked` is always `block`, in shadow mode too ([Revoked root](root-recovery-v1.md#revoked-root-blocked-in-every-mode)).
|
|
105
|
+
|
|
100
106
|
## Key rotation
|
|
101
107
|
|
|
102
108
|
- **Approver keys:** add the new key (`root add-approver`), re-approve the Skills, then remove the old key (`root remove-approver`). Certificates from a removed approver stop verifying once a host reads the updated trust root; revoke the old key instead if it may be compromised.
|
|
103
|
-
- **Root key:**
|
|
109
|
+
- **Root key:** with a v2 policy and a recovery set, the root key is revoked and replaced by root events signed by recovery keys, without editing host policies: [Root recovery v1](root-recovery-v1.md). After a rotate, `mago-ski root adopt` re-signs the trust documents with the new root. With a v1 policy, replacing the root still means distributing a new fingerprint to every host.
|
|
@@ -14,11 +14,18 @@ Status: draft, implemented by mago-ski 0.1 and later (`src/verify.ts`). Verdict
|
|
|
14
14
|
| `EXPIRED` | The certificate, the approver key, the trust root or the revocation list has expired | Renew the expired item |
|
|
15
15
|
| `UNVERIFIABLE` | Something could not be checked: malformed or tampered documents, a trust root not signed by the pinned key, rollback, unreadable Skill files | Fix the input; treat as blocked |
|
|
16
16
|
|
|
17
|
-
Every verdict except `VERIFIED` blocks on supported hosts in enforce mode. Shadow mode allows it and records `would-block` in the decision log when one is configured (the GitHub Action reports instead).
|
|
17
|
+
Every verdict except `VERIFIED` blocks on supported hosts in enforce mode. Shadow mode allows it and records `would-block` in the decision log when one is configured (the GitHub Action reports instead). One exception: a root key revoked by a root event blocks in shadow mode too ([Revoked root](root-recovery-v1.md#revoked-root-blocked-in-every-mode)).
|
|
18
18
|
|
|
19
19
|
## Order of checks
|
|
20
20
|
|
|
21
|
-
Trust documents, once per host check:
|
|
21
|
+
Trust documents, once per host check. With root recovery (a v2 policy with `recovery`), these come first ([Order of checks](root-recovery-v1.md#order-of-checks)):
|
|
22
|
+
|
|
23
|
+
- Walk the root event log from the policy's starting keys. A missing, malformed or invalid log is `UNVERIFIABLE`.
|
|
24
|
+
- Check the log against the host state: fewer events than already applied (rollback) or a different event at the recorded number (fork) is `UNVERIFIABLE`.
|
|
25
|
+
- If the active root is revoked, every Skill is blocked, **in shadow mode too**; nothing else is read.
|
|
26
|
+
- With `freshness`, the timestamp must be signed by the active timestamp key, unexpired, within `max_lifetime`, not older than the host state records, and must name exactly the files read. Otherwise `UNVERIFIABLE`.
|
|
27
|
+
|
|
28
|
+
The steps below then use the **active root** (the pinned root, replaced by each rotate event) instead of the pinned fingerprint, and the trust root is also `UNVERIFIABLE` if an approver is a recovery key or the active timestamp key.
|
|
22
29
|
|
|
23
30
|
1. The trust root's envelope is signed by the pinned root fingerprint, names that root, and its signature is valid. Otherwise `UNVERIFIABLE`.
|
|
24
31
|
2. The trust root has not expired. Otherwise `EXPIRED`.
|
package/docs/threat-model.md
CHANGED
|
@@ -20,6 +20,8 @@ mago-ski answers one question: **is the Skill this agent is about to use the exa
|
|
|
20
20
|
| **Path aliases**: `@/path`, `file://` URLs, Unicode spaces or filename variants that Pi's tools resolve to a Skill file | The Pi host resolves tool paths the same way Pi's tools do before matching them |
|
|
21
21
|
| **Verification errors** | The Pi host fails closed in enforce mode: a Skill that cannot be checked is `UNVERIFIABLE`, and if checking crashes outright, file and shell tools that touch any Skill path are blocked |
|
|
22
22
|
| **Pull request trusting itself**: a PR adds its own root or approver | The GitHub Action reads policy, trust root and revocation list from the protected base revision |
|
|
23
|
+
| **Compromised root key** (with a v2 policy and a recovery set) | Any `revoke_threshold` recovery keys revoke the root by a signed root event: hosts that read it block every Skill, in shadow mode too. `rotate_threshold` recovery keys and the new root then replace it, without editing host policies. The thief cannot undo or forge either event. Limits: [What each leak allows](spec/root-recovery-v1.md#what-each-leak-allows) |
|
|
24
|
+
| **Frozen host** (fed old documents to hide a revoke, with `freshness` on) | A short-lived timestamp names the exact current files; once the newest one expires (24 hours by default), the host trusts nothing until it gets current files |
|
|
23
25
|
| **Tampered documents** | Canonical JSON with exact fields and Ed25519 signatures over DSSE: a changed document fails verification. Malformed documents and invalid signatures are `UNVERIFIABLE`; a change caught by an earlier check (for example a different Skill name or signer) reports that check's verdict instead |
|
|
24
26
|
|
|
25
27
|
## What it does not protect against
|
|
@@ -29,13 +31,13 @@ mago-ski answers one question: **is the Skill this agent is about to use the exa
|
|
|
29
31
|
- **Shell commands that reach Skill files indirectly.** In Pi, `bash` and `powershell` are checked by matching Skill paths in the command text. Relative paths after `cd`, globs, variables or encoded paths can evade it. In enforce mode, the guarantees that hold are: unverified Skills are not advertised, `/skill:` cannot load them, and the structured file tools (`read`, `grep`, `edit`, `write`, `find`, `ls`) refuse their files. `find` and `ls` may still list file names inside verified Skills; in an unverified Skill they are removed from the results (a `bash` `ls` or `find` is not filtered). Names of files a verified Skill excludes from its certificate can still appear.
|
|
30
32
|
- **Other code in the agent process.** A hostile Pi extension, MCP server or custom tool runs with the same permissions as mago-ski and can read files directly or change the Skill list after mago-ski filters it. Load mago-ski last and only trusted extensions.
|
|
31
33
|
- **A compromised host.** Root or same-user malware can change files, the policy, the state file or the extension itself. This includes racing directory replacement between path resolution and reading; the digest re-checks file identity, but a same-user attacker controls the file system.
|
|
32
|
-
- **A compromised root key.**
|
|
34
|
+
- **A compromised root key without a recovery set.** With a v1 policy (or a v2 policy without `recovery`), everything chains to the root key, and recovering from a leak means editing every host's policy. Set up [root recovery](spec/root-recovery-v1.md). With it, `rotate_threshold` leaked recovery keys can still take over, and without `freshness` a thief who holds the root key and controls delivery to a host can keep it on an old log.
|
|
33
35
|
- **Files excluded from the digest** (`.skilldigestignore`, root `.git`) are not approved. The Pi host refuses to read them from a verified Skill, but other tools may still use them.
|
|
34
36
|
- **Windows.** Not supported yet. Windows has no POSIX executable bit, so it cannot reproduce Linux and macOS digests; see the [digest spec](spec/skill-tree-v2.md).
|
|
35
37
|
|
|
36
38
|
## Revocation timing
|
|
37
39
|
|
|
38
|
-
Revocation is not instant everywhere. A host acts on a revocation once it reads the updated list. Until then it accepts its current list for as long as that list is unexpired, so the list's lifetime (30 days by default, set with `--expires`) is the longest a revoked certificate can still pass. Shorten it for high-risk organizations and republish often (`revoke refresh`). The host state file stops a host from being moved back to an older list. In CI there is no state file; the Action reads the list from the protected base revision, so a revocation applies to pull requests once it is merged there.
|
|
40
|
+
Revocation is not instant everywhere. A host acts on a revocation once it reads the updated list. Until then it accepts its current list for as long as that list is unexpired, so the list's lifetime (30 days by default, set with `--expires`) is the longest a revoked certificate can still pass. Shorten it for high-risk organizations and republish often (`revoke refresh`). The host state file stops a host from being moved back to an older list. In CI there is no state file; the Action reads the list from the protected base revision, so a revocation applies to pull requests once it is merged there. With `freshness` in a v2 policy, the bound drops to the timestamp's `max_lifetime` (24 hours by default): a host that is not given the new list stops trusting the old one when its timestamp expires.
|
|
39
41
|
|
|
40
42
|
## Assumptions
|
|
41
43
|
|