@mago-foundation/mago-ski 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +139 -2
- package/action.yml +58 -0
- package/dist/hosts/github/run.d.ts +27 -0
- package/dist/hosts/github/run.js +152 -0
- package/dist/hosts/pi/index.d.ts +13 -0
- package/dist/hosts/pi/index.js +550 -0
- package/dist/hosts/pi/paths.d.ts +9 -0
- package/dist/hosts/pi/paths.js +55 -0
- package/dist/src/admin.d.ts +74 -0
- package/dist/src/admin.js +243 -0
- package/dist/src/canonical-json.d.ts +12 -0
- package/dist/src/canonical-json.js +149 -0
- package/dist/src/certificate.d.ts +34 -0
- package/dist/src/certificate.js +112 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +595 -0
- package/dist/src/diff.d.ts +26 -0
- package/dist/src/diff.js +404 -0
- package/dist/src/dsse.d.ts +25 -0
- package/dist/src/dsse.js +71 -0
- package/dist/src/experimental/sigstore.d.ts +26 -0
- package/dist/src/experimental/sigstore.js +153 -0
- package/dist/src/fs-safe.d.ts +27 -0
- package/dist/src/fs-safe.js +229 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/keys.d.ts +21 -0
- package/dist/src/keys.js +154 -0
- package/dist/src/main-module.d.ts +5 -0
- package/dist/src/main-module.js +19 -0
- package/dist/src/names.d.ts +7 -0
- package/dist/src/names.js +38 -0
- package/dist/src/policy.d.ts +81 -0
- package/dist/src/policy.js +349 -0
- package/dist/src/revocations.d.ts +28 -0
- package/dist/src/revocations.js +93 -0
- package/dist/src/time.d.ts +25 -0
- package/dist/src/time.js +74 -0
- package/dist/src/tree-digest.d.ts +46 -0
- package/dist/src/tree-digest.js +268 -0
- package/dist/src/trust-root.d.ts +38 -0
- package/dist/src/trust-root.js +136 -0
- package/dist/src/verify.d.ts +96 -0
- package/dist/src/verify.js +380 -0
- package/docs/hosts/adapter-interface.md +33 -0
- package/docs/hosts/github-action.md +45 -0
- package/docs/hosts/pi.md +41 -0
- package/docs/spec/root-recovery-v1.md +430 -0
- package/docs/spec/skill-certificate-v1.md +60 -0
- package/docs/spec/skill-tree-v2.md +59 -0
- package/docs/spec/trust-documents-v1.md +103 -0
- package/docs/spec/verification.md +56 -0
- package/docs/threat-model.md +45 -0
- package/package.json +77 -4
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# Root recovery v1
|
|
2
|
+
|
|
3
|
+
Status: **proposal, not implemented.** No released version of mago-ski reads the fields or documents described here. Once implemented, this page becomes normative and the changes listed under [Changes to other documents](#changes-to-other-documents) are applied.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
This proposal adds a **recovery set**: a few keys, held by different people and kept offline, that hosts pin in advance. The recovery set cannot approve Skills or sign trust roots. It can do exactly two things, both recorded as signed, numbered **root events**:
|
|
8
|
+
|
|
9
|
+
- **revoke**: stop hosts trusting the current root key. A small number of recovery keys is enough (by default one), so any single trustee can stop the damage quickly. The worst a stolen recovery key can do with this is make hosts block everything until a rotation (an outage, never a takeover).
|
|
10
|
+
- **rotate**: replace the root key, and optionally the recovery set or the timestamp key. This needs a larger number of recovery keys (for example two of three), plus signatures from the new keys.
|
|
11
|
+
|
|
12
|
+
Two further rules make a revocation hard to escape:
|
|
13
|
+
|
|
14
|
+
- **A revoked root blocks in every mode**, shadow mode included, and is reported once per host rather than once per Skill. See [Revoked root](#revoked-root-blocked-in-every-mode).
|
|
15
|
+
- **Freshness (optional, recommended):** a separate, automated key re-signs a short-lived timestamp of the current documents. A host that is fed old files stops trusting anything within a day, instead of never noticing. See [Freshness](#freshness).
|
|
16
|
+
|
|
17
|
+
The design follows [TUF](https://theupdateframework.io/)'s root and timestamp roles. See [Rationale](#rationale-tuf-and-keri) for why this was chosen over a KERI-style pre-rotated successor.
|
|
18
|
+
|
|
19
|
+
## Roles
|
|
20
|
+
|
|
21
|
+
| Key | Signs | Used | Hosts know it from |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| Recovery keys (1-16) | Root events only | Only in an incident or a planned rotation | Their fingerprints in the host policy |
|
|
24
|
+
| Root key | Trust root and revocation list | Every 30 days or so (revocation list refresh) | `root_fingerprint` in the policy, then rotate events |
|
|
25
|
+
| Timestamp key (optional) | Timestamps only | Automatically, every few hours | `freshness.key_id` in the policy, then rotate events |
|
|
26
|
+
| Approver keys | Skill certificates | Every approval | The trust root |
|
|
27
|
+
|
|
28
|
+
No key may hold two roles. A recovery key must not be the root key, the timestamp key or an approver; the timestamp key must not be the root key or an approver; and the root key must not be an approver (as in v1).
|
|
29
|
+
|
|
30
|
+
## How a recovery works
|
|
31
|
+
|
|
32
|
+
Example organization: root key `R0`; recovery keys `A`, `B`, `C` held by three people; rotation needs 2 of them, revocation needs 1; timestamp key `T` used by an automated job.
|
|
33
|
+
|
|
34
|
+
1. **Setup.** Every host's policy pins `R0`, the fingerprints of `A`, `B` and `C`, and `T`. The organization publishes an empty root event log next to the trust root, and the job re-signs a 24-hour timestamp every 6 hours.
|
|
35
|
+
2. **Leak.** `R0`'s private key turns up in a public CI log.
|
|
36
|
+
3. **Revoke (minutes).** Trustee A signs event 1, `revoke R0`, and appends it to the log. Each host that reads the new log blocks every Skill, in shadow mode too, and shows one alarm. A host the thief can feed old files does not see event 1, but its timestamp expires within 24 hours, after which it trusts nothing.
|
|
37
|
+
4. **Rotate (hours).** The organization creates a new root key `R1`. Trustees A and B sign event 2, `rotate R0 -> R1`, keeping the same recovery set and timestamp key, and `R1` signs it too. `R1` then signs a trust root and a revocation list, listing the same approvers as before.
|
|
38
|
+
5. **Back to normal.** Hosts read event 2, trust `R1`, and accept its documents. Existing certificates keep verifying: they are signed by approver keys and do not name the root. No host policy was edited.
|
|
39
|
+
|
|
40
|
+
The thief, holding only `R0`, cannot undo event 1 or produce event 2: both need recovery keys.
|
|
41
|
+
|
|
42
|
+
## Host policy v2
|
|
43
|
+
|
|
44
|
+
A policy that uses recovery declares `mago.policy/v2`. A v2 host accepts v1 policies unchanged; they have no recovery set and behave exactly as today.
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"policy_version": "mago.policy/v2",
|
|
49
|
+
"mode": "enforce",
|
|
50
|
+
"root_fingerprint": "sha256:<root key id at setup>",
|
|
51
|
+
"recovery": {
|
|
52
|
+
"key_ids": ["sha256:<A>", "sha256:<B>", "sha256:<C>"],
|
|
53
|
+
"rotate_threshold": 2,
|
|
54
|
+
"revoke_threshold": 1
|
|
55
|
+
},
|
|
56
|
+
"root_events": "root-events.json",
|
|
57
|
+
"freshness": {
|
|
58
|
+
"timestamp": "timestamp.json",
|
|
59
|
+
"key_id": "sha256:<T>",
|
|
60
|
+
"max_lifetime": "24h"
|
|
61
|
+
},
|
|
62
|
+
"trust_root": "trust-root.json",
|
|
63
|
+
"revocations": "revocations.json",
|
|
64
|
+
"state_file": "state.json"
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Field | Required | Meaning |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `root_fingerprint` | yes | The root key trusted before any root event. It does not change after a rotation |
|
|
71
|
+
| `recovery` | no | The recovery set trusted before any root event. When absent, the policy behaves as v1, and `root_events` and `freshness` must be absent too |
|
|
72
|
+
| `recovery.key_ids` | yes | Fingerprints of the recovery keys: sorted, unique, 1-16, none equal to `root_fingerprint` |
|
|
73
|
+
| `recovery.rotate_threshold` | yes | Recovery signatures a rotate event needs: `1 <= revoke_threshold <= rotate_threshold <= len(key_ids)` |
|
|
74
|
+
| `recovery.revoke_threshold` | yes | Recovery signatures a revoke event needs |
|
|
75
|
+
| `root_events` | with `recovery` | The root event log. Required when `recovery` is present, and the file must exist: an organization with no events publishes an empty log. A missing file is `UNVERIFIABLE`, so deleting it cannot hide a revocation |
|
|
76
|
+
| `root_events_after` | no | How many events `root_fingerprint`, `recovery` and `freshness.key_id` already reflect (default 0). A host set up after a rotation pins the current keys and this number, and starts walking at the next event. A log with fewer events than this is `UNVERIFIABLE` |
|
|
77
|
+
| `freshness` | no | Turns on the [freshness](#freshness) check. Requires `recovery`, so that a leaked timestamp key can be replaced |
|
|
78
|
+
| `freshness.timestamp` | yes | The timestamp file. It must exist |
|
|
79
|
+
| `freshness.key_id` | yes | The timestamp key trusted before any root event. Not `root_fingerprint` and not in `recovery.key_ids` |
|
|
80
|
+
| `freshness.max_lifetime` | no | The longest timestamp lifetime hosts accept, as a duration such as `24h` (default `24h`, at most `7d`). It caps the damage a leaked timestamp key can do by signing long-lived timestamps |
|
|
81
|
+
|
|
82
|
+
Only fingerprints are pinned. A key's public half is revealed in the first event or timestamp it signs, and must hash to its fingerprint.
|
|
83
|
+
|
|
84
|
+
## Root event log
|
|
85
|
+
|
|
86
|
+
Canonical JSON, not signed as a whole (each event is signed):
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{"events":[{"payload":"<base64>","payloadType":"application/vnd.mago-ski.root-event+json","signatures":[{"keyid":"sha256:<A>","sig":"<base64>"}]}],"type":"mago.root-events/v1"}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- `events`: DSSE envelope objects in order. The event at index `i` has `sequence` `i + 1`.
|
|
93
|
+
- The log only grows. An organization never removes or rewrites an event, even an unwanted one (see [Rollback and forks](#rollback-and-forks)).
|
|
94
|
+
- At most 256 events; the file is at most 4 MiB.
|
|
95
|
+
|
|
96
|
+
## Root events
|
|
97
|
+
|
|
98
|
+
Envelopes are DSSE, as for [certificates](skill-certificate-v1.md), with one difference: a root event carries **one signature per signer** instead of exactly one. Signatures are sorted by `keyid`, unique, and every one must be valid; an envelope with an unknown or invalid signature is rejected even if enough valid ones remain.
|
|
99
|
+
|
|
100
|
+
`payloadType`: `application/vnd.mago-ski.root-event+json`
|
|
101
|
+
|
|
102
|
+
### Revoke
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"type": "mago.root-event/v1",
|
|
107
|
+
"sequence": 1,
|
|
108
|
+
"action": "revoke",
|
|
109
|
+
"root_key_id": "sha256:<R0>",
|
|
110
|
+
"issued_at": "2026-11-02T09:00:00Z",
|
|
111
|
+
"reason": "root.pem appeared in a public CI log",
|
|
112
|
+
"signers": [
|
|
113
|
+
{ "key_id": "sha256:<A>", "public_key": "<base64 DER SPKI>" }
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Rotate
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"type": "mago.root-event/v1",
|
|
123
|
+
"sequence": 2,
|
|
124
|
+
"action": "rotate",
|
|
125
|
+
"root_key_id": "sha256:<R0>",
|
|
126
|
+
"issued_at": "2026-11-02T15:30:00Z",
|
|
127
|
+
"reason": "replace leaked root",
|
|
128
|
+
"new_root": { "key_id": "sha256:<R1>", "public_key": "<base64 DER SPKI>" },
|
|
129
|
+
"new_recovery": {
|
|
130
|
+
"key_ids": ["sha256:<A>", "sha256:<B>", "sha256:<C>"],
|
|
131
|
+
"rotate_threshold": 2,
|
|
132
|
+
"revoke_threshold": 1
|
|
133
|
+
},
|
|
134
|
+
"signers": [
|
|
135
|
+
{ "key_id": "sha256:<A>", "public_key": "<base64 DER SPKI>" },
|
|
136
|
+
{ "key_id": "sha256:<B>", "public_key": "<base64 DER SPKI>" }
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Fields
|
|
142
|
+
|
|
143
|
+
| Field | Meaning |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `sequence` | Position in the log, starting at 1, with no gaps |
|
|
146
|
+
| `action` | `revoke` or `rotate` |
|
|
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
|
+
| `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. Shown in verdict reasons |
|
|
150
|
+
| `signers` | The recovery keys that sign: sorted by `key_id`, unique. Each `public_key` must hash to its `key_id` |
|
|
151
|
+
| `new_root` | Rotate only. The new root key; `public_key` must hash to `key_id` |
|
|
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 |
|
|
153
|
+
| `new_timestamp` | Rotate only, optional. A new timestamp key, `{ "key_id", "public_key" }`. When absent, the timestamp key does not change. Hosts without `freshness` check the field and its signature but otherwise ignore it |
|
|
154
|
+
|
|
155
|
+
### Who must sign
|
|
156
|
+
|
|
157
|
+
Let *current set* be the recovery set in force just before the event.
|
|
158
|
+
|
|
159
|
+
| Action | Signatures required |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `revoke` | At least `revoke_threshold` keys of the current set |
|
|
162
|
+
| `rotate` | At least `rotate_threshold` keys of the current set, **and** at least the new `rotate_threshold` keys of `new_recovery`, **and** `new_root`, **and** `new_timestamp` if present |
|
|
163
|
+
|
|
164
|
+
- A key in both sets counts toward both thresholds, so a rotate that keeps the same set needs no extra recovery signatures.
|
|
165
|
+
- Every key in `signers` must belong to the current set or to `new_recovery`. The envelope's signatures are exactly the `signers`, plus `new_root` and `new_timestamp` for a rotate.
|
|
166
|
+
- The signatures from new keys prove that those keys exist and are held. A typo in a fingerprint cannot leave the organization with a recovery set nobody can use, or a root or timestamp key nobody can sign with. This is TUF's rule that new root metadata is signed by both the old and the new root keys.
|
|
167
|
+
|
|
168
|
+
### Rules for a rotate
|
|
169
|
+
|
|
170
|
+
- `new_root.key_id` must not be in the current recovery set or in `new_recovery`.
|
|
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
|
+
- `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
|
+
- `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
|
+
|
|
175
|
+
### Rules for a revoke
|
|
176
|
+
|
|
177
|
+
- The key named in `root_key_id` must not already be revoked.
|
|
178
|
+
- After a revoke, the next event, if any, must be a rotate naming the same `root_key_id`.
|
|
179
|
+
|
|
180
|
+
## Freshness
|
|
181
|
+
|
|
182
|
+
Optional, turned on per policy with `freshness`, and recommended for hosts in enforce mode.
|
|
183
|
+
|
|
184
|
+
Without it, a host acts on whatever files reach it. Someone who controls how files reach a host (a sync job, a mirror, a network path) can keep feeding it an old log that lacks a revoke. If they also hold the leaked root key, they can keep signing fresh trust roots for it indefinitely. Freshness closes this gap: a separate **timestamp key**, used by an automated job, regularly signs a short-lived statement of exactly which files are current. A host rejects files that do not match a timestamp that is still valid.
|
|
185
|
+
|
|
186
|
+
### Timestamp document
|
|
187
|
+
|
|
188
|
+
A DSSE envelope with exactly one signature, by the timestamp key.
|
|
189
|
+
|
|
190
|
+
`payloadType`: `application/vnd.mago-ski.timestamp+json`
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"type": "mago.timestamp/v1",
|
|
195
|
+
"version": 412,
|
|
196
|
+
"issued_at": "2026-11-02T06:00:00Z",
|
|
197
|
+
"expires_at": "2026-11-03T06:00:00Z",
|
|
198
|
+
"timestamp_key": { "key_id": "sha256:<T>", "public_key": "<base64 DER SPKI>" },
|
|
199
|
+
"root_events": { "sha256": "<64 hex>", "count": 2 },
|
|
200
|
+
"trust_root": { "sha256": "<64 hex>", "version": 7 },
|
|
201
|
+
"revocations": { "sha256": "<64 hex>", "version": 31 }
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
| Field | Meaning |
|
|
206
|
+
|---|---|
|
|
207
|
+
| `version` | Positive integer, increased with every timestamp |
|
|
208
|
+
| `issued_at` | Not more than 5 minutes in the future |
|
|
209
|
+
| `expires_at` | Later than `issued_at`, at most `max_lifetime` after it, and later than the host's current time |
|
|
210
|
+
| `timestamp_key` | Must be the active timestamp key (below); `public_key` must hash to `key_id`, which must equal the envelope's `keyid` |
|
|
211
|
+
| `root_events` | SHA-256 of the root event log file's bytes, and its number of events |
|
|
212
|
+
| `trust_root`, `revocations` | SHA-256 of each document file's bytes, and the `version` inside it |
|
|
213
|
+
|
|
214
|
+
### What a host checks
|
|
215
|
+
|
|
216
|
+
The *active timestamp key* is `freshness.key_id`, replaced by each rotate event that carries `new_timestamp`. A host:
|
|
217
|
+
|
|
218
|
+
- reads each file once, and hashes and parses the same bytes;
|
|
219
|
+
- verifies the timestamp's signature with the active timestamp key;
|
|
220
|
+
- checks the times above and that `version` is not lower than the host state records;
|
|
221
|
+
- checks that the three digests, the event count and the two versions match the files it read.
|
|
222
|
+
|
|
223
|
+
Any failure is `UNVERIFIABLE`, and follows the configured mode (see [Reporting trust failures](#reporting-trust-failures-once)).
|
|
224
|
+
|
|
225
|
+
### What it guarantees
|
|
226
|
+
|
|
227
|
+
- **A frozen host stops trusting.** A host that is fed old files rejects them once the newest timestamp naming them expires: at most `max_lifetime` (24 hours by default). It then trusts nothing until it receives current files.
|
|
228
|
+
- **A leaked root key alone does not reach freshness-checking hosts.** The timestamp names exact file digests, so a trust root signed with a leaked root key is accepted only if it has been published at the place the timestamp job reads from. Someone who can only tamper with the files on their way to a host cannot get it accepted.
|
|
229
|
+
- **A leaked timestamp key alone forges nothing.** It cannot sign events or trust documents. Combined with control over delivery to a host, it can keep that host on the documents it already has; see [What each leak allows](#what-each-leak-allows).
|
|
230
|
+
|
|
231
|
+
The longest time a revoked approver key or digest can still pass also drops, from the revocation list's lifetime (30 days by default) to `max_lifetime`.
|
|
232
|
+
|
|
233
|
+
### Publishing
|
|
234
|
+
|
|
235
|
+
- The timestamp job runs every 6 hours with a 24-hour lifetime. If it stalls, hosts start failing 18 hours after its first missed run, which leaves time to notice and fix it.
|
|
236
|
+
- It reads the published files, hashes them, and signs. It publishes the timestamp together with any new documents: write everything to a new directory, then switch to it in one step. A host that reads mid-update sees a mismatch, which is `UNVERIFIABLE` until its next load.
|
|
237
|
+
- The timestamp key is online, so treat it as the key most likely to leak. Keep it in a different system from the root key, never in the same CI secret store.
|
|
238
|
+
|
|
239
|
+
## Host processing
|
|
240
|
+
|
|
241
|
+
### Walking the log
|
|
242
|
+
|
|
243
|
+
At every trust check, before reading the trust root, a host with a v2 recovery policy:
|
|
244
|
+
|
|
245
|
+
1. Starts from the policy: *active root* = `root_fingerprint`, *recovery set* = `recovery`, *timestamp key* = `freshness.key_id`, *revoked* = false.
|
|
246
|
+
2. Reads `root_events`. A missing, malformed or oversized log is `UNVERIFIABLE`.
|
|
247
|
+
3. For each event after the first `root_events_after`, in order, checks every rule above against the current state, then applies it:
|
|
248
|
+
- revoke: *revoked* = true.
|
|
249
|
+
- rotate: *active root* = `new_root.key_id`, *recovery set* = `new_recovery`, *timestamp key* = `new_timestamp.key_id` if present, *revoked* = false.
|
|
250
|
+
4. Any event that breaks a rule makes the whole log `UNVERIFIABLE`. The host does not skip it or stop early with the events before it.
|
|
251
|
+
|
|
252
|
+
Walking the full log keeps hosts without state correct, but hosts load trust documents often: the Pi host does so before every agent run and on every tool call that re-verifies a Skill. A worst-case log (256 events of 34 signatures) costs about 8,700 signature checks per walk, over a second on a laptop. So a host caches each **successful** walk, keyed by the policy's starting point (`root_fingerprint`, `recovery`, `freshness.key_id`, `root_events_after`) and the log's SHA-256, and walks again only when one of them changes. An unchanged log then costs one SHA-256 over at most 4 MiB. Failed walks are not cached, because an event that is too far in the future now may be valid later. The rollback and fork checks below run on every load; they only compare a number and a digest.
|
|
253
|
+
|
|
254
|
+
### Order of checks
|
|
255
|
+
|
|
256
|
+
1. Walk the root event log. Otherwise `UNVERIFIABLE`.
|
|
257
|
+
2. Check rollback and forks against the host state. Otherwise `UNVERIFIABLE`.
|
|
258
|
+
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
|
+
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 active timestamp key.
|
|
261
|
+
6. Record the new state.
|
|
262
|
+
|
|
263
|
+
### Revoked root: blocked in every mode
|
|
264
|
+
|
|
265
|
+
When the active root is revoked:
|
|
266
|
+
|
|
267
|
+
- Every Skill is blocked, in **both `enforce` and `shadow` mode**. No policy setting changes this.
|
|
268
|
+
- 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
|
+
- The only way back is a rotate event. Switching the policy to shadow mode does not help.
|
|
270
|
+
|
|
271
|
+
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
|
+
|
|
273
|
+
Only a revoke, a signed and deliberate statement, overrides the mode. Failures that might have an innocent cause (an unreadable log, an expired timestamp from a stalled job) follow the configured mode.
|
|
274
|
+
|
|
275
|
+
### Reporting trust failures once
|
|
276
|
+
|
|
277
|
+
A failure in the trust documents affects every Skill at once. Reporting it once per Skill would bury it among dozens of identical warnings, along with any Skill a thief has planted. So hosts report these failures **once per host**:
|
|
278
|
+
|
|
279
|
+
| Failure | Event name | Enforce mode | Shadow mode |
|
|
280
|
+
|---|---|---|---|
|
|
281
|
+
| The active root is revoked | `root-revoked` | block | **block** |
|
|
282
|
+
| Root event log missing or invalid, rollback, fork | `trust-unavailable` | block | would-block |
|
|
283
|
+
| Timestamp missing, invalid, expired or not matching the files | `trust-unavailable` | block | would-block |
|
|
284
|
+
| Trust root or revocation list invalid or expired (as in v1) | `trust-unavailable` | block | would-block |
|
|
285
|
+
|
|
286
|
+
While such a failure lasts:
|
|
287
|
+
|
|
288
|
+
- **Pi host:** one notice when it starts or changes, and the status bar shows it (for example `mago-ski: ROOT KEY REVOKED - all Skills blocked`). `root-revoked` is always an error, whatever the mode. No per-Skill notices are shown.
|
|
289
|
+
- **Decision log:** one record when it starts or changes. It carries the event name, empty `skill` and `skill_dir`, null `digest` and `certificate_id`, verdict `UNVERIFIABLE`, the action from the table and the reason. No per-Skill records are written.
|
|
290
|
+
- **CLI** (`verify`, `verify-all`, `policy check`): prints the failure once and exits non-zero.
|
|
291
|
+
- **GitHub Action:** one summary line and no per-Skill rows. It fails the check on `root-revoked` in both modes; on `trust-unavailable` it follows the mode.
|
|
292
|
+
|
|
293
|
+
### Rollback and forks
|
|
294
|
+
|
|
295
|
+
Host state version 2:
|
|
296
|
+
|
|
297
|
+
```json
|
|
298
|
+
{
|
|
299
|
+
"type": "mago.host-state/v2",
|
|
300
|
+
"roots": { "sha256:<R1>": { "trust_root_version": 1, "revocations_version": 1 } },
|
|
301
|
+
"root_events": { "sha256:<R0>": { "sequence": 2, "event_digest": "sha256:<hex>" } },
|
|
302
|
+
"timestamps": { "sha256:<T>": { "version": 412 } }
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
(Written as canonical JSON; shown indented here.)
|
|
307
|
+
|
|
308
|
+
- `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
|
+
- **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.
|
|
310
|
+
- **Fork:** if the event at the recorded `sequence` has a different digest, it is `UNVERIFIABLE`. Two valid but different events with the same number mean that two trustees prepared events at the same time, or that recovery keys were misused. Hosts fail closed until people sort it out. To avoid the honest case, trustees always prepare events against the published log, never a private copy.
|
|
311
|
+
- **Versions are per key.** `roots` is keyed by the root key that signed the documents, as in v1, and `timestamps` by the timestamp key. A new key starts its own count, so a thief who signed a document with a huge `version` using a leaked key cannot lock out its successor.
|
|
312
|
+
- Hosts without a state file (the GitHub Action) still walk and check the log and the timestamp, but have no rollback or fork protection, as for v1 documents. The Action reads them from the protected base revision.
|
|
313
|
+
|
|
314
|
+
An unwanted but valid event, such as a revoke signed with a stolen recovery key, is not rewritten. The organization appends a rotate after it. Because a revoke only removes trust, keeping it in the log is harmless.
|
|
315
|
+
|
|
316
|
+
## What each leak allows
|
|
317
|
+
|
|
318
|
+
With `k` = `rotate_threshold` and `r` = `revoke_threshold`:
|
|
319
|
+
|
|
320
|
+
| Leaked | The thief can | The organization |
|
|
321
|
+
|---|---|---|
|
|
322
|
+
| The root key | Sign trust roots and revocation lists. Freshness-checking hosts accept them only if the thief can also publish at the place the timestamp job reads; other hosts accept them until they read a revoke | Any `r` trustees revoke; `k` trustees rotate |
|
|
323
|
+
| The timestamp key | Nothing by itself. With control over delivery to a host: keep that host on the documents it already has, by re-signing timestamps for them | `k` trustees rotate with `new_timestamp`; hosts that receive the log directly pick it up at once |
|
|
324
|
+
| The root key and the timestamp key | As the root key on a host without freshness | Revoke, then rotate both keys |
|
|
325
|
+
| Fewer than `r` recovery keys | Nothing | Optionally rotates to a recovery set without the leaked keys |
|
|
326
|
+
| `r` to `k - 1` recovery keys | Revoke the active root: an outage, not a takeover | `k` other trustees rotate, dropping the leaked keys from the set |
|
|
327
|
+
| The root key and fewer than `k` recovery keys | Both of the above | Revokes, then rotates to a new root and a set without the leaked keys |
|
|
328
|
+
| `k` or more recovery keys | Rotate to a root of their choosing: a takeover | Out of scope. Pin new keys on every host by hand |
|
|
329
|
+
|
|
330
|
+
A revocation, like a revocation list, reaches a host only when the host reads the new log. With freshness, a host that is fed old files stops trusting anything once its last timestamp expires, unless whoever feeds it also holds the timestamp key. Without freshness, a thief who holds the root key and controls delivery can keep a host on the old log indefinitely.
|
|
331
|
+
|
|
332
|
+
## Limits
|
|
333
|
+
|
|
334
|
+
| Item | Limit |
|
|
335
|
+
|---|---|
|
|
336
|
+
| Recovery keys per set | 16 |
|
|
337
|
+
| Events per log | 256 |
|
|
338
|
+
| Log file size | 4 MiB |
|
|
339
|
+
| Signatures per event | 34 (16 current + 16 new recovery keys + the new root + the new timestamp key) |
|
|
340
|
+
| `reason` | 1024 characters |
|
|
341
|
+
| Timestamp file size | 64 KiB |
|
|
342
|
+
| `max_lifetime` | 7 days |
|
|
343
|
+
|
|
344
|
+
## Recommended setups
|
|
345
|
+
|
|
346
|
+
| Organization | Recovery set | Why |
|
|
347
|
+
|---|---|---|
|
|
348
|
+
| Team or company | 3 keys, `rotate_threshold` 2, `revoke_threshold` 1, held by three people | Any one person can stop trust quickly; no single stolen or lost key prevents recovery or allows a takeover |
|
|
349
|
+
| One maintainer | 3 keys, `rotate_threshold` 2, `revoke_threshold` 1, stored in three places (for example a home safe, a bank box, a trusted person) | Same properties with one person. A 1-of-1 set is allowed but makes the single recovery key as powerful as the root |
|
|
350
|
+
|
|
351
|
+
Recovery private keys never sit next to `root.pem`, never in CI, and are used only to sign root events. Each trustee also keeps a printed copy of their key's fingerprint, so a signed event can be checked by eye.
|
|
352
|
+
|
|
353
|
+
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
|
+
|
|
355
|
+
## Commands (informative)
|
|
356
|
+
|
|
357
|
+
Proposed CLI shape; names may change during implementation. 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:
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
mago-ski recovery init --public-key a.pub --public-key b.pub --public-key c.pub \
|
|
361
|
+
--rotate-threshold 2 --revoke-threshold 1 # prints the policy "recovery" block
|
|
362
|
+
mago-ski root-events init --out root-events.json # empty log
|
|
363
|
+
|
|
364
|
+
# Revoke: one trustee is enough with revoke_threshold 1
|
|
365
|
+
mago-ski root-events prepare-revoke --events root-events.json --reason TEXT --out proposal.json
|
|
366
|
+
mago-ski root-events sign proposal.json --key a.pem
|
|
367
|
+
mago-ski root-events append proposal.json --events root-events.json
|
|
368
|
+
|
|
369
|
+
# Rotate: the new root and two trustees sign the same proposal
|
|
370
|
+
mago-ski root-events prepare-rotate --events root-events.json --new-root-public r1.pub \
|
|
371
|
+
[--new-recovery-public KEY.pub ... --rotate-threshold N --revoke-threshold N] \
|
|
372
|
+
[--new-timestamp-public t2.pub] --reason TEXT --out proposal.json
|
|
373
|
+
mago-ski root-events sign proposal.json --key r1.pem
|
|
374
|
+
mago-ski root-events sign proposal.json --key a.pem
|
|
375
|
+
mago-ski root-events sign proposal.json --key b.pem
|
|
376
|
+
mago-ski root-events append proposal.json --events root-events.json
|
|
377
|
+
|
|
378
|
+
# Freshness: run by the timestamp job every 6 hours
|
|
379
|
+
mago-ski timestamp sign --policy policy.json --key timestamp.pem --expires 24h
|
|
380
|
+
```
|
|
381
|
+
|
|
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.
|
|
383
|
+
|
|
384
|
+
Before rolling a v2 policy out to hosts, or after appending an event, the organization checks it the way a host would:
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
mago-ski policy check --policy policy.json
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
`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
|
+
|
|
392
|
+
## Changes to other documents
|
|
393
|
+
|
|
394
|
+
When this is implemented:
|
|
395
|
+
|
|
396
|
+
- **[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
|
+
- **[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.
|
|
398
|
+
- **[Pi host](../hosts/pi.md):** the *What it does* table gains a row for a revoked root (blocked in both modes), and the notification text describes the single report for trust failures.
|
|
399
|
+
- **[GitHub Action](../hosts/github-action.md):** a revoked root fails the check in shadow mode too, with one summary line.
|
|
400
|
+
- **[Threat model](../threat-model.md):** "A compromised root key" moves from *What it does not protect against* to the protections table, limited by the [leak table](#what-each-leak-allows) above. *Revocation timing* gains the freshness bound.
|
|
401
|
+
- **Migration:** every existing host's policy is edited once, to `mago.policy/v2` with a `recovery` block, an empty log and, ideally, `freshness`, after `mago-ski policy check` passes on it.
|
|
402
|
+
|
|
403
|
+
## Rationale: TUF and KERI
|
|
404
|
+
|
|
405
|
+
Both TUF and KERI address key compromise, and their ideas are compatible; this design takes its structure from TUF and one idea from KERI.
|
|
406
|
+
|
|
407
|
+
**What TUF contributes.** TUF separates a *root role* (a threshold of offline keys, used rarely) from the keys that sign day-to-day metadata. When a day-to-day key leaks, the root role signs new metadata naming its replacement; clients walk the chain of root versions from the one they shipped with. In mago-ski, the root key is the day-to-day key: it signs a revocation list every 30 days, often from automation. So the recovery set plays TUF's root role, root events are the chain of root versions, and the rule that a rotation is signed by both the old and the new keys is TUF's. The freshness check is TUF's *timestamp role*: an online key that frequently re-signs a short-lived statement naming the current metadata, so a client cannot be kept on old metadata unnoticed (a *freeze attack*). TUF secures Sigstore's root of trust and, as Uptane, software updates in vehicles, and PyPI adopted it in PEP 458. mago-ski already follows TUF elsewhere: expiring signed metadata, version-based rollback protection, and short revocation-list lifetimes.
|
|
408
|
+
|
|
409
|
+
**What KERI contributes.** KERI commits to the next keys by their digests, so a key's public half is revealed only when it is used (*pre-rotation*). This design keeps that property in the form mago-ski already uses everywhere: hosts pin recovery and timestamp keys by fingerprint, and public keys appear only in what they sign.
|
|
410
|
+
|
|
411
|
+
**What KERI would add, and why this design does not take it.**
|
|
412
|
+
|
|
413
|
+
- *A single pre-rotated successor key* (rotate by revealing the next key; the next key becomes the root). Simple, but whoever steals the successor from storage can take over, with no threshold to stop them.
|
|
414
|
+
- *Several pre-rotated next keys with a threshold*, which KERI also supports. This is close to the recovery set, with one difference: each set of next keys is used once. Every rotation reveals them and commits to new ones, so all the trustees' keys are replaced at every rotation. The recovery set, like TUF's root role, keeps its keys across rotations until the organization chooses to change them.
|
|
415
|
+
- *Key event logs with witnesses and watchers.* KERI is built for self-certifying identifiers with no central authority, where many parties must agree on a key's history. mago-ski always has a central authority (the organization that publishes the policy and the documents), which is the setting TUF was built for. The root event log is enough.
|
|
416
|
+
|
|
417
|
+
**Alternatives considered.**
|
|
418
|
+
|
|
419
|
+
- *A threshold on every root signature* (k-of-n to sign each trust root and revocation list). It would protect against a root leak too, but would need `k` people every 30 days for the revocation list.
|
|
420
|
+
- *A revocation-only key*, separate from rotation. Kept, as `revoke_threshold`: setting it to 1 gives any one trustee a fast emergency stop whose worst misuse is an outage.
|
|
421
|
+
- *Cross-signing by the old root* (the plan in v1). Useful for planned rotations, but a thief holding the old root can cross-sign their own key, so it does not help after a leak.
|
|
422
|
+
- *Freshness by minimum versions instead of exact digests.* Simpler to publish, because a new document would not need a new timestamp. But it only stops freezes: a thief with the root key and control over delivery could hand a host any trust root with a high enough version. Exact digests also stop that.
|
|
423
|
+
- *A revoked root that follows the mode.* Rejected: see [Revoked root](#revoked-root-blocked-in-every-mode).
|
|
424
|
+
|
|
425
|
+
**Cost.** Freshness adds one signature check and hashes of files the host has already read: about 0.2 ms per trust load, measured on a laptop. Root events cost one SHA-256 of the log per trust load once a walk is cached. The real cost of freshness is operational: an automated job with its own key, and an outage if that job stops for longer than `max_lifetime`.
|
|
426
|
+
|
|
427
|
+
## Open questions
|
|
428
|
+
|
|
429
|
+
1. **Gaps while publishing.** A host that reads the files in the middle of a publish sees a mismatch until its next load. Is atomic publishing (a new directory, then one switch) enough, or should a timestamp also accept the previous set of digests for a short time?
|
|
430
|
+
2. **Early warning.** Should hosts warn when the timestamp is close to expiring (for example, with less than a quarter of its lifetime left), so a stalled job is fixed before it causes an outage?
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Skill certificate v1
|
|
2
|
+
|
|
3
|
+
Status: draft, implemented by mago-ski 0.1 and later. This page's URL is the certificate's `predicateType`. Test vectors: [`tests/vectors/certificates/`](../../tests/vectors/certificates/).
|
|
4
|
+
|
|
5
|
+
A Skill certificate records that an approver approved one exact version of one Skill until a stated time. It does **not** state that the Skill is safe.
|
|
6
|
+
|
|
7
|
+
## Envelope
|
|
8
|
+
|
|
9
|
+
A [DSSE](https://github.com/secure-systems-lab/dsse/blob/master/protocol.md) envelope, serialized as canonical JSON (sorted keys, no whitespace, one trailing LF):
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{"payload":"<base64>","payloadType":"application/vnd.in-toto+json","signatures":[{"keyid":"sha256:<hex>","sig":"<base64>"}]}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- Exactly one signature, Ed25519 over the DSSE pre-authentication encoding `DSSEv1 <len(type)> <type> <len(payload)> <payload>`.
|
|
16
|
+
- `keyid` is `sha256:` + hex SHA-256 of the signer's DER SubjectPublicKeyInfo.
|
|
17
|
+
|
|
18
|
+
## Payload: in-toto Statement v1
|
|
19
|
+
|
|
20
|
+
The payload is canonical JSON:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"_type": "https://in-toto.io/Statement/v1",
|
|
25
|
+
"subject": [{ "name": "pdf-tools", "digest": { "magoSkillTreeV2": "<64 hex>" } }],
|
|
26
|
+
"predicateType": "https://github.com/mago-foundation/mago-ski/blob/main/docs/spec/skill-certificate-v1.md",
|
|
27
|
+
"predicate": {
|
|
28
|
+
"tree_profile": "mago.skill-tree/v2",
|
|
29
|
+
"files": [{ "path": "SKILL.md", "size": 412, "sha256": "<64 hex>", "exec": false }],
|
|
30
|
+
"approval": {
|
|
31
|
+
"approver_key_id": "sha256:<hex>",
|
|
32
|
+
"issued_at": "2026-10-09T12:00:00Z",
|
|
33
|
+
"expires_at": "2027-01-07T12:00:00Z",
|
|
34
|
+
"reason": "Reviewed scripts and network use"
|
|
35
|
+
},
|
|
36
|
+
"previous_digest": "sha256:<hex>"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| Field | Rule |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `subject` | Exactly one. `name`: 1–128 ASCII letters, digits, `.`, `_`, `-`, starting with a letter or digit. `digest.magoSkillTreeV2`: the [tree digest](skill-tree-v2.md) without the `sha256:` prefix |
|
|
44
|
+
| `files` | The per-file records of the tree, sorted as in the digest. Must include `SKILL.md`. Their digest must equal the subject digest |
|
|
45
|
+
| `approver_key_id` | Must equal the envelope's `keyid` |
|
|
46
|
+
| `issued_at`, `expires_at` | UTC, second precision, `YYYY-MM-DDTHH:MM:SSZ`; `expires_at` after `issued_at` |
|
|
47
|
+
| `reason` | Free text, 1–1024 characters, no control characters |
|
|
48
|
+
| `previous_digest` | The previously approved digest of this Skill, or `null`. Informational: it forms a readable update history, it does not grant anything |
|
|
49
|
+
|
|
50
|
+
No other fields are allowed anywhere. Unknown fields make the certificate unverifiable.
|
|
51
|
+
|
|
52
|
+
## Where certificates live
|
|
53
|
+
|
|
54
|
+
A host looks for certificates for Skill `NAME`, in this order:
|
|
55
|
+
|
|
56
|
+
1. a file named explicitly by the caller;
|
|
57
|
+
2. `<certificate_dir>/NAME.cert.json` for each `certificate_dirs` entry in the policy (for Skills the organization does not modify);
|
|
58
|
+
3. `.mago-ski-cert.json` in the Skill root (excluded from the tree digest).
|
|
59
|
+
|
|
60
|
+
If any candidate verifies, the Skill is verified. Otherwise the most specific failure is reported (see [verification](verification.md)).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Skill tree digest: `mago.skill-tree/v2`
|
|
2
|
+
|
|
3
|
+
Status: draft, implemented by mago-ski 0.1 and later. Test vectors: [`tests/vectors/trees.json`](../../tests/vectors/trees.json).
|
|
4
|
+
|
|
5
|
+
The tree digest identifies the exact contents of a Skill directory. A certificate approves one tree digest.
|
|
6
|
+
|
|
7
|
+
## Which files are covered
|
|
8
|
+
|
|
9
|
+
Start at the Skill root (the directory that holds `SKILL.md`) and walk it recursively.
|
|
10
|
+
|
|
11
|
+
- Every regular file is covered, except:
|
|
12
|
+
- the entry named `.git` at the root (file or directory);
|
|
13
|
+
- the file `.mago-ski-cert.json` at the root (the in-tree certificate);
|
|
14
|
+
- paths listed in `.skilldigestignore` at the root (below).
|
|
15
|
+
- `.skilldigestignore` itself is covered when present.
|
|
16
|
+
- `SKILL.md` at the root is required and always covered. A tree without it is not a Skill and has no digest.
|
|
17
|
+
- These make the whole tree **unverifiable** (the digest is not computed):
|
|
18
|
+
- symbolic links, sockets, FIFOs, devices;
|
|
19
|
+
- a path component that is not valid UTF-8, is not in Unicode NFC, is empty, `.` or `..`, contains `/`, `\`, `:` or a control character, ends with a dot or space, or is a reserved Windows device name;
|
|
20
|
+
- two paths that are equal after NFKC normalization and lowercasing (they would collide on case-insensitive file systems);
|
|
21
|
+
- more than 20,000 files, 50,000 entries, depth 64, 64 MiB per file, 256 MiB total, or 4,096 bytes per relative path;
|
|
22
|
+
- a file that changes while it is being read.
|
|
23
|
+
- Empty directories and other metadata (owner, timestamps, permissions other than the executable bit) are not covered.
|
|
24
|
+
|
|
25
|
+
## `.skilldigestignore`
|
|
26
|
+
|
|
27
|
+
UTF-8 text, at most 64 KiB and 256 patterns. Blank lines and lines starting with `#` are skipped. Each other line is one relative POSIX path:
|
|
28
|
+
|
|
29
|
+
- `name/` excludes the directory `name` and everything under it;
|
|
30
|
+
- `name` excludes a file or directory with that exact relative path.
|
|
31
|
+
|
|
32
|
+
Globs (`* ? [ ] !`), absolute paths, `.` or `..` segments, backslashes, the ignore file itself and `SKILL.md` are rejected.
|
|
33
|
+
|
|
34
|
+
Excluded files are not approved. Hosts must not serve them as Skill content: the Pi host refuses to read any file inside a verified Skill that is not in the certificate's file list.
|
|
35
|
+
|
|
36
|
+
## Per-file record
|
|
37
|
+
|
|
38
|
+
For each covered file:
|
|
39
|
+
|
|
40
|
+
| Field | Value |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `path` | Relative path, `/`-separated, UTF-8, NFC |
|
|
43
|
+
| `size` | Byte length |
|
|
44
|
+
| `sha256` | Lowercase hex SHA-256 of the raw bytes (no line-ending normalization) |
|
|
45
|
+
| `exec` | `true` if any POSIX execute bit (`0o111`) is set. Always `false` on Windows, which has no mode bits |
|
|
46
|
+
|
|
47
|
+
## Digest
|
|
48
|
+
|
|
49
|
+
1. Sort records by the UTF-8 bytes of `path` (byte order, not locale order).
|
|
50
|
+
2. Build `{"files": [...records], "profile": "mago.skill-tree/v2"}`.
|
|
51
|
+
3. Serialize as canonical JSON: object keys sorted, no whitespace, integers only, one trailing LF.
|
|
52
|
+
4. The digest is `sha256:` followed by the lowercase hex SHA-256 of those bytes.
|
|
53
|
+
|
|
54
|
+
Because the digest is computed from the record list, anyone holding a certificate's file list can recompute and check its digest, and a host can verify a single file by comparing its hash with one record.
|
|
55
|
+
|
|
56
|
+
## Known limitations
|
|
57
|
+
|
|
58
|
+
- On Windows the executable bit is always `false`, so a Skill approved on Linux or macOS with an executable script will not verify on Windows. mago-ski does not support Windows yet for this reason.
|
|
59
|
+
- Some file systems report every file as executable (for example WSL's DrvFs mounts of Windows drives). Digest Skills on a native Linux or macOS file system.
|