@mago-foundation/mago-ski 0.3.0 → 0.4.1
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 +34 -10
- package/action.yml +21 -2
- package/dist/hosts/github/run.d.ts +9 -0
- package/dist/hosts/github/run.js +30 -16
- package/dist/hosts/pi/index.js +40 -18
- package/dist/src/admin.d.ts +2 -1
- package/dist/src/admin.js +3 -2
- package/dist/src/canonical-json.d.ts +6 -0
- package/dist/src/canonical-json.js +11 -0
- package/dist/src/cli.d.ts +13 -1
- package/dist/src/cli.js +426 -8
- package/dist/src/diff.d.ts +5 -0
- package/dist/src/diff.js +2 -1
- package/dist/src/dsse.js +2 -2
- package/dist/src/experimental/sigstore.d.ts +6 -0
- package/dist/src/experimental/sigstore.js +13 -5
- package/dist/src/gate/adapters/claude-code-settings.js +1 -1
- package/dist/src/gate/adapters/claude-code.js +1 -0
- package/dist/src/gate/adapters/codex-names.d.ts +1 -0
- package/dist/src/gate/adapters/codex-names.js +56 -0
- package/dist/src/gate/adapters/codex-requirements.d.ts +11 -0
- package/dist/src/gate/adapters/codex-requirements.js +56 -29
- package/dist/src/gate/adapters/codex.d.ts +3 -0
- package/dist/src/gate/adapters/codex.js +147 -20
- package/dist/src/gate/admin-client.d.ts +19 -0
- package/dist/src/gate/admin-client.js +62 -0
- package/dist/src/gate/generations.js +2 -0
- package/dist/src/gate/instance.d.ts +57 -0
- package/dist/src/gate/instance.js +97 -0
- package/dist/src/gate/proc.d.ts +6 -0
- package/dist/src/gate/proc.js +14 -3
- package/dist/src/gate/service.d.ts +13 -0
- package/dist/src/gate/service.js +344 -37
- package/dist/src/gate/setup.d.ts +210 -0
- package/dist/src/gate/setup.js +1038 -0
- package/dist/src/gate/trust-store.d.ts +14 -0
- package/dist/src/gate/trust-store.js +66 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +3 -1
- package/dist/src/policy.d.ts +7 -0
- package/dist/src/policy.js +19 -2
- package/dist/src/recovery-admin.js +7 -4
- package/dist/src/root-events.d.ts +2 -0
- package/dist/src/root-events.js +61 -4
- package/dist/src/tree-digest.d.ts +6 -0
- package/dist/src/tree-digest.js +8 -0
- package/docs/hosts/adapter-interface.md +1 -1
- package/docs/hosts/claude-code.md +108 -0
- package/docs/hosts/codex.md +181 -0
- package/docs/spec/gui-admin-rack-v1.md +1 -1
- package/docs/spec/root-recovery-v1.md +3 -2
- package/docs/spec/trust-documents-v1.md +1 -1
- package/docs/threat-model.md +13 -1
- package/package.json +3 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Codex host (the company gate and the mago-ski Codex profile)
|
|
2
|
+
|
|
3
|
+
The company gate is a root service that installs approved Skills into an admin-owned folder and answers Codex's hooks when a Skill is mentioned. For Codex it also writes two managed files, together called the **mago-ski Codex profile**, that switch off every Skill source an administrator can switch off.
|
|
4
|
+
|
|
5
|
+
Read this page before you enable enforce mode. Codex has routes that no hook sees, so **part of the enforcement is your organisation's job, not mago-ski's**. The section [What Codex leaves to your organisation](#what-codex-leaves-to-your-organisation) lists them.
|
|
6
|
+
|
|
7
|
+
Linux only. The profile was verified against Codex 0.166.x; `gate doctor` warns on any other version. Claude Code has its own guide: [claude-code.md](claude-code.md).
|
|
8
|
+
|
|
9
|
+
## The main limit, first
|
|
10
|
+
|
|
11
|
+
Codex lists every Skill folder it finds in a user's home and in the working folder. A Skill picked from Codex's menu, or sent as structured input by an IDE or app-server client, reaches the model **with no hook involved**. mago-ski can detect such a Skill folder. It cannot prevent the pick inside Codex.
|
|
12
|
+
|
|
13
|
+
So the control is that no Skill other than the administrator's is there to be listed:
|
|
14
|
+
|
|
15
|
+
- `gate doctor` FAILs when a listed home has a Skill folder. Run it on a timer.
|
|
16
|
+
- Repositories should require the [mago-ski GitHub Action](github-action.md) check.
|
|
17
|
+
- `gate init --lock-user-skill-folders` can make the user Skill folders empty and immutable (see below).
|
|
18
|
+
- The decision log has no record for a menu-picked Skill, which an audit can notice.
|
|
19
|
+
|
|
20
|
+
This route has not been tested by driving Codex's menu. The claims on this page about blocking are made for typed and linked mentions.
|
|
21
|
+
|
|
22
|
+
## What you need
|
|
23
|
+
|
|
24
|
+
- Linux with systemd, and root.
|
|
25
|
+
- Node.js and the `mago-ski` package installed system-wide, in root-owned folders. `gate init` refuses a per-user install and any package, node or host binary a user could edit.
|
|
26
|
+
- The real `codex` binary, root-owned.
|
|
27
|
+
- Your organisation's root fingerprint, its `trust-root.json` and `revocations.json`, and a certificate for each Skill you install.
|
|
28
|
+
|
|
29
|
+
## Set up
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 1. See what would be written and which homes are covered. Writes nothing, needs no root.
|
|
33
|
+
mago-ski gate init --host codex --root-fingerprint sha256:… --print
|
|
34
|
+
|
|
35
|
+
# 2. Write it (shadow mode by default).
|
|
36
|
+
sudo mago-ski gate init --host codex --root-fingerprint sha256:…
|
|
37
|
+
|
|
38
|
+
# 3. Start the service.
|
|
39
|
+
sudo systemctl daemon-reload && sudo systemctl enable --now mago-ski-gate@codex
|
|
40
|
+
|
|
41
|
+
# 4. Give the gate the organisation's trust documents.
|
|
42
|
+
sudo mago-ski gate trust --host codex --trust-root trust-root.json --revocations revocations.json
|
|
43
|
+
|
|
44
|
+
# 5. Install an approved Skill version.
|
|
45
|
+
sudo mago-ski gate install --host codex skills/docs-helper --certificate docs-helper.cert.json
|
|
46
|
+
|
|
47
|
+
# 6. Check the whole installation.
|
|
48
|
+
sudo mago-ski gate doctor --host codex
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Which homes the profile covers
|
|
52
|
+
|
|
53
|
+
The profile covers only the homes it is told about:
|
|
54
|
+
|
|
55
|
+
- `--user-home DIR` (repeatable) names a user's home. With none, `gate init` takes every home in `/etc/passwd` with uid 1000 or above and a login shell, and prints the list in its plan.
|
|
56
|
+
- `--codex-home DIR` (repeatable) names a non-default `CODEX_HOME`.
|
|
57
|
+
|
|
58
|
+
For each listed home, `gate init`:
|
|
59
|
+
|
|
60
|
+
- adds `<home>/.codex/skills`, `<home>/.codex/skills/.system` and `<home>/.agents/skills` to `deny_read`, so sandboxed shell commands cannot read them (`--no-deny-read` leaves this out);
|
|
61
|
+
- moves an existing `.codex/skills/.system` folder (Codex's bundled Skills) to `<home>/.codex/mago-ski-backup/system-<UTC>`, because the profile turns bundled Skills off.
|
|
62
|
+
|
|
63
|
+
When Codex runs with a `HOME` or `CODEX_HOME` that is not listed, the hook cannot tell where that user's Skills are, so it blocks every plain `$name` mention.
|
|
64
|
+
|
|
65
|
+
### Optional: lock the user Skill folders
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
sudo mago-ski gate init --host codex --root-fingerprint sha256:… --lock-user-skill-folders
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
In every listed home this makes `~/.agents`, `~/.agents/skills` and `~/.codex/skills` empty, root-owned and immutable (`chattr +i`), so a user cannot add a Skill there. The command stops if the filesystem cannot set the attribute. The lock does **not** cover:
|
|
72
|
+
|
|
73
|
+
- a `CODEX_HOME` the user points somewhere else;
|
|
74
|
+
- repository folders;
|
|
75
|
+
- a user renaming `~/.codex` and creating a new one. `~/.codex` itself cannot be locked because Codex writes there. `gate doctor` detects the new folder.
|
|
76
|
+
|
|
77
|
+
### What gate init writes
|
|
78
|
+
|
|
79
|
+
Besides the files every gate instance gets (see the [Claude Code guide](claude-code.md#set-up), with `codex` in place of `claude-code`):
|
|
80
|
+
|
|
81
|
+
| File | What it does |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `/etc/codex/requirements.toml` | Turns hooks on and pins plugins, remote plugins, apps and executor capability discovery off; registers the gate's hooks; carries `deny_read` for the listed Skill roots |
|
|
84
|
+
| `/etc/codex/managed_config.toml` | Turns off bundled Skills and cloud Skills, keeps Skill descriptions out of the prompt, and sets `project_root_markers = []` |
|
|
85
|
+
| `/etc/codex/skills/` | The managed Skill folder. Each installed Skill is a link to an immutable copy |
|
|
86
|
+
|
|
87
|
+
`/etc/codex/managed_config.toml` outranks user config, project config, profiles and `-c`. Both files are written in shadow mode too: they remove Skill sources, they do not block anything.
|
|
88
|
+
|
|
89
|
+
`project_root_markers = []` has a side effect: Codex scans only the working folder for repository Skills, and does not load a repository's `.codex/config.toml` when started in a subfolder.
|
|
90
|
+
|
|
91
|
+
## Skills must be named plainly
|
|
92
|
+
|
|
93
|
+
Codex names a Skill from its `SKILL.md` frontmatter. `gate install` therefore refuses a Skill unless its frontmatter:
|
|
94
|
+
|
|
95
|
+
- has exactly one top-level line `name: <name>`, unquoted, in plain ASCII, equal to the install name;
|
|
96
|
+
- has exactly one non-empty `description:` line;
|
|
97
|
+
- uses only plain `key: value` lines (no quotes, indentation, anchors or other YAML forms).
|
|
98
|
+
|
|
99
|
+
The refusal reads `SKILL.md must start its frontmatter with one plain line "name: <name>" so every host names it the same`. `gate install` also refuses a folder that contains a second `SKILL.md` below the top level.
|
|
100
|
+
|
|
101
|
+
## What it does
|
|
102
|
+
|
|
103
|
+
With the profile in enforce mode, for listed homes and listed `CODEX_HOME`s:
|
|
104
|
+
|
|
105
|
+
| Situation | Result |
|
|
106
|
+
|---|---|
|
|
107
|
+
| Skills from plugins, the cloud, executor discovery and Codex's bundled `.system` folder | Not loaded |
|
|
108
|
+
| Skill descriptions | Not put into the prompt |
|
|
109
|
+
| A typed `$name` for an installed, approved Skill, when no other Skill folder is present | Checked by the gate and allowed |
|
|
110
|
+
| A typed `$name` or a linked mention of anything that is not an installed, approved Skill | Blocked by the hook |
|
|
111
|
+
| A typed `$name` while a user or repository Skill folder exists, or the hook could not finish looking | Blocked: `A Skill with this name also exists outside your organisation's approved Skills, so a plain mention is blocked. Mention the approved Skill by its link, or remove the other Skill.` |
|
|
112
|
+
| A linked mention, `[$name](/etc/codex/skills/name/SKILL.md)` | Allowed only when the link resolves to the current installed copy. The text of the mention never selects the Skill |
|
|
113
|
+
| A plugin-namespaced mention, `$ns:name` | Blocked |
|
|
114
|
+
| An installed Skill that is revoked | Uninstalled when the gate receives the revocation, in every mode. Its name stays blocked |
|
|
115
|
+
| An installed Skill that expired, no longer matches, has a nested `SKILL.md` or a name that no longer matches | Hidden at the next check |
|
|
116
|
+
| Sandboxed shell reads of the listed user Skill roots | Refused by Codex's sandbox (`deny_read`) |
|
|
117
|
+
| The gate cannot be reached, or cannot verify | Blocked: the hook fails closed |
|
|
118
|
+
| The trust documents are expired, missing or rolled back | Every installed Skill is hidden until trust is valid again, and the decision log records it |
|
|
119
|
+
|
|
120
|
+
The hook looks for repository Skill folders in the working folder and every parent folder, while Codex (with the profile) scans only the working folder. A Skill folder in a parent folder therefore blocks plain mentions without Codex loading it.
|
|
121
|
+
|
|
122
|
+
In shadow mode nothing is blocked or hidden, except that a revocation still uninstalls. A Skill that expired or no longer matches stays installed and usable in shadow mode: the decision log records what would have been blocked, hidden (`would-hide`) or uninstalled (`would-uninstall`), and `gate status` lists the Skills it would uninstall.
|
|
123
|
+
|
|
124
|
+
### How quickly a change takes effect
|
|
125
|
+
|
|
126
|
+
- **A revocation** takes effect when the gate receives it: `gate trust` and `gate refresh` re-check every installed Skill at once.
|
|
127
|
+
- **An expiry** takes effect at the next periodic check, at most about 60 seconds later (longer while an admin command is running).
|
|
128
|
+
- **While the service is down** nothing is re-checked. Typed uses are blocked, because the hook cannot reach the gate. A menu pick of an already installed Skill during the outage is not checked. The unit restarts the service automatically, and `gate doctor` FAILs while it is down.
|
|
129
|
+
|
|
130
|
+
## What Codex leaves to your organisation
|
|
131
|
+
|
|
132
|
+
| What can still happen | Your organisation's control |
|
|
133
|
+
|---|---|
|
|
134
|
+
| A Skill folder created after a check is listed, and a menu pick of it reaches the model with no hook | Not prevented. Detected by `gate doctor` on a timer, by the GitHub Action on repositories, and by missing records in the decision log. Narrowed by `--lock-user-skill-folders` |
|
|
135
|
+
| A hook process crashes, times out or is killed, and Codex continues without it | Execution control (MDM or EDR). The decision log shows the missing decisions |
|
|
136
|
+
| A user runs their own Codex binary, or `codex app-server`, which ignores the managed files | Allow only the managed Codex binary and approved clients, and block `codex app-server` |
|
|
137
|
+
| A repository's `.agents/skills` or `.codex/skills` folder is listed and can be picked from the menu | The gate does not check a menu pick of a repository Skill. The mago-ski GitHub Action narrows this, within the limits below. Start the agent only in working copies at a checked commit |
|
|
138
|
+
| An untracked Skill folder in a working copy. The GitHub Action sees only committed files | The hook still blocks typed plain mentions there. The menu pick is the first row |
|
|
139
|
+
| Start-up tricks, such as a `.env` file that changes `HOME`, or a symlinked `CODEX_HOME` | An admin-owned `CODEX_HOME`, or execution control |
|
|
140
|
+
|
|
141
|
+
### What the GitHub Action check does and does not cover
|
|
142
|
+
|
|
143
|
+
Requiring the [GitHub Action](github-action.md) check on a repository is not enough by itself to keep repository Skills away from the Codex menu:
|
|
144
|
+
|
|
145
|
+
- **It checks only the folders in the policy's `skill_dirs`.** A Skill folder that Codex lists but the policy does not name is not looked at. List every `.agents/skills` and `.codex/skills` folder of the repository in `skill_dirs`, including those in subfolders where the agent is started, or forbid these folders outside `skill_dirs` with a repository rule (a push rule or a required path check).
|
|
146
|
+
- **It accepts a certified Skill; it does not remove it.** A repository Skill with a valid certificate passes the check, stays in the repository and can be picked from the Codex menu. That pick reaches the model with no hook, so the gate does not check it and does not record it.
|
|
147
|
+
- **It checks when it runs, not when the Skill is picked.** A certificate that is revoked or expires after the check stays in effect for menu picks until the check runs again and the Skill is removed. Run the check on a schedule as well as on pull requests, and remove a repository Skill when its approval is revoked.
|
|
148
|
+
- **It sees committed files of the checked revision only.** A working copy at another commit, or with local changes, is not covered.
|
|
149
|
+
|
|
150
|
+
The repository controls this needs: the check is a required status check on protected branches; the policy and trust files are changed only with review (the Action reads them from the base revision); and, if no repository Skill is meant to be used with Codex, a rule that keeps `.agents/skills` and `.codex/skills` out of the repository, which is the only setting in which the menu route is closed for repositories.
|
|
151
|
+
|
|
152
|
+
## Keeping it current
|
|
153
|
+
|
|
154
|
+
- **New trust root or revocation list:** `sudo mago-ski gate trust --host codex --trust-root FILE --revocations FILE`, or an inbox (`gate init --inbox DIR`, then `gate refresh`).
|
|
155
|
+
- **Remove a Skill:** `sudo mago-ski gate uninstall --host codex NAME`.
|
|
156
|
+
- **Removed names.** The gate records the Skills it removed in `/etc/codex/skills/.mago-ski-removed-names.json` (at most 4096 entries, oldest dropped first), so a removed name gets a clear block message. `sudo mago-ski gate prune-removed --host codex --older-than-days N` (default 90, at least 7) drops old entries. Blocking rests on the removed link, so pruning only loses the message. A removed name is blocked by the hook without asking the gate, so that block is not in the decision log.
|
|
157
|
+
- **Checks.** `sudo mago-ski gate doctor --host codex` FAILs on, among other things: a managed file that differs from what `gate init` writes, a Skill folder or a `.system` folder in a listed home, a listed home whose Skill folders could not be scanned completely (too large, too deep or unreadable), an entry in `/etc/codex/skills` with no install record, a reconcile that did not finish cleanly, an installed Skill with a name mismatch, and a service that is down. It WARNs on an untested Codex version, on unlocked user Skill folders and on shadow mode.
|
|
158
|
+
|
|
159
|
+
## After a root rotation
|
|
160
|
+
|
|
161
|
+
The gate does not follow root events by itself. When your organisation has replaced its root key and re-signed its documents (`mago-ski root adopt`), move each gate to the new root:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
sudo mago-ski gate init --host codex --root-fingerprint sha256:<new> --new-root # with the same options as your original init
|
|
165
|
+
sudo systemctl daemon-reload && sudo systemctl restart mago-ski-gate@codex
|
|
166
|
+
sudo mago-ski gate trust --host codex --trust-root trust-root.json --revocations revocations.json
|
|
167
|
+
sudo mago-ski gate doctor --host codex
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- `gate init` refuses a root fingerprint that differs from the installed one unless `--new-root` is given, so a mistyped fingerprint cannot switch roots by accident. `--print` shows the move without writing anything.
|
|
171
|
+
- Between the restart and `gate trust`, the gate has no documents for the new root. In enforce mode every Skill is blocked during that time, so run the commands together.
|
|
172
|
+
- Installed Skills do not need to be installed again. Their certificates were signed by approvers, and the approvers are kept.
|
|
173
|
+
- The old root's stored documents are kept and no longer used.
|
|
174
|
+
|
|
175
|
+
## Limits
|
|
176
|
+
|
|
177
|
+
- **Linux only.**
|
|
178
|
+
- **Verified on Codex 0.166.x.** The earlier live test ([results](../spikes/codex-gate-live.md)) ran 0.163.0 and 0.166.0 in non-interactive sessions, before the profile existed. Results for the profile's own live scenarios are not published yet, and the menu route has not been tested.
|
|
179
|
+
- **Instructions already read stay.** The gate cannot remove a Skill's text from a session that has already loaded it.
|
|
180
|
+
- **The gate does not follow root events or timestamps by itself.** It keeps the root fingerprint it was given, so a rotated or revoked root key is not noticed until an administrator moves the gate (see [After a root rotation](#after-a-root-rotation)). On a fleet, that means running the four commands on every machine.
|
|
181
|
+
- An approval records who approved which exact version. It does not say that a Skill is safe.
|
|
@@ -274,7 +274,7 @@ The renderer cannot name a file, a key or a directory in any of them. A compromi
|
|
|
274
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
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
276
|
- **The memory does not protect against the user** (see above).
|
|
277
|
-
- **Retired keys
|
|
277
|
+
- **Retired keys come from the whole log.** A key retired in a walked event, or shown leaving a role in an event before `root_events_after` (read without checking its signatures, and used only to refuse), is retired. The host check refuses a trust root that lists such a key (`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
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
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
280
|
|
|
@@ -171,7 +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.
|
|
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. Events before `root_events_after` are not checked, but hosts still read which keys they show leaving a role and treat those keys as retired (see [Host processing](#host-processing)).
|
|
175
175
|
|
|
176
176
|
### Rules for a revoke
|
|
177
177
|
|
|
@@ -245,6 +245,7 @@ At every trust check, before reading the trust root, a host with a v2 recovery p
|
|
|
245
245
|
|
|
246
246
|
1. Starts from the policy: *active root* = `root_fingerprint`, *recovery set* = `recovery`, *timestamp key* = `freshness.key_id`, *revoked* = false.
|
|
247
247
|
2. Reads `root_events`. A missing, malformed or oversized log is `UNVERIFIABLE`.
|
|
248
|
+
- **Events before `root_events_after` are read, not checked.** The policy pins the state after them, not the keys that signed them, so their signatures and rules are not checked and nothing is ever accepted because of them. The host reads only which keys they show leaving a role, and uses that only to refuse: the root key a revoke names, the root key a rotate replaces with another key, a timestamp key that a later event replaces, and a recovery key that a rotate leaves out of `new_recovery` count as retired or former recovery keys for the rest of the walk and for the trust root check. Someone who can change these events can only make a host refuse more, which they can already do by deleting the log; with `freshness`, the timestamp covers the whole file. An event there with the wrong payload type, a payload that does not parse, or the wrong `sequence`, and an event there that retires a key the policy pins (`the events before root_events_after show key <id> leaving the root or timestamp role, but the policy pins it as the <role> key`), make the log `UNVERIFIABLE`.
|
|
248
249
|
3. For each event after the first `root_events_after`, in order, checks every rule above against the current state, then applies it:
|
|
249
250
|
- revoke: *revoked* = true.
|
|
250
251
|
- rotate: *active root* = `new_root.key_id`, *recovery set* = `new_recovery`, *timestamp key* = `new_timestamp.key_id` if present, *revoked* = false.
|
|
@@ -258,7 +259,7 @@ Walking the full log keeps hosts without state correct, but hosts load trust doc
|
|
|
258
259
|
2. Check rollback and forks against the host state. Otherwise `UNVERIFIABLE`.
|
|
259
260
|
3. If the active root is revoked, every Skill is blocked: see [Revoked root](#revoked-root-blocked-in-every-mode). Nothing else is read.
|
|
260
261
|
4. With `freshness`, check the timestamp against the files. Otherwise `UNVERIFIABLE`.
|
|
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`).
|
|
262
|
+
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`). Keys shown leaving a role in the events before `root_events_after` count too (see [Walking the log](#walking-the-log)). 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
|
|
|
263
264
|
Before upgrading hosts, an organisation removes such approvers; see the upgrade note in the CHANGELOG.
|
|
264
265
|
6. Record the new state.
|
|
@@ -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. 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`.
|
|
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`. Keys shown leaving a role in events before `root_events_after` count too; 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
|
package/docs/threat-model.md
CHANGED
|
@@ -27,7 +27,7 @@ mago-ski answers one question: **is the Skill this agent is about to use the exa
|
|
|
27
27
|
## What it does not protect against
|
|
28
28
|
|
|
29
29
|
- **Malicious first versions and fooled reviewers.** A certificate records a decision; it does not make the decision correct. Review quality is the organization's job.
|
|
30
|
-
- **Prompt injection at runtime.** A verified Skill can still be steered by untrusted data it reads (the confused-deputy problem).
|
|
30
|
+
- **Prompt injection at runtime.** A verified Skill can still be steered by untrusted data it reads (the confused-deputy problem). mago-ski decides admission only: it does not evaluate tool calls, returned data or intent after a Skill is loaded, and no part of mago-ski depends on a runtime enforcement product.
|
|
31
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.
|
|
32
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.
|
|
33
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.
|
|
@@ -35,6 +35,18 @@ mago-ski answers one question: **is the Skill this agent is about to use the exa
|
|
|
35
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.
|
|
36
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).
|
|
37
37
|
|
|
38
|
+
## Accepted risks
|
|
39
|
+
|
|
40
|
+
Findings from security reviews that were kept on purpose. A review that raises one again should say what changed.
|
|
41
|
+
|
|
42
|
+
| Risk | Why it is kept |
|
|
43
|
+
|---|---|
|
|
44
|
+
| **`verifySkill` reads `SKILL.md` twice** (once for the digest, once for the name), so a file swapped in between gives a different name | It fails closed: a name that does not match the certificate is refused. Discovery stops at the outer `SKILL.md`, whose digest covers any nested one |
|
|
45
|
+
| **Gate: one user can spend the decision socket's rate limit for others** | Telling users apart needs the connecting process's credentials (`SO_PEERCRED`), which Node does not provide. Changing this means a native addon or a different socket design |
|
|
46
|
+
| **Gate: revoked Skill generations stay readable on disk** until they are pruned | Sessions admitted before the revocation may still read them. Every new use is refused, in every mode |
|
|
47
|
+
| **Gate: the host binary is matched by path, not by inode** | An inode check would refuse every host after a normal upgrade. A process that fakes the path can only be the user's own, which [What it does not protect against](#what-it-does-not-protect-against) already covers |
|
|
48
|
+
| **Codex: a user can rename `~/.codex`** to get around `--lock-user-skill-folders` | Listed in the [Codex guide](hosts/codex.md#what-codex-leaves-to-your-organisation); `gate doctor` reports it. Preventing it needs control of the home directory, which the organisation has, not mago-ski |
|
|
49
|
+
|
|
38
50
|
## Revocation timing
|
|
39
51
|
|
|
40
52
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mago-foundation/mago-ski",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Skills PKI: organization-approved, exact-version Skill certificates enforced on the agent host",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mago Foundation",
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"test": "node --test --test-concurrency=1 \"tests/**/*.test.ts\"",
|
|
40
40
|
"test:live:claude-code": "node tests/live/claude-code-gate.live.ts",
|
|
41
41
|
"test:live:codex": "node tests/live/codex-gate.live.ts",
|
|
42
|
+
"live:scenarios": "node scripts/live-scenarios.mjs",
|
|
43
|
+
"sast": "semgrep scan --config .semgrep.yml --error --metrics=off --timeout 60",
|
|
42
44
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
43
45
|
},
|
|
44
46
|
"peerDependencies": {
|