@cygnuxlabs/tracekit 1.5.0 → 1.5.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/dist/v2/adapters/openai-agents.js +7 -1
- package/dist/v2/rpc_schema.js +16 -16
- package/dist/verify/cli.js +13 -9
- package/dist/verify/explain.d.ts +6 -5
- package/dist/verify/explain.js +177 -61
- package/dist/verify/index.d.ts +5 -1
- package/dist/verify/index.js +62 -31
- package/dist/verify/primitives.d.ts +3 -0
- package/dist/verify/primitives.js +20 -0
- package/dist/verify/web.js +4 -4
- package/dist/verify/zip.d.ts +4 -0
- package/dist/verify/zip.js +5 -4
- package/dist/verify.html +351 -115
- package/package.json +5 -5
package/dist/verify/explain.js
CHANGED
|
@@ -16,6 +16,8 @@ export const asJson = (rep, code) => ({ exit_code: code, checks: rep.checks, fai
|
|
|
16
16
|
export const asText = (rep, code) => formatReport(rep) + `\nExit code ${code}`
|
|
17
17
|
+ (code === EXIT_OK && rep.warnings.length ? ` (3 with --strict: ${rep.warnings.length} warning(s))` : "") + ".\n";
|
|
18
18
|
const failed = (rep, name) => rep.checks.find((c) => c.check === name && c.status === "fail");
|
|
19
|
+
/** Only the witness quorum failed: too few of the witnesses the trust file pins cosigned; the records verified. */
|
|
20
|
+
const quorumOnly = (rep) => rep.failures.length === 1 && failed(rep, "witness quorum");
|
|
19
21
|
const anchored = (rep) => !rep.checks.some((c) => c.check === "trust config" && c.status === "warn");
|
|
20
22
|
const v1 = (rep) => rep.checks.some((c) => c.check === "bundle readable"
|
|
21
23
|
&& c.problems.some((p) => p.startsWith("a format v1 bundle")));
|
|
@@ -44,22 +46,29 @@ export function verdict(rep, code) {
|
|
|
44
46
|
return { word: "FAILED", means: "This bundle is not signed by the signer your trust file names, or its checkpoint "
|
|
45
47
|
+ "was changed.", notMeans: "It doesn't say who made the bundle. If the trust file is the right one, don't rely "
|
|
46
48
|
+ "on the bundle." };
|
|
49
|
+
const quorum = quorumOnly(rep);
|
|
50
|
+
if (quorum)
|
|
51
|
+
return { word: "FAILED", means: `Too few of the witnesses your trust file pins cosigned this bundle's checkpoint `
|
|
52
|
+
+ `(${clean(quorum.detail)}). Nothing else failed.`,
|
|
53
|
+
notMeans: "It doesn't mean the contents were changed: a witness name or key in your trust file that differs from "
|
|
54
|
+
+ "the one the witness signs with gives this same result." };
|
|
47
55
|
return { word: "FAILED", means: "This bundle doesn't match what was signed: something in it was changed, removed or "
|
|
48
56
|
+ `added after signing. Failed: ${rep.failures.join(", ")}.`,
|
|
49
57
|
notMeans: "It doesn't say who changed it or why: the failed lines below show what doesn't match." };
|
|
50
58
|
}
|
|
51
59
|
const readable = rep.checks.find((c) => c.check === "bundle readable");
|
|
52
60
|
const nothing = "Nothing failed: it doesn't mean the bundle is bad.";
|
|
61
|
+
// the word the command-line verifiers print in the Integrity line
|
|
62
|
+
const word = rep.integrity === "UNUSABLE BUNDLE" ? "UNUSABLE BUNDLE" : "UNVERIFIABLE";
|
|
53
63
|
if (failed(rep, "trust config"))
|
|
54
|
-
return { word
|
|
64
|
+
return { word, means: "The trust file couldn't be used, so nothing in the bundle was checked.", notMeans: nothing };
|
|
55
65
|
if (v1(rep))
|
|
56
|
-
return { word
|
|
57
|
-
+ "
|
|
66
|
+
return { word, means: "This is a format v1 bundle (from Tracekit's laptop signer); this page checks format v2 "
|
|
67
|
+
+ "bundles, so nothing was checked.", notMeans: nothing };
|
|
58
68
|
if (rep.integrity.startsWith("UNVERIFIABLE (needs"))
|
|
59
|
-
return { word
|
|
60
|
-
notMeans: nothing };
|
|
69
|
+
return { word, means: `This bundle needs a newer verifier than this page (Tracekit ${VERSION}).`, notMeans: nothing };
|
|
61
70
|
if (readable)
|
|
62
|
-
return { word
|
|
71
|
+
return { word, means: "This file couldn't be read as a Tracekit bundle, so nothing in it was checked.",
|
|
63
72
|
notMeans: "Nothing in it can be relied on until a readable copy verifies." };
|
|
64
73
|
if (!anchored(rep))
|
|
65
74
|
return { word: "UNVERIFIABLE", means: "Signatures are intact, but you haven't said whose signer you trust.",
|
|
@@ -77,8 +86,10 @@ export function nextSteps(rep, code, names) {
|
|
|
77
86
|
if (code === EXIT_OK)
|
|
78
87
|
return rep.warnings.length ? [{ text: `Read the ${rep.warnings.length} warning(s) below: each says what to look at. `
|
|
79
88
|
+ "They don't change the verdict (with --strict the command line exits 3)." }] : [];
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
const trustFile = failed(rep, "trust config");
|
|
90
|
+
if (trustFile)
|
|
91
|
+
return [{ text: `Fix the trust file, or choose the right one: ${clean(trustFile.detail)}. If it isn't the sender's, `
|
|
92
|
+
+ `ask for ${TRUST_FILE}.` }];
|
|
82
93
|
if (readable?.problems.length)
|
|
83
94
|
return readable.problems.map((p) => {
|
|
84
95
|
const at = p.search(/(npx|uvx) /);
|
|
@@ -94,6 +105,10 @@ export function nextSteps(rep, code, names) {
|
|
|
94
105
|
if (failed(rep, "checkpoint") && anchored(rep))
|
|
95
106
|
steps.push({ text: `Make sure the trust file is ${TRUST_FILE.replace("the sender's", "the sender's own")}. With `
|
|
96
107
|
+ "the right one, this bundle isn't theirs: don't rely on it." });
|
|
108
|
+
else if (quorumOnly(rep))
|
|
109
|
+
steps.push({ text: "Check the witness names and keys in your trust file: each must be the name and key the "
|
|
110
|
+
+ "witness cosigns with. If they are, ask the sender for a copy exported after the witnesses you require "
|
|
111
|
+
+ "cosigned." });
|
|
97
112
|
else
|
|
98
113
|
steps.push({ text: "Don't rely on this bundle's contents. Ask the sender for the original and compare its SHA-256 "
|
|
99
114
|
+ "with theirs:", command: `shasum -a 256 ${b}` });
|
|
@@ -109,56 +124,153 @@ export function nextSteps(rep, code, names) {
|
|
|
109
124
|
return [{ text: "Verify it with the reference verifier, which checks this:",
|
|
110
125
|
command: `uvx --from tracekit-ai tracekit verify ${b} --trust ${t}` }];
|
|
111
126
|
}
|
|
112
|
-
/**
|
|
127
|
+
/** What each line means, for each outcome it can have (docs/verdicts.md#lines): a line that fails or warns never reads
|
|
128
|
+
* as a pass. */
|
|
113
129
|
export const MEANING = {
|
|
114
|
-
"trust config":
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
"
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
130
|
+
"trust config": {
|
|
131
|
+
warn: "You chose no trust file, so no log key you trust checked the checkpoint: the bundle can't be VERIFIED.",
|
|
132
|
+
fail: "Your trust file (the log key and witnesses you trust) can't be used, for the reason on this line, so nothing "
|
|
133
|
+
+ "in the bundle was checked.",
|
|
134
|
+
},
|
|
135
|
+
"bundle readable": { fail: "This verifier can't read the file as a Tracekit v2 bundle: it isn't one, is damaged, or "
|
|
136
|
+
+ "needs a newer verifier. Nothing in it was checked." },
|
|
137
|
+
"bundle structure": { fail: "The bundle is malformed in a way no other line covers, so it couldn't be fully "
|
|
138
|
+
+ "checked." },
|
|
139
|
+
"manifest": {
|
|
140
|
+
pass: "The files in the bundle are exactly those its manifest lists, with those hashes.",
|
|
141
|
+
fail: "A file was added, removed or changed after the bundle was exported: the files don't match its manifest.",
|
|
142
|
+
},
|
|
143
|
+
"checkpoint": {
|
|
144
|
+
pass: "The log's checkpoint (the signed root of every record) matches the proofs and is signed by the log key "
|
|
145
|
+
+ "your trust file pins; without a trust file its signature isn't checked.",
|
|
146
|
+
fail: "The checkpoint isn't signed by the log key your trust file pins, or it was changed: the bundle comes from "
|
|
147
|
+
+ "another signer, or was edited.",
|
|
148
|
+
},
|
|
149
|
+
"witness quorum": {
|
|
150
|
+
pass: "Enough witnesses your trust file pins cosigned the checkpoint: they vouch it was not rolled back.",
|
|
151
|
+
fail: "Fewer witnesses your trust file pins cosigned the checkpoint than it requires: not enough vouch it was not "
|
|
152
|
+
+ "rolled back.",
|
|
153
|
+
},
|
|
154
|
+
"keys": {
|
|
155
|
+
pass: "The record keys were declared by records the checkpoint includes, in order, and retired keys stop signing.",
|
|
156
|
+
fail: "A key record is missing from the checkpointed tree, out of order, or retires a key never declared: the "
|
|
157
|
+
+ "record keys can't be trusted.",
|
|
158
|
+
warn: "Nothing proves the bundle shows every key retirement: one left out would not show. It doesn't mean one was.",
|
|
159
|
+
},
|
|
160
|
+
"run parts": {
|
|
161
|
+
pass: "A long run comes in numbered parts: none is missing between the first and the last, extra or out of "
|
|
162
|
+
+ "order, so they read as one run. Parts cut off its end leave it open, never VERIFIED.",
|
|
163
|
+
fail: "A long run's parts don't read as one run: a part is missing, extra, empty or out of order.",
|
|
164
|
+
},
|
|
165
|
+
"signatures": {
|
|
166
|
+
pass: "Every record's signature verifies under a key valid at its position: no record was edited after signing.",
|
|
167
|
+
fail: "A record doesn't verify: it was edited after signing, or signed by a key not valid at its position.",
|
|
168
|
+
},
|
|
169
|
+
"run chain": {
|
|
170
|
+
pass: "Each run's records follow one another without a gap from the first: none deleted, swapped or added.",
|
|
171
|
+
fail: "A run's records don't follow one another: one was deleted, swapped, copied from another run, or added "
|
|
172
|
+
+ "after the run ended.",
|
|
173
|
+
},
|
|
174
|
+
"inclusion": {
|
|
175
|
+
pass: "Each run's first and last records are in the checkpointed tree: the run wasn't rebuilt.",
|
|
176
|
+
fail: "A run's first or last record isn't in the checkpointed tree: the run was rebuilt or cut short, or the "
|
|
177
|
+
+ "proofs are for another tree.",
|
|
178
|
+
},
|
|
179
|
+
"policy snapshot": {
|
|
180
|
+
pass: "The bundled policy file is named by its own hash: it wasn't edited.",
|
|
181
|
+
fail: "The bundled policy file doesn't match the hash it is named by: it was edited.",
|
|
182
|
+
},
|
|
183
|
+
"policy": { warn: "A tool call ran against a deny, or an ask nobody approved, and the signer recorded it." },
|
|
184
|
+
"held calls": { warn: "A call held for a gateway or executor got no result before its run ended." },
|
|
185
|
+
"gaps": { warn: "The signer recorded something a person should read: a gap, a tamper attempt or a mismatched "
|
|
186
|
+
+ "approval." },
|
|
187
|
+
"external decisions": {
|
|
188
|
+
pass: "Decisions imported from another policy system: none disagreed with the signer's.",
|
|
189
|
+
warn: "A decision imported from another policy system disagreed with the signer's: the signer's is the one that "
|
|
190
|
+
+ "applied.",
|
|
191
|
+
},
|
|
192
|
+
"coverage": {
|
|
193
|
+
pass: "Which capture layers reported; the signer matched every call across them. The record is only as complete "
|
|
194
|
+
+ "as those layers.",
|
|
195
|
+
warn: "The signer couldn't match some calls across capture layers, or saw a host no call explains. It doesn't "
|
|
196
|
+
+ "mean the agent hid a call: a layer may simply not have reported.",
|
|
197
|
+
},
|
|
198
|
+
"coverage matrix": { pass: "How each kind of action was covered: enforced, observed, only reported by the agent, or "
|
|
199
|
+
+ "not at all." },
|
|
200
|
+
"observers": { warn: "An observer outside the agent went silent or restarted while the run was open." },
|
|
201
|
+
"reviews": {
|
|
202
|
+
pass: "Reviews of the run, each labelled by who wrote it; every signed finding cites records the run has.",
|
|
203
|
+
warn: "A signed finding is self-asserted: the agent could have written it about itself.",
|
|
204
|
+
fail: "A signed finding cites a record the run doesn't have or that has another hash, or isn't shaped as a "
|
|
205
|
+
+ "signer writes one: it misstates the evidence.",
|
|
206
|
+
},
|
|
207
|
+
"reviews counted": { warn: "Findings whose analysed run isn't in the bundle, so their citations weren't checked." },
|
|
208
|
+
"incidents": {
|
|
209
|
+
pass: "Detections the signer opened, recomputed from the run's records where the bundle allows.",
|
|
210
|
+
fail: "An incident doesn't follow from the run's records, or the records don't honour a hold or quarantine it "
|
|
211
|
+
+ "recorded.",
|
|
212
|
+
},
|
|
213
|
+
"incident policies": { warn: "Policies an incident cites that aren't in the bundle: those incidents are the "
|
|
214
|
+
+ "signer's word." },
|
|
215
|
+
"content vault": { pass: "Who read or erased retained content, as the signer recorded it." },
|
|
216
|
+
"tiers": {
|
|
217
|
+
pass: "Tool calls by how they were captured: T2 gateway or executor, T1 adapter, T3 import (receipt only).",
|
|
218
|
+
warn: "A tool call was decided and completed by different capture paths, so it counts at the weaker tier.",
|
|
219
|
+
},
|
|
220
|
+
"args source": { pass: "Whether recorded arguments are the model's exact bytes (raw), parsed, or changed by a "
|
|
221
|
+
+ "framework." },
|
|
222
|
+
"isolation": { pass: "How the signer measured its separation from the agent: separate-user and remote are out of "
|
|
223
|
+
+ "its reach." },
|
|
224
|
+
"principals": { pass: "The person or service each run acted for, attested by the signer or asserted by the app." },
|
|
225
|
+
"harness": { pass: "The agent harness the signer bound each run to." },
|
|
226
|
+
"fail-open classes": {
|
|
227
|
+
pass: "No tool class runs while the signer is down: every call needed the signer.",
|
|
228
|
+
warn: "Tool classes allowed to run while the signer is down, so such calls may be unrecorded.",
|
|
229
|
+
},
|
|
230
|
+
"key assurance": { pass: "Whether the record keys are only declared by the log (asserted) or certified by an "
|
|
231
|
+
+ "issuer." },
|
|
232
|
+
"approvals by people": { pass: "Held calls approved by people." },
|
|
233
|
+
"approvals by agents": {
|
|
234
|
+
pass: "Held calls approved by agents (model output), checked against the rules that allow it.",
|
|
235
|
+
warn: "Held calls approved by agents (model output); some couldn't be checked against their rules: the bundle "
|
|
236
|
+
+ "lacks the policy they were held under.",
|
|
237
|
+
fail: "An agent approved a call the rules for agent approvals don't let it approve.",
|
|
238
|
+
},
|
|
239
|
+
"break-glass approvals": { warn: "Approvals given under the break-glass role, with who and why." },
|
|
240
|
+
"not interpreted": { warn: "Records carry an extension this verifier doesn't read. They verified like every other "
|
|
241
|
+
+ "record." },
|
|
242
|
+
"gateway amendments": {
|
|
243
|
+
pass: "Requests the LLM gateway changed so the provider shows its reasoning; each record commits to the request "
|
|
244
|
+
+ "as sent.",
|
|
245
|
+
warn: "A record carries a gateway amendment where or how the signer never writes one. The record verified like "
|
|
246
|
+
+ "every other.",
|
|
247
|
+
},
|
|
248
|
+
"openshell policy": {
|
|
249
|
+
pass: "Changes of the sandbox's policy or configuration that NVIDIA OpenShell reported, signed into the run as "
|
|
250
|
+
+ "OpenShell's report.",
|
|
251
|
+
warn: "A record carries an OpenShell policy change where or how the signer never writes one. The record verified "
|
|
252
|
+
+ "like every other.",
|
|
253
|
+
},
|
|
254
|
+
"constraints": {
|
|
255
|
+
pass: "What the person's request said not to do, added while the run was open, and the calls it held.",
|
|
256
|
+
fail: "A call held by a live constraint comes before any constraint in its run, or wasn't held for approval: the "
|
|
257
|
+
+ "signer never writes either.",
|
|
258
|
+
},
|
|
259
|
+
"run-set": {
|
|
260
|
+
pass: "Every run of the tenant in the registry range is in the bundle (COMPLETE).",
|
|
261
|
+
fail: "A run of the tenant in the registry range is missing or cut short, or the bundle holds one that doesn't "
|
|
262
|
+
+ "belong (INCOMPLETE).",
|
|
263
|
+
},
|
|
264
|
+
"tenant-level gaps": { warn: "Signer gaps in the range that concern every tenant, such as witness failures." },
|
|
265
|
+
"log tail": {
|
|
266
|
+
pass: "No records follow the checkpoint: a log.closed proves it is the log's last.",
|
|
267
|
+
warn: "Nothing proves no records follow the checkpoint (no log.closed). It doesn't mean any were hidden.",
|
|
268
|
+
},
|
|
269
|
+
"rekor anchor": { warn: "A Rekor transparency-log anchor of the checkpoint, which this page can't check." },
|
|
270
|
+
"SLH-DSA-SHA2-128s checkpoint signature": { warn: "A post-quantum checkpoint signature, which browsers can't check "
|
|
271
|
+
+ "yet." },
|
|
272
|
+
"record-key certificates": { warn: "Certificates of the record keys, which this page doesn't check." },
|
|
273
|
+
"tracekit why findings": { warn: "tracekit why investigation findings, which this page doesn't check." },
|
|
162
274
|
};
|
|
163
275
|
const day = (ts) => ts.slice(0, 19).replace("T", " ") + " UTC";
|
|
164
276
|
/** A few plain facts about the bundle's runs, from their records ({name: bytes}, the runs/ files, a run's parts read as
|
|
@@ -177,11 +289,13 @@ export function summarize(files, rep) {
|
|
|
177
289
|
const cp = rep.checks.find((c) => c.check === "checkpoint")?.detail.split(" at tree size")[0];
|
|
178
290
|
if (cp)
|
|
179
291
|
out.push(["Signer", `log ${cp}` + (anchored(rep) ? ", the key your trust file pins" : ", not checked (no trust file)")]);
|
|
180
|
-
const level = rep.assurance.split(";")[0];
|
|
292
|
+
const level = rep.assurance.split(";")[0], self = rep.assurance.includes("; approvals: self");
|
|
293
|
+
const unwitnessed = "no independent witness vouches for the checkpoint";
|
|
181
294
|
out.push(["Assurance", level === "witnessed" ? "witnessed: independent witnesses cosigned the checkpoint"
|
|
182
295
|
: level === "local" ? "local: only witnesses the log's operator runs cosigned the checkpoint"
|
|
183
|
-
: level === "dev" ? "dev:
|
|
184
|
-
:
|
|
296
|
+
: level === "dev" && self ? "dev: a run holds a self-approval (whoever asked for the call approved it)"
|
|
297
|
+
+ (rep.assurance.includes("; no witness cosignature") ? `, and ${unwitnessed}` : "")
|
|
298
|
+
: level === "dev" ? `dev: ${unwitnessed}` : level]);
|
|
185
299
|
const agents = runs.map((rs) => rs[0]).filter((e) => e?.type === "run.registered").map((e) => {
|
|
186
300
|
const id = e.data?.identity;
|
|
187
301
|
return `${JSON.stringify(String(e.data?.agent?.name ?? "agent"))}` + (id ? ` (${id.scheme}:${id.subject})` : "");
|
|
@@ -193,11 +307,13 @@ export function summarize(files, rep) {
|
|
|
193
307
|
out.push(["Tool calls", `${decisions.length} decided` + (decisions.length ? ": " + ["allow", "deny", "ask"]
|
|
194
308
|
.map((d) => `${decisions.filter((x) => x === d).length} ${d}`).join(", ") : "")]);
|
|
195
309
|
const answers = new Map(of("approval").map((e) => [e.data?.approval_id, e.data]));
|
|
310
|
+
const expired = new Set(of("approval.expired").map((e) => e.data?.approval_id));
|
|
196
311
|
const held = of("approval.request").map((e) => {
|
|
197
312
|
const a = answers.get(e.data?.approval_id);
|
|
198
313
|
const who = a ? `${a.decision === "approve" ? "approved" : a.decision === "reject" ? "rejected" : a.decision} by `
|
|
199
314
|
+ `${a.person ?? a.approver}` + (a.approver_kind === "agent" ? " (an agent)" : "")
|
|
200
|
-
+ (a.self_approved ? " (self-approved)" : "") + (a.break_glass ? " (break-glass)" : "")
|
|
315
|
+
+ (a.self_approved ? " (self-approved)" : "") + (a.break_glass ? " (break-glass)" : "")
|
|
316
|
+
: expired.has(e.data?.approval_id) ? "expired before anyone answered" : "no answer recorded";
|
|
201
317
|
const tool = e.data?.binding?.tool ?? e.tool_call_id;
|
|
202
318
|
return `${tool == null ? "a call" : JSON.stringify(String(tool))}: ${who}`;
|
|
203
319
|
});
|
package/dist/verify/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { MAX_ENTRIES, MAX_ENTRY, MAX_TOTAL, Unusable, readZip } from "./zip.js";
|
|
2
2
|
export { StrictJSONError, canonicalize, strictParse, strictParseBytes } from "./jcs.js";
|
|
3
3
|
/** The bundle format version this verifier implements: a bundle needing a later one is UNVERIFIABLE. */
|
|
4
|
-
export declare const VERSION = "1.5.
|
|
4
|
+
export declare const VERSION = "1.5.1";
|
|
5
5
|
export declare const EXIT_OK = 0, EXIT_FAIL = 1, EXIT_BAD = 2, EXIT_WARN = 3;
|
|
6
|
+
/** The integrity of a trust config that can't be used: nothing in the bundle was checked. */
|
|
7
|
+
export declare const TRUST_UNUSABLE = "UNVERIFIABLE (the trust file can't be used)";
|
|
6
8
|
export type Check = {
|
|
7
9
|
check: string;
|
|
8
10
|
status: "pass" | "warn" | "fail";
|
|
@@ -46,5 +48,7 @@ export declare function runFiles(names: Iterable<string>): Map<string, string[]>
|
|
|
46
48
|
/** `x` without control characters and the bidirectional and zero-width format characters that would reorder or hide
|
|
47
49
|
* the text around them, as the report prints bundle-derived strings. */
|
|
48
50
|
export declare const clean: (x: string) => string;
|
|
51
|
+
/** The Assurance line as the reports print it: an assurance level rates only evidence that verified. */
|
|
52
|
+
export declare const assuranceLine: (rep: Report) => string;
|
|
49
53
|
/** The report as text, as the reference CLI prints it; `clean` drops characters from bundle-derived strings. */
|
|
50
54
|
export declare function formatReport(rep: Report): string;
|
package/dist/verify/index.js
CHANGED
|
@@ -17,18 +17,20 @@
|
|
|
17
17
|
* `verify(bundle, null)` (no trust config) checks what needs no pinned key and is never VERIFIED. web.ts is this
|
|
18
18
|
* verifier as a browser page (verify.html).
|
|
19
19
|
*/
|
|
20
|
-
import { canonicalize, repr as quoted, strictParseBytes } from "./jcs.js";
|
|
21
|
-
import { HYBRID, NoteError, SIGNER_LEAVES, b64decode, bytes, equal, keyAlg, leafHash, openNote, parseLeaf, parseVkey, registryOrigin, runHash, sha256hex, spkiKid, unhex, verifyConsistency, verifyInclusion, verifyV2, vkey, } from "./primitives.js";
|
|
20
|
+
import { StrictJSONError, canonicalize, repr as quoted, strictParseBytes } from "./jcs.js";
|
|
21
|
+
import { HYBRID, NoteError, SIGNER_LEAVES, b64decode, bytes, checkWitnesses, equal, keyAlg, leafHash, openNote, parseLeaf, parseVkey, registryOrigin, runHash, sha256hex, spkiKid, unhex, verifyConsistency, verifyInclusion, verifyV2, vkey, } from "./primitives.js";
|
|
22
22
|
import { Detector } from "./detect.js";
|
|
23
23
|
import { same, validateEvent } from "./schema.js";
|
|
24
|
-
import { MAX_ENTRY, Unusable, readZip } from "./zip.js";
|
|
24
|
+
import { BadZipFile, MAX_ENTRY, Unusable, readZip } from "./zip.js";
|
|
25
25
|
export { MAX_ENTRIES, MAX_ENTRY, MAX_TOTAL, Unusable, readZip } from "./zip.js";
|
|
26
26
|
export { StrictJSONError, canonicalize, strictParse, strictParseBytes } from "./jcs.js";
|
|
27
27
|
/** The bundle format version this verifier implements: a bundle needing a later one is UNVERIFIABLE. */
|
|
28
|
-
export const VERSION = "1.5.
|
|
28
|
+
export const VERSION = "1.5.1";
|
|
29
29
|
/** The browser verifier of the latest release (docs/RELEASING.md). */
|
|
30
30
|
const PAGE = "https://cygnux-labs.github.io/Tracekit/verify/";
|
|
31
31
|
export const EXIT_OK = 0, EXIT_FAIL = 1, EXIT_BAD = 2, EXIT_WARN = 3;
|
|
32
|
+
/** The integrity of a trust config that can't be used: nothing in the bundle was checked. */
|
|
33
|
+
export const TRUST_UNUSABLE = "UNVERIFIABLE (the trust file can't be used)";
|
|
32
34
|
const FORMAT = "tracekit.bundle.v2";
|
|
33
35
|
const MAX_LINE = 1 << 20;
|
|
34
36
|
const MIN_RECORD = 256; // no signed record's line is shorter: its hash, signature, ids and timestamp alone are longer
|
|
@@ -86,6 +88,9 @@ function manifestDetail(listed, hashes, bad) {
|
|
|
86
88
|
: Object.hasOwn(listed, n) ? "missing" : "not listed"})`);
|
|
87
89
|
return "files differ from the manifest: " + how.join(", ") + (bad.length > 5 ? ` and ${bad.length - 5} more` : "");
|
|
88
90
|
}
|
|
91
|
+
/** A check's detail: what it found when it passed, else how many problems in what (its lines say which), so a failed
|
|
92
|
+
* line never reads as a pass. */
|
|
93
|
+
const found = (problems, passed, scope) => problems.length ? `${problems.length} problem(s) in ${scope}` : passed;
|
|
89
94
|
const kind = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
|
|
90
95
|
function at(o, k) {
|
|
91
96
|
if (!isObj(o))
|
|
@@ -179,13 +184,30 @@ async function loadTrust(data, name) {
|
|
|
179
184
|
&& Array.isArray(opt(t, "issuers")) && opt(t, "issuers").every((i) => exactly(i, ["vkey", "issuance_log_vkey"])
|
|
180
185
|
&& Object.values(i).every((v) => typeof v === "string"))
|
|
181
186
|
&& Array.isArray(opt(t, "analyzers"))
|
|
182
|
-
&& opt(t, "analyzers").every((a) => typeof a === "string" && /^[a-z0-9_]
|
|
187
|
+
&& opt(t, "analyzers").every((a) => typeof a === "string" && /^[a-z0-9_]+:[^\n]+$/.test(a));
|
|
183
188
|
if (!ok)
|
|
184
189
|
throw new ValueError(`${name}: not a v2 trust config (logs, witnesses, algs, witnesses_required, rekor, monitors, `
|
|
185
190
|
+ "issuers, analyzers)");
|
|
186
191
|
for (const k of [...t.logs, ...opt(t, "witnesses").map((w) => w.vkey), ...opt(t, "monitors").map((m) => m.vkey),
|
|
187
|
-
...opt(t, "issuers").flatMap((i) => Object.values(i))])
|
|
188
|
-
|
|
192
|
+
...opt(t, "issuers").flatMap((i) => Object.values(i))]) {
|
|
193
|
+
try {
|
|
194
|
+
await parseVkey(k);
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
if (!(e instanceof NoteError))
|
|
198
|
+
throw e;
|
|
199
|
+
throw new ValueError(`pinned key ${repr(cut(k, 80))} is not a vkey: ${e.message}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
await checkWitnesses(opt(t, "witnesses").map((w) => w.vkey));
|
|
203
|
+
const classes = new Map();
|
|
204
|
+
for (const w of opt(t, "witnesses")) {
|
|
205
|
+
const c = classes.get(w.vkey) ?? w.class;
|
|
206
|
+
if (c !== w.class)
|
|
207
|
+
throw new ValueError(`trust pins witness ${w.vkey.split("+")[0]} with two classes (${c}, `
|
|
208
|
+
+ `${w.class}); a witness has one class: list it once, with the class you give it`);
|
|
209
|
+
classes.set(w.vkey, c);
|
|
210
|
+
}
|
|
189
211
|
t.witnesses ??= [];
|
|
190
212
|
t.witnesses_required ??= 0;
|
|
191
213
|
t.issuers ??= [];
|
|
@@ -234,7 +256,9 @@ export async function verify(bundle, trust, names = { bundle: "BUNDLE", trust: "
|
|
|
234
256
|
t = await loadTrust(trust, names.trust);
|
|
235
257
|
}
|
|
236
258
|
catch (e) {
|
|
237
|
-
rep.
|
|
259
|
+
rep.integrity = TRUST_UNUSABLE;
|
|
260
|
+
rep.check("trust config", false, e instanceof StrictJSONError ? `not valid JSON (${e.message})`
|
|
261
|
+
: e instanceof ValueError || e instanceof NoteError ? e.message : errorText(e));
|
|
238
262
|
return { report: rep, code: EXIT_BAD };
|
|
239
263
|
}
|
|
240
264
|
const floats = new WeakMap();
|
|
@@ -242,7 +266,7 @@ export async function verify(bundle, trust, names = { bundle: "BUNDLE", trust: "
|
|
|
242
266
|
files = await readZip(bundle);
|
|
243
267
|
const m = files.get("manifest.json");
|
|
244
268
|
if (!m)
|
|
245
|
-
throw new
|
|
269
|
+
throw new BadZipFile("no manifest.json");
|
|
246
270
|
files.delete("manifest.json");
|
|
247
271
|
manifest = strictParseBytes(m, floats);
|
|
248
272
|
v1 = isObj(manifest) && manifest.format === "tracekit.bundle.v1";
|
|
@@ -259,7 +283,9 @@ export async function verify(bundle, trust, names = { bundle: "BUNDLE", trust: "
|
|
|
259
283
|
}
|
|
260
284
|
catch (e) {
|
|
261
285
|
// a format v1 bundle (the laptop signer's): the reference verifier checks it, against the signer.pub the sender pins
|
|
262
|
-
|
|
286
|
+
const why = e instanceof BadZipFile ? `the bundle file is damaged: ${e.message}`
|
|
287
|
+
: e instanceof Unusable ? e.message : errorText(e);
|
|
288
|
+
rep.check("bundle readable", false, `cannot read bundle: ${why}`, v1 ? ["a format v1 bundle: verify it with "
|
|
263
289
|
+ `the signer's public key (signer.pub, from the sender): uvx --from tracekit-ai tracekit verify ${quote(names.bundle)}`
|
|
264
290
|
+ " --key signer.pub"] : []);
|
|
265
291
|
return { report: rep, code: EXIT_BAD };
|
|
@@ -329,8 +355,10 @@ async function check(rep, manifest, files, trust, floats) {
|
|
|
329
355
|
return;
|
|
330
356
|
}
|
|
331
357
|
const { origin, size, root, cosigs } = note;
|
|
332
|
-
|
|
333
|
-
|
|
358
|
+
const sized = same(size, at(proofs, "tree_size"));
|
|
359
|
+
rep.check("checkpoint", sized, `${origin} at tree size ${size}, `
|
|
360
|
+
+ (anchored ? "signed by its pinned log key" : "its signature not checked (no trust config)")
|
|
361
|
+
+ (sized ? "" : ", but the proofs are for another tree size"));
|
|
334
362
|
if (note.unchecked)
|
|
335
363
|
rep.unsupport("SLH-DSA-SHA2-128s checkpoint signature");
|
|
336
364
|
if (anchored)
|
|
@@ -446,8 +474,8 @@ async function check(rep, manifest, files, trust, floats) {
|
|
|
446
474
|
extend(keyProblems, retired.filter(([seq, h]) => !keyed.has(`${seq} ${h}`))
|
|
447
475
|
.map(([seq]) => `seq ${seq}: key.retire withheld (the registry log has it)`));
|
|
448
476
|
}
|
|
449
|
-
rep.check("keys", timeline.size > 0 && !keyProblems.length,
|
|
450
|
-
+
|
|
477
|
+
rep.check("keys", timeline.size > 0 && !keyProblems.length, found(keyProblems, timeline.size ? `${timeline.size} record `
|
|
478
|
+
+ `key(s) from ${keyRecords.length} key record(s)` : "no key record declares a record key", `${keyRecords.length} key record(s)`), keyProblems);
|
|
451
479
|
const every = [...runs.values()].flat();
|
|
452
480
|
const seqs = [...keyRecords, ...every].map((r) => num(at(at(r, "event"), "seq")));
|
|
453
481
|
if (!seqs.length)
|
|
@@ -462,19 +490,19 @@ async function check(rep, manifest, files, trust, floats) {
|
|
|
462
490
|
+ "its signer.pub to the reference verifier to check the format bridge");
|
|
463
491
|
const inParts = [...names].filter(([n, ps]) => !(ps.length === 1 && ps[0] === n)).map(([, ps]) => ps.length);
|
|
464
492
|
if (inParts.length)
|
|
465
|
-
rep.check("run parts", !layout.length, `${inParts.length} run(s) in ${inParts.reduce((a, b) => a + b, 0)}
|
|
466
|
-
+ "each part continuing the one before it", layout);
|
|
467
|
-
rep.check("signatures", !problems.length, `${every.length} record(s), keys valid at their position`, problems);
|
|
493
|
+
rep.check("run parts", !layout.length, found(layout, `${inParts.length} run(s) in ${inParts.reduce((a, b) => a + b, 0)} `
|
|
494
|
+
+ "parts, each part continuing the one before it", `the parts of ${inParts.length} run(s)`), layout);
|
|
495
|
+
rep.check("signatures", !problems.length, found(problems, `${every.length} record(s), keys valid at their position`, `${every.length} record(s)`), problems);
|
|
468
496
|
const only = runs.size === 1 ? [...runs.values()][0][0].event : null;
|
|
469
|
-
rep.check("run chain", !chain.length, only ? `run ${repr(cut(str(get(only, "run_id")), 200))} of tenant `
|
|
470
|
-
+ `${repr(get(only, "tenant"))}, contiguous from run_seq 0` : `${runs.size} run(s), each contiguous from run_seq 0`, chain);
|
|
471
|
-
rep.check("inclusion", !outside.length, `first and last records of ${runs.size} run(s) are in the
|
|
472
|
-
+ `size ${size}`, outside);
|
|
497
|
+
rep.check("run chain", !chain.length, found(chain, only ? `run ${repr(cut(str(get(only, "run_id")), 200))} of tenant `
|
|
498
|
+
+ `${repr(get(only, "tenant"))}, contiguous from run_seq 0` : `${runs.size} run(s), each contiguous from run_seq 0`, `the chain of ${runs.size} run(s)`), chain);
|
|
499
|
+
rep.check("inclusion", !outside.length, found(outside, `first and last records of ${runs.size} run(s) are in the `
|
|
500
|
+
+ `checkpointed tree of size ${size}`, `the first and last records of ${runs.size} run(s)`), outside);
|
|
473
501
|
// policy_hash -> the bundled snapshot named by it: the one set checkIncidents and approvals check against
|
|
474
502
|
const policies = new Map();
|
|
475
503
|
for (const p of [...files.keys()].filter((n) => n.startsWith("policies/")).sort()) {
|
|
476
504
|
const hex = await sha256hex(file(p));
|
|
477
|
-
rep.check("policy snapshot", p === `policies/${hex}.json`, p);
|
|
505
|
+
rep.check("policy snapshot", p === `policies/${hex}.json`, p === `policies/${hex}.json` ? p : `${p} is not named by the SHA-256 of its bytes`);
|
|
478
506
|
if (p === `policies/${hex}.json`)
|
|
479
507
|
policies.set(`sha256:${hex}`, file(p));
|
|
480
508
|
}
|
|
@@ -783,9 +811,9 @@ function approvals(rep, runs, policies, floats) {
|
|
|
783
811
|
if (!agents)
|
|
784
812
|
return; // a bundle without agent approvals keeps the report it always had
|
|
785
813
|
rep.check("approvals by people", true, `${people} approval(s) answered by people`);
|
|
786
|
-
rep.check("approvals by agents", !problems.length && !unchecked.length, `${agents} approval(s) answered
|
|
787
|
-
+ "output); argument bounds are not checkable offline (salted commitments): audit one with
|
|
788
|
-
+ (unchecked.length ? `; agent approval bounds unchecked for ${unchecked.length}` : ""), (problems.length ? problems : unchecked).slice(0, 20), !problems.length);
|
|
814
|
+
rep.check("approvals by agents", !problems.length && !unchecked.length, found(problems, `${agents} approval(s) answered `
|
|
815
|
+
+ "by agents (model output); argument bounds are not checkable offline (salted commitments): audit one with "
|
|
816
|
+
+ "`tracekit signer reveal`" + (unchecked.length ? `; agent approval bounds unchecked for ${unchecked.length}` : ""), `${agents} approval(s) answered by agents`), (problems.length ? problems : unchecked).slice(0, 20), !problems.length);
|
|
789
817
|
}
|
|
790
818
|
const CONTAINMENT = ["incident.opened", "incident.updated", "run.held", "run.quarantined", "run.resumed"];
|
|
791
819
|
const FIRES = ["policy.decision", "approval.consumed", "capture.gap", "trace.tamper", "refusal.summary",
|
|
@@ -886,8 +914,8 @@ function checkReviews(rep, runs, pinned) {
|
|
|
886
914
|
extend(labels, Array(signed.length).fill(label));
|
|
887
915
|
}
|
|
888
916
|
if (total) {
|
|
889
|
-
|
|
890
|
-
|
|
917
|
+
const said = `${total} review(s): ` + count(labels).map(([k, n]) => `${n} ${k}`).join(", ");
|
|
918
|
+
rep.check("reviews", !problems.length && !selfs.length, found(problems, said, said), (problems.length ? problems : selfs).slice(0, 20), !problems.length);
|
|
891
919
|
const verdicts = [...runs.values()].flatMap((rs) => rs.map((r) => r.event)) // signed findings only
|
|
892
920
|
.filter((e) => get(e, "type") === "review" && has(at(e, "data"), "cites")).map((e) => get(e.data, "verdict"));
|
|
893
921
|
const sev = count(verdicts.filter((v) => isObj(v) && get(v, "kind") === "finding")
|
|
@@ -925,7 +953,8 @@ function checkConstraints(rep, runs) {
|
|
|
925
953
|
}
|
|
926
954
|
}
|
|
927
955
|
if (added || held)
|
|
928
|
-
rep.check("constraints", !problems.length, `${added} live constraint(s) added; ${held} call(s) held
|
|
956
|
+
rep.check("constraints", !problems.length, found(problems, `${added} live constraint(s) added; ${held} call(s) held `
|
|
957
|
+
+ "by them", "the calls held by live constraints"), problems.slice(0, 20));
|
|
929
958
|
}
|
|
930
959
|
/** The `incidents` line, as verify/v2.py's _incidents: cited records, incidents recomputed from their run under the
|
|
931
960
|
* bundled compiled policy (`policies`, by policy_hash), responses honoured. */
|
|
@@ -998,8 +1027,8 @@ function checkIncidents(rep, runs, policies, floats) {
|
|
|
998
1027
|
extend(problems, honoured(events, pointers));
|
|
999
1028
|
}
|
|
1000
1029
|
const n = opened.size + [...pointers].filter((p) => !opened.has(p)).length;
|
|
1001
|
-
rep.check("incidents", !problems.length, `${n} incident(s): ${checked} checked against the bundle,
|
|
1002
|
-
+
|
|
1030
|
+
rep.check("incidents", !problems.length, found(problems, `${n} incident(s): ${checked} checked against the bundle, `
|
|
1031
|
+
+ `${n - checked} signer-asserted (operator, cross-run, under several policies, or under a policy not in the bundle)`, `${n} incident(s)`), problems.slice(0, 20));
|
|
1003
1032
|
if (unbundled.size)
|
|
1004
1033
|
rep.check("incident policies", false, `${unbundled.size} cited policy(ies) not in the bundle: their incidents are `
|
|
1005
1034
|
+ "signer-asserted, not recomputed (export the run with the signer's config, which bundles the policies its "
|
|
@@ -1284,6 +1313,8 @@ async function assurance(origin, cosigs, witnesses, trust, algs, selfApproved, r
|
|
|
1284
1313
|
/** `x` without control characters and the bidirectional and zero-width format characters that would reorder or hide
|
|
1285
1314
|
* the text around them, as the report prints bundle-derived strings. */
|
|
1286
1315
|
export const clean = (x) => x.replace(/[\x00-\x1f\x7f-\x9f\u061c\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff]/g, "");
|
|
1316
|
+
/** The Assurance line as the reports print it: an assurance level rates only evidence that verified. */
|
|
1317
|
+
export const assuranceLine = (rep) => `Assurance: ${rep.integrity === "FAILED" ? "not rated (the bundle failed verification)" : clean(rep.assurance)}.`;
|
|
1287
1318
|
/** The report as text, as the reference CLI prints it; `clean` drops characters from bundle-derived strings. */
|
|
1288
1319
|
export function formatReport(rep) {
|
|
1289
1320
|
let s = "";
|
|
@@ -1292,6 +1323,6 @@ export function formatReport(rep) {
|
|
|
1292
1323
|
for (const p of c.problems)
|
|
1293
1324
|
s += ` ${clean(p)}\n`;
|
|
1294
1325
|
}
|
|
1295
|
-
return s + `\nIntegrity: ${clean(rep.integrity)}.\
|
|
1326
|
+
return s + `\nIntegrity: ${clean(rep.integrity)}.\n${assuranceLine(rep)}\n`
|
|
1296
1327
|
+ (rep.findings ? `Findings: ${clean(rep.findings)}.\n` : "");
|
|
1297
1328
|
}
|
|
@@ -37,6 +37,9 @@ export type VKey = {
|
|
|
37
37
|
};
|
|
38
38
|
/** (name, key id, type, public key) of a vkey `name+hex id+base64(type ‖ key)`. */
|
|
39
39
|
export declare function parseVkey(text: string): Promise<VKey>;
|
|
40
|
+
/** A cosignature signs no key name and a witness has one key (C2SP tlog-cosignature): refuse pins of one cosignature
|
|
41
|
+
* key under two names, or of two under one name, so each witness counts once. */
|
|
42
|
+
export declare function checkWitnesses(keys: string[]): Promise<void>;
|
|
40
43
|
export type Note = {
|
|
41
44
|
origin: string;
|
|
42
45
|
size: number;
|
|
@@ -191,6 +191,25 @@ export async function parseVkey(text) {
|
|
|
191
191
|
throw new NoteError("vkey id does not match the key");
|
|
192
192
|
return { name, id, type: raw[0], pub: raw.subarray(1) };
|
|
193
193
|
}
|
|
194
|
+
/** A cosignature signs no key name and a witness has one key (C2SP tlog-cosignature): refuse pins of one cosignature
|
|
195
|
+
* key under two names, or of two under one name, so each witness counts once. */
|
|
196
|
+
export async function checkWitnesses(keys) {
|
|
197
|
+
const names = new Map(), pubs = new Map();
|
|
198
|
+
for (const k of keys) {
|
|
199
|
+
const p = await parseVkey(k);
|
|
200
|
+
if (p.type !== COSIGNATURE)
|
|
201
|
+
continue;
|
|
202
|
+
const pub = hex(p.pub), name = names.get(pub) ?? p.name, other = pubs.get(p.name) ?? pub;
|
|
203
|
+
if (name !== p.name)
|
|
204
|
+
throw new NoteError(`trust pins one witness key under two names (${name}, ${p.name}); a key is one witness: `
|
|
205
|
+
+ "keep it under the name it cosigns with");
|
|
206
|
+
if (other !== pub)
|
|
207
|
+
throw new NoteError(`trust pins two witness keys under one name (${p.name}); a name is one witness: keep only `
|
|
208
|
+
+ "its current key");
|
|
209
|
+
names.set(pub, name);
|
|
210
|
+
pubs.set(p.name, pub);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
194
213
|
/**
|
|
195
214
|
* Open a checkpoint note with pinned vkeys: a pinned Ed25519 log key named after the origin must sign it, and each
|
|
196
215
|
* pinned hybrid key of the origin must have a line. Web Crypto has no SLH-DSA, so a hybrid line is left `unchecked`.
|
|
@@ -230,6 +249,7 @@ export async function openNote(data, logKeys, witnessKeys, anchored = true) {
|
|
|
230
249
|
}
|
|
231
250
|
if (root.length !== 32)
|
|
232
251
|
throw new NoteError("bad root hash");
|
|
252
|
+
await checkWitnesses(witnessKeys);
|
|
233
253
|
const pinned = new Map();
|
|
234
254
|
for (const [keys, want] of [[logKeys, [ED25519, HYBRID]], [witnessKeys, [COSIGNATURE]]])
|
|
235
255
|
for (const k of keys) {
|