@memnexus-ai/mx-agent-cli 0.1.239 → 0.1.241
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/__tests__/isolation-probe.test.d.ts +15 -0
- package/dist/__tests__/isolation-probe.test.d.ts.map +1 -0
- package/dist/__tests__/isolation-probe.test.js +611 -0
- package/dist/__tests__/isolation-probe.test.js.map +1 -0
- package/dist/agent-config/hooks/named-memory-write-guard.sh +5 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +17 -7
- package/dist/commands/start.js.map +1 -1
- package/dist/lib/isolation-probe.d.ts +187 -0
- package/dist/lib/isolation-probe.d.ts.map +1 -0
- package/dist/lib/isolation-probe.js +628 -0
- package/dist/lib/isolation-probe.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* isolation-probe.ts — probes behind the `mx-agent start` isolation banner (#4646).
|
|
3
|
+
*
|
|
4
|
+
* PROBLEM (FL-2, false-green). The banner printed three green checkmarks as
|
|
5
|
+
* unconditional `console.log` string literals:
|
|
6
|
+
*
|
|
7
|
+
* ✓ Directory restricted to worktree
|
|
8
|
+
* ✓ git checkout/switch to main blocked
|
|
9
|
+
* ✓ git push origin main blocked
|
|
10
|
+
*
|
|
11
|
+
* The checkmark was a character inside a template string. Nothing was verified,
|
|
12
|
+
* so the banner asserted three protections directly to the operator whether or
|
|
13
|
+
* not any of them was in place — including on a worktree whose hooks had been
|
|
14
|
+
* lost (exactly the #4428 state) or whose deny list had been edited away. A
|
|
15
|
+
* false green is worse than a silent gap: it actively tells the operator not to
|
|
16
|
+
* look.
|
|
17
|
+
*
|
|
18
|
+
* WHAT EACH LINE ACTUALLY DEPENDS ON. Both mechanisms must hold, so both are
|
|
19
|
+
* probed:
|
|
20
|
+
* - `.claude/settings.json` permissions.deny entries, which Claude Code
|
|
21
|
+
* enforces BEFORE any hook runs (`Bash(git checkout main)`, `Bash(git push
|
|
22
|
+
* origin main)`, ...);
|
|
23
|
+
* - `.claude/hooks/worktree-guard.sh`, which catches the shapes a literal deny
|
|
24
|
+
* pattern misses (separators, wrappers, `git -C <other-worktree>`).
|
|
25
|
+
*
|
|
26
|
+
* PROBE, DON'T ASSUME (FL-9). Presence on disk plus registration is not
|
|
27
|
+
* verification: a stale-but-present guard passes an existence check while
|
|
28
|
+
* behaving like an older, weaker build (KI-EXISTENCE-CHECK-CANNOT-SEE-A-BROKEN-
|
|
29
|
+
* CONTROL, KI-VERIFY-BY-PROBE-NOT-BY-HAVING-RUN-SOMETHING). So the deployed
|
|
30
|
+
* guard's sha256 is compared against an anchor.
|
|
31
|
+
*
|
|
32
|
+
* WHICH ANCHOR IS THE WHOLE SECURITY PROPERTY. Whoever chooses the anchor
|
|
33
|
+
* decides the verdict, so the anchor must be chosen by something outside the
|
|
34
|
+
* write surface being measured. The shipped model, in order:
|
|
35
|
+
*
|
|
36
|
+
* 1. The npm-installed CLI bundle, and only when it resolves outside BOTH the
|
|
37
|
+
* worktree and the project root. Deployed === bundled → `pass`.
|
|
38
|
+
* `MX_BUNDLED_CONFIG_DIR` is deliberately NOT honoured here: an
|
|
39
|
+
* env-designated directory is attacker-designated in this fleet (`.envrc`,
|
|
40
|
+
* `.devcontainer/post-start.sh` are repo files), so it is a test seam, not
|
|
41
|
+
* an anchor. Tests inject `resolveBundledDir` instead.
|
|
42
|
+
* 2. Otherwise the in-repo sources are consulted, and agreement between them
|
|
43
|
+
* and the deployed guard yields `unknown`, not `pass` — an anchor inside the
|
|
44
|
+
* set it measures cannot distinguish "current" from "coordinated edit of
|
|
45
|
+
* both copies". A source-tree checkout therefore reads `?`, labelled
|
|
46
|
+
* "source may be ahead of the published build".
|
|
47
|
+
* 3. In-repo copies disagreeing with each other, a symlinked or non-regular
|
|
48
|
+
* deployed guard, or no readable source at all → `unknown`.
|
|
49
|
+
*
|
|
50
|
+
* THREE STATES, ALWAYS DISTINCT (FL-1). `pass` / `fail` / `unknown`. A probe
|
|
51
|
+
* that could not run returns `unknown` and renders `?` — never `✓`. No probe, no
|
|
52
|
+
* checkmark.
|
|
53
|
+
*
|
|
54
|
+
* UNTRUSTED REASON TEXT (CWE-150). Some reasons quote `.claude/settings.json`
|
|
55
|
+
* hook-command content, which is agent-editable. Every reason passes through
|
|
56
|
+
* `sanitizeReason` before printing, which strips control sequences and status
|
|
57
|
+
* glyphs and caps the length — otherwise a crafted command can erase a printed
|
|
58
|
+
* `✗` and paint a `✓` over it.
|
|
59
|
+
*
|
|
60
|
+
* ADVISORY, NOT BLOCKING (FL-10, reversible-harm row). None of these probes can
|
|
61
|
+
* abort startup. A failure is loud — `✗` on stdout plus a line on stderr — but
|
|
62
|
+
* the session still launches, because refusing to start on a banner failure
|
|
63
|
+
* would make the banner the most fragile part of the tool and get it removed.
|
|
64
|
+
*
|
|
65
|
+
* BUDGET, ENFORCED NOT ASSUMED. A 100ms ceiling is checked against a clock
|
|
66
|
+
* seeded in `probeIsolation`; a probe starting past it returns `unknown` rather
|
|
67
|
+
* than doing more filesystem work, and every read is size-capped at 1 MB. The
|
|
68
|
+
* ceiling bounds this block's own work — it cannot interrupt a syscall already
|
|
69
|
+
* stalled (see the note on `budgetExceeded`). Typical cost is a few ms.
|
|
70
|
+
*/
|
|
71
|
+
import { existsSync, readFileSync, statSync, lstatSync, realpathSync } from 'fs';
|
|
72
|
+
import { isAbsolute, join, normalize, resolve, sep } from 'path';
|
|
73
|
+
import { spawnSync } from 'child_process';
|
|
74
|
+
import chalk from 'chalk';
|
|
75
|
+
import { checkHookCompleteness } from './hook-completeness.js';
|
|
76
|
+
import { hashFile, getBundledConfigDir } from './bundled-config.js';
|
|
77
|
+
import { stripAnsi } from './startup-report.js';
|
|
78
|
+
const DEFAULT_CONFIG_SOURCE = 'mx-agent-system/agent-config';
|
|
79
|
+
/** The guard whose absence or staleness invalidates all three banner claims. */
|
|
80
|
+
const WORKTREE_GUARD = 'worktree-guard.sh';
|
|
81
|
+
/**
|
|
82
|
+
* Deny patterns each claim depends on. Matched as exact strings against
|
|
83
|
+
* permissions.deny; a claim needs EVERY pattern in its group, because each
|
|
84
|
+
* covers a distinct invocation shape and one missing entry is a real hole.
|
|
85
|
+
*/
|
|
86
|
+
const CHECKOUT_MAIN_DENIES = [
|
|
87
|
+
'Bash(git checkout main)',
|
|
88
|
+
'Bash(git checkout main *)',
|
|
89
|
+
'Bash(git switch main)',
|
|
90
|
+
'Bash(git switch main *)',
|
|
91
|
+
];
|
|
92
|
+
const PUSH_MAIN_DENIES = [
|
|
93
|
+
'Bash(git push origin main)',
|
|
94
|
+
'Bash(git push origin main *)',
|
|
95
|
+
'Bash(git push -u origin main)',
|
|
96
|
+
'Bash(git push -u origin main *)',
|
|
97
|
+
];
|
|
98
|
+
/**
|
|
99
|
+
* Largest file this module will read or hash. Bounds the probe's cost on a
|
|
100
|
+
* hostile or accidentally-huge input: settings.json and a guard script are a few
|
|
101
|
+
* KB, so 1 MB is generous. Over the cap → `unknown`, never a silent skip.
|
|
102
|
+
*/
|
|
103
|
+
const MAX_READ_BYTES = 1024 * 1024;
|
|
104
|
+
/** Whole-block wall-clock budget. Past it, remaining probes report `unknown`. */
|
|
105
|
+
const BUDGET_MS = 100;
|
|
106
|
+
// ── Shared, never-throwing primitives ────────────────────────────────────────
|
|
107
|
+
/** Separator-terminated containment test, so `/a/bc` is not "inside" `/a/b`. */
|
|
108
|
+
function isWithin(parent, child) {
|
|
109
|
+
if (child === parent)
|
|
110
|
+
return true;
|
|
111
|
+
const prefix = parent.endsWith(sep) ? parent : parent + sep;
|
|
112
|
+
return child.startsWith(prefix);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Sanitize `configSource` before it is joined into any path (CWE-22).
|
|
116
|
+
*
|
|
117
|
+
* It arrives from `mx-agent.config.json`, which is a checked-in, agent-editable
|
|
118
|
+
* file — a `typeof === 'string'` check upstream is not a trust boundary. A value
|
|
119
|
+
* like `../../../attacker-controlled` relocates the freshness anchor outside the
|
|
120
|
+
* repo entirely, and an anchor the attacker also controls turns the hash
|
|
121
|
+
* comparison into a rubber stamp: point it at a directory holding a copy of an
|
|
122
|
+
* `exit 0` guard and the banner reports three green checks (CWE-807, reliance on
|
|
123
|
+
* untrusted input in a security decision).
|
|
124
|
+
*
|
|
125
|
+
* Rejects absolute paths and any traversal segment, falling back to the default
|
|
126
|
+
* rather than failing the probe: a malformed config should not make the banner
|
|
127
|
+
* unreadable, it should make it use the known-good relative path.
|
|
128
|
+
*/
|
|
129
|
+
export function safeConfigSource(raw) {
|
|
130
|
+
if (typeof raw !== 'string' || raw.trim() === '')
|
|
131
|
+
return DEFAULT_CONFIG_SOURCE;
|
|
132
|
+
const value = raw.trim();
|
|
133
|
+
if (isAbsolute(value))
|
|
134
|
+
return DEFAULT_CONFIG_SOURCE;
|
|
135
|
+
// Normalize first so `a/../../b` and `a/./../..` are both caught.
|
|
136
|
+
const norm = normalize(value).split('\\').join('/');
|
|
137
|
+
if (norm === '..' || norm.startsWith('../') || norm.includes('/../') || norm.endsWith('/..')) {
|
|
138
|
+
return DEFAULT_CONFIG_SOURCE;
|
|
139
|
+
}
|
|
140
|
+
return norm;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolve `<base>/<configSource>` and assert it stays inside `base`. Returns
|
|
144
|
+
* null when it escapes — belt to safeConfigSource's braces, because a symlinked
|
|
145
|
+
* intermediate directory can escape a path that is textually clean.
|
|
146
|
+
*/
|
|
147
|
+
function containedSource(base, configSource) {
|
|
148
|
+
const candidate = resolve(base, configSource);
|
|
149
|
+
let realBase;
|
|
150
|
+
let realCandidate;
|
|
151
|
+
try {
|
|
152
|
+
realBase = realpathSync(base);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
realCandidate = realpathSync(candidate);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// Not yet existing is fine — judge the textual path in that case.
|
|
162
|
+
return isWithin(realBase, resolve(candidate)) ? candidate : null;
|
|
163
|
+
}
|
|
164
|
+
return isWithin(realBase, realCandidate) ? realCandidate : null;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Wall-clock budget check. Returns an `unknown` result once the block has spent
|
|
168
|
+
* its budget, so a slow filesystem degrades the banner to `?` instead of
|
|
169
|
+
* delaying session start.
|
|
170
|
+
*
|
|
171
|
+
* Scope note: this bounds THIS block's own work. It does not make the probes
|
|
172
|
+
* non-blocking — a probe already inside a stalled syscall (a hung NFS mount, or
|
|
173
|
+
* the leader-lock path holding a lock while the filesystem is wedged) still
|
|
174
|
+
* blocks until that syscall returns, because nothing here can interrupt it.
|
|
175
|
+
* Moving the whole block off the critical path is the real fix and is out of
|
|
176
|
+
* scope for this change; the cap plus the 1 MB read limit bound the common cases.
|
|
177
|
+
*/
|
|
178
|
+
function budgetExceeded(input) {
|
|
179
|
+
const t0 = input.budgetStartedAt;
|
|
180
|
+
if (typeof t0 !== 'number')
|
|
181
|
+
return null;
|
|
182
|
+
if (Date.now() - t0 <= BUDGET_MS)
|
|
183
|
+
return null;
|
|
184
|
+
return { state: 'unknown', reason: `isolation probe exceeded its ${BUDGET_MS}ms budget` };
|
|
185
|
+
}
|
|
186
|
+
/** statSync size, or null when unavailable. */
|
|
187
|
+
function fileSize(path) {
|
|
188
|
+
try {
|
|
189
|
+
return statSync(path).size;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/** Read permissions.deny from the worktree's live settings.json. */
|
|
196
|
+
function readDenyList(worktreePath) {
|
|
197
|
+
const p = join(worktreePath, '.claude', 'settings.json');
|
|
198
|
+
if (!existsSync(p))
|
|
199
|
+
return { error: '.claude/settings.json is absent' };
|
|
200
|
+
const size = fileSize(p);
|
|
201
|
+
if (size === null)
|
|
202
|
+
return { error: '.claude/settings.json could not be stat-ed' };
|
|
203
|
+
if (size > MAX_READ_BYTES) {
|
|
204
|
+
return { error: `.claude/settings.json is ${size} bytes (over the ${MAX_READ_BYTES}-byte probe cap)` };
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const parsed = JSON.parse(readFileSync(p, 'utf-8'));
|
|
208
|
+
const deny = parsed?.permissions?.deny;
|
|
209
|
+
if (!Array.isArray(deny))
|
|
210
|
+
return { error: '.claude/settings.json has no permissions.deny array' };
|
|
211
|
+
return { deny: deny.filter((d) => typeof d === 'string') };
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return { error: '.claude/settings.json is not valid JSON' };
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Health of the worktree-guard hook: registered, present, and byte-identical to
|
|
219
|
+
* its agent-config source. Returns null when healthy, else a one-line reason.
|
|
220
|
+
* `unknown` is signalled separately because a missing SOURCE means we cannot
|
|
221
|
+
* judge freshness, which is not the same as the guard being stale.
|
|
222
|
+
*/
|
|
223
|
+
function probeWorktreeGuard(projectRoot, worktreePath, configSource, resolveBundled) {
|
|
224
|
+
const completeness = checkHookCompleteness(worktreePath, { configSource });
|
|
225
|
+
if (completeness.missing.includes('settings.json')) {
|
|
226
|
+
return { ok: false, reason: '.claude/settings.json is absent or unreadable — hooks cannot be verified', unknown: true };
|
|
227
|
+
}
|
|
228
|
+
if (completeness.missing.some((m) => m.endsWith(WORKTREE_GUARD))) {
|
|
229
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is registered but MISSING on disk (hook fails open)` };
|
|
230
|
+
}
|
|
231
|
+
if (completeness.unregistered.includes(WORKTREE_GUARD)) {
|
|
232
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is not registered in settings.json` };
|
|
233
|
+
}
|
|
234
|
+
if (completeness.unresolved.length > 0) {
|
|
235
|
+
return { ok: false, reason: `a hook registration is unresolvable: ${completeness.unresolved[0]}`, unknown: true };
|
|
236
|
+
}
|
|
237
|
+
// ── Freshness ──────────────────────────────────────────────────────────────
|
|
238
|
+
// A present-but-stale guard passes an existence check while behaving like an
|
|
239
|
+
// older, weaker build (FL-9). So the deployed bytes are hashed against an
|
|
240
|
+
// anchor — and the anchor choice is the whole security property here.
|
|
241
|
+
//
|
|
242
|
+
// THE ANCHOR MUST NOT LIVE INSIDE THE SET IT MEASURES. Hashing the deployed
|
|
243
|
+
// guard against a source in the same worktree compares two files an attacker
|
|
244
|
+
// who can write one can usually write both: neuter the guard, copy it over the
|
|
245
|
+
// source, and the check becomes hash(x) === hash(x) — a green tick that proves
|
|
246
|
+
// only that a file equals itself.
|
|
247
|
+
//
|
|
248
|
+
// Order:
|
|
249
|
+
// 1. PRIMARY: the npm-installed CLI bundle (getBundledConfigDir). It sits
|
|
250
|
+
// outside the worktree AND outside the repo, and its contents are chosen
|
|
251
|
+
// by the publish pipeline rather than by anything in the working tree.
|
|
252
|
+
// Deployed === bundled → pass.
|
|
253
|
+
// 2. Bundled present but different: consult the in-repo sources. If they
|
|
254
|
+
// agree with the deployed guard, this is the legitimate dev-ahead case
|
|
255
|
+
// (source newer than the published build) → `unknown`, labelled honestly.
|
|
256
|
+
// Not a pass: we cannot tell "ahead" from "tampered" by hash alone.
|
|
257
|
+
// 3. In-repo sources disagree with each other → `unknown`: there is no
|
|
258
|
+
// single answer to compare against.
|
|
259
|
+
// 4. No usable independent anchor → `unknown`, never pass.
|
|
260
|
+
const deployed = join(worktreePath, '.claude', 'hooks', WORKTREE_GUARD);
|
|
261
|
+
// lstat, not stat: a symlinked "deployed" guard is how the self-reference gets
|
|
262
|
+
// reintroduced after the anchor fix — point .claude/hooks/x.sh at the anchor
|
|
263
|
+
// and every hash matches trivially. Only a regular file is measurable.
|
|
264
|
+
let st;
|
|
265
|
+
try {
|
|
266
|
+
st = lstatSync(deployed);
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is absent from .claude/hooks/` };
|
|
270
|
+
}
|
|
271
|
+
if (st.isSymbolicLink()) {
|
|
272
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is a SYMLINK, not a regular file — its bytes cannot be attributed`, unknown: true };
|
|
273
|
+
}
|
|
274
|
+
if (!st.isFile()) {
|
|
275
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is not a regular file — freshness cannot be established`, unknown: true };
|
|
276
|
+
}
|
|
277
|
+
if (st.size > MAX_READ_BYTES) {
|
|
278
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is ${st.size} bytes (over the ${MAX_READ_BYTES}-byte probe cap)`, unknown: true };
|
|
279
|
+
}
|
|
280
|
+
const deployedHash = hashFile(deployed);
|
|
281
|
+
if (!deployedHash) {
|
|
282
|
+
return { ok: false, reason: `${WORKTREE_GUARD} could not be hashed for a freshness check`, unknown: true };
|
|
283
|
+
}
|
|
284
|
+
// Candidate anchors. The bundled dir is only independent when it is genuinely
|
|
285
|
+
// outside both the worktree and the repo; a source-tree run resolves it back
|
|
286
|
+
// into the repo, which is not an anchor at all.
|
|
287
|
+
//
|
|
288
|
+
// AND it must not be ENV-DESIGNATED. getBundledConfigDir() honours
|
|
289
|
+
// MX_BUNDLED_CONFIG_DIR unconditionally, and an env-designated directory
|
|
290
|
+
// passes the outside-worktree-and-root test trivially — point it at /tmp with a
|
|
291
|
+
// neutered copy and the deployed guard "matches its anchor". That is the same
|
|
292
|
+
// defect as the traversing configSource: whoever chooses the anchor decides the
|
|
293
|
+
// verdict. In this fleet the environment is inside the plausible write surface
|
|
294
|
+
// (.envrc and .devcontainer/post-start.sh are repo files), so an env override is
|
|
295
|
+
// a TEST SEAM, not an independent anchor. When it is set we fall through to the
|
|
296
|
+
// in-repo comparison and its honest `unknown` reasons; the production path never
|
|
297
|
+
// reads the env var. Tests inject `resolveBundledDir` instead.
|
|
298
|
+
const bundleIsOverridden = typeof process.env.MX_BUNDLED_CONFIG_DIR === 'string'
|
|
299
|
+
&& process.env.MX_BUNDLED_CONFIG_DIR.trim() !== '';
|
|
300
|
+
const bundledDir = resolveBundled
|
|
301
|
+
? resolveBundled()
|
|
302
|
+
: (bundleIsOverridden ? null : getBundledConfigDir());
|
|
303
|
+
let bundledHash = null;
|
|
304
|
+
if (bundledDir) {
|
|
305
|
+
let realBundled = null;
|
|
306
|
+
try {
|
|
307
|
+
realBundled = realpathSync(bundledDir);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
realBundled = null;
|
|
311
|
+
}
|
|
312
|
+
let realWorktree = null;
|
|
313
|
+
let realRoot = null;
|
|
314
|
+
try {
|
|
315
|
+
realWorktree = realpathSync(worktreePath);
|
|
316
|
+
}
|
|
317
|
+
catch { /* leave null */ }
|
|
318
|
+
try {
|
|
319
|
+
realRoot = realpathSync(projectRoot);
|
|
320
|
+
}
|
|
321
|
+
catch { /* leave null */ }
|
|
322
|
+
const independent = realBundled !== null &&
|
|
323
|
+
!(realWorktree !== null && isWithin(realWorktree, realBundled)) &&
|
|
324
|
+
!(realRoot !== null && isWithin(realRoot, realBundled));
|
|
325
|
+
if (independent) {
|
|
326
|
+
const p = join(realBundled, 'hooks', WORKTREE_GUARD);
|
|
327
|
+
const size = fileSize(p);
|
|
328
|
+
if (size !== null && size <= MAX_READ_BYTES)
|
|
329
|
+
bundledHash = hashFile(p);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (bundledHash && deployedHash === bundledHash) {
|
|
333
|
+
return { ok: true };
|
|
334
|
+
}
|
|
335
|
+
// In-repo sources, each containment-checked so a traversing configSource
|
|
336
|
+
// cannot move the comparison outside its base.
|
|
337
|
+
const wtSourceDir = containedSource(worktreePath, configSource);
|
|
338
|
+
const rootSourceDir = containedSource(projectRoot, configSource);
|
|
339
|
+
const hashIn = (dir) => {
|
|
340
|
+
if (!dir)
|
|
341
|
+
return null;
|
|
342
|
+
const p = join(dir, 'hooks', WORKTREE_GUARD);
|
|
343
|
+
const size = fileSize(p);
|
|
344
|
+
if (size === null || size > MAX_READ_BYTES)
|
|
345
|
+
return null;
|
|
346
|
+
return hashFile(p);
|
|
347
|
+
};
|
|
348
|
+
const wtHash = hashIn(wtSourceDir);
|
|
349
|
+
const rootHash = hashIn(rootSourceDir);
|
|
350
|
+
if (wtHash && rootHash && wtHash !== rootHash) {
|
|
351
|
+
return { ok: false, reason: `${WORKTREE_GUARD} freshness cannot be established — the worktree and project-root copies of ${configSource} disagree`, unknown: true };
|
|
352
|
+
}
|
|
353
|
+
const inRepoHash = wtHash ?? rootHash;
|
|
354
|
+
if (!inRepoHash) {
|
|
355
|
+
return { ok: false, reason: `cannot compare ${WORKTREE_GUARD} to any source (no CLI bundle and no readable ${configSource})`, unknown: true };
|
|
356
|
+
}
|
|
357
|
+
if (deployedHash !== inRepoHash) {
|
|
358
|
+
return { ok: false, reason: `${WORKTREE_GUARD} is STALE — deployed copy differs from ${configSource} (run mx-agent verify-hooks)` };
|
|
359
|
+
}
|
|
360
|
+
// Deployed matches its in-repo source. If we had an independent anchor and it
|
|
361
|
+
// disagreed, the working tree is ahead of the published build — plausible and
|
|
362
|
+
// common during development, but indistinguishable by hash from a coordinated
|
|
363
|
+
// edit of both deployed and source. Report it, do not bless it.
|
|
364
|
+
if (bundledHash) {
|
|
365
|
+
return { ok: false, reason: `${WORKTREE_GUARD} matches its in-repo source but not the shipped CLI bundle — source may be ahead of the published build`, unknown: true };
|
|
366
|
+
}
|
|
367
|
+
return { ok: false, reason: `${WORKTREE_GUARD} matches its in-repo source, but no independent CLI bundle was available to confirm it`, unknown: true };
|
|
368
|
+
}
|
|
369
|
+
/** Default branch reader: one cheap `git rev-parse`. Returns null on any failure. */
|
|
370
|
+
function gitCurrentBranch(worktreePath) {
|
|
371
|
+
try {
|
|
372
|
+
const r = spawnSync('git', ['-C', worktreePath, 'rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
373
|
+
encoding: 'utf-8',
|
|
374
|
+
timeout: 5000,
|
|
375
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
376
|
+
});
|
|
377
|
+
if (r.error || r.status !== 0)
|
|
378
|
+
return null;
|
|
379
|
+
const out = (r.stdout || '').trim();
|
|
380
|
+
return out.length > 0 ? out : null;
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/** Which of `required` are absent from `deny`. */
|
|
387
|
+
function missingDenies(deny, required) {
|
|
388
|
+
const have = new Set(deny);
|
|
389
|
+
return required.filter((r) => !have.has(r));
|
|
390
|
+
}
|
|
391
|
+
// ── Probe 1: directory containment ───────────────────────────────────────────
|
|
392
|
+
/**
|
|
393
|
+
* Claim: "Directory restricted to worktree".
|
|
394
|
+
*
|
|
395
|
+
* Two things must hold: the worktree really is a directory under the project
|
|
396
|
+
* root (so "the worktree" is a meaningful boundary), and worktree-guard.sh —
|
|
397
|
+
* which enforces the boundary at runtime — is registered, present and current.
|
|
398
|
+
* cwd is checked too: a session started from outside the worktree is not
|
|
399
|
+
* contained by it, whatever the guard says.
|
|
400
|
+
*/
|
|
401
|
+
export function probeContainment(input) {
|
|
402
|
+
const { projectRoot, worktreePath } = input;
|
|
403
|
+
const configSource = safeConfigSource(input.configSource);
|
|
404
|
+
const cwd = input.cwd ?? process.cwd();
|
|
405
|
+
const overBudget = budgetExceeded(input);
|
|
406
|
+
if (overBudget)
|
|
407
|
+
return overBudget;
|
|
408
|
+
let realWorktree;
|
|
409
|
+
let realRoot;
|
|
410
|
+
try {
|
|
411
|
+
if (!existsSync(worktreePath) || !statSync(worktreePath).isDirectory()) {
|
|
412
|
+
return { state: 'fail', reason: `worktree path is not a directory: ${worktreePath}` };
|
|
413
|
+
}
|
|
414
|
+
realWorktree = realpathSync(worktreePath);
|
|
415
|
+
realRoot = realpathSync(projectRoot);
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
return { state: 'unknown', reason: 'worktree or project path could not be resolved' };
|
|
419
|
+
}
|
|
420
|
+
// The worktree being the project root is not isolation — there is no boundary
|
|
421
|
+
// for the guard to enforce. Latent for `mx-agent start`, which always passes a
|
|
422
|
+
// real worktree, but this module is exported and reusable, so it is checked
|
|
423
|
+
// here rather than assumed at every future call site.
|
|
424
|
+
if (realWorktree === realRoot) {
|
|
425
|
+
return { state: 'fail', reason: 'worktree path is the project root — no worktree isolation' };
|
|
426
|
+
}
|
|
427
|
+
if (!isWithin(realRoot, realWorktree)) {
|
|
428
|
+
return { state: 'fail', reason: `worktree ${realWorktree} is not under project root ${realRoot}` };
|
|
429
|
+
}
|
|
430
|
+
let realCwd;
|
|
431
|
+
try {
|
|
432
|
+
realCwd = realpathSync(resolve(cwd));
|
|
433
|
+
}
|
|
434
|
+
catch {
|
|
435
|
+
return { state: 'unknown', reason: 'current directory could not be resolved' };
|
|
436
|
+
}
|
|
437
|
+
if (!isWithin(realWorktree, realCwd)) {
|
|
438
|
+
return { state: 'fail', reason: `current directory ${realCwd} is outside the worktree` };
|
|
439
|
+
}
|
|
440
|
+
const guard = probeWorktreeGuard(projectRoot, worktreePath, configSource, input.resolveBundledDir);
|
|
441
|
+
if (!guard.ok) {
|
|
442
|
+
return { state: guard.unknown ? 'unknown' : 'fail', reason: guard.reason };
|
|
443
|
+
}
|
|
444
|
+
return { state: 'pass' };
|
|
445
|
+
}
|
|
446
|
+
// ── Probe 2: branch pin ──────────────────────────────────────────────────────
|
|
447
|
+
/**
|
|
448
|
+
* Claim: "git checkout/switch to main blocked".
|
|
449
|
+
*
|
|
450
|
+
* Probed as: the worktree is on a branch that is neither the base branch nor a
|
|
451
|
+
* detached HEAD, AND the deny rules that stop a switch to main are present, AND
|
|
452
|
+
* the guard that catches the shapes those literal patterns miss is healthy.
|
|
453
|
+
*
|
|
454
|
+
* A worktree already sitting on main is the outcome this line exists to prevent,
|
|
455
|
+
* so it fails the line even when every rule is in place — the rules evidently did
|
|
456
|
+
* not hold, or were added after the switch.
|
|
457
|
+
*/
|
|
458
|
+
export function probeBranchPin(input) {
|
|
459
|
+
const { projectRoot, worktreePath, baseBranch } = input;
|
|
460
|
+
const configSource = safeConfigSource(input.configSource);
|
|
461
|
+
const read = input.readBranch ?? gitCurrentBranch;
|
|
462
|
+
const overBudget = budgetExceeded(input);
|
|
463
|
+
if (overBudget)
|
|
464
|
+
return overBudget;
|
|
465
|
+
const current = input.currentBranch !== undefined ? input.currentBranch : read(worktreePath);
|
|
466
|
+
if (current === null || current === '') {
|
|
467
|
+
return { state: 'unknown', reason: 'current branch could not be read (git rev-parse failed)' };
|
|
468
|
+
}
|
|
469
|
+
// `rev-parse --abbrev-ref HEAD` prints the literal 'HEAD' when detached: no
|
|
470
|
+
// branch is pinned, so the claim cannot be true.
|
|
471
|
+
if (current === 'HEAD') {
|
|
472
|
+
return { state: 'fail', reason: 'worktree is on a detached HEAD — no branch is pinned' };
|
|
473
|
+
}
|
|
474
|
+
if (!baseBranch) {
|
|
475
|
+
return { state: 'unknown', reason: 'no base branch is configured, so "not on main" cannot be checked' };
|
|
476
|
+
}
|
|
477
|
+
if (current === baseBranch) {
|
|
478
|
+
return { state: 'fail', reason: `worktree is ON the base branch '${baseBranch}' — it must sit on its own branch` };
|
|
479
|
+
}
|
|
480
|
+
const deny = readDenyList(worktreePath);
|
|
481
|
+
if ('error' in deny) {
|
|
482
|
+
return { state: 'unknown', reason: deny.error };
|
|
483
|
+
}
|
|
484
|
+
const gaps = missingDenies(deny.deny, CHECKOUT_MAIN_DENIES);
|
|
485
|
+
if (gaps.length > 0) {
|
|
486
|
+
return { state: 'fail', reason: `deny list is missing ${gaps.length} of ${CHECKOUT_MAIN_DENIES.length} switch-to-main rules (e.g. ${gaps[0]})` };
|
|
487
|
+
}
|
|
488
|
+
const guard = probeWorktreeGuard(projectRoot, worktreePath, configSource, input.resolveBundledDir);
|
|
489
|
+
if (!guard.ok) {
|
|
490
|
+
return { state: guard.unknown ? 'unknown' : 'fail', reason: guard.reason };
|
|
491
|
+
}
|
|
492
|
+
return { state: 'pass' };
|
|
493
|
+
}
|
|
494
|
+
// ── Probe 3: push-to-main block ──────────────────────────────────────────────
|
|
495
|
+
/**
|
|
496
|
+
* Claim: "git push origin main blocked".
|
|
497
|
+
*
|
|
498
|
+
* Probed as: every push-to-main deny rule is present, and worktree-guard.sh —
|
|
499
|
+
* which also refuses push-to-main in shapes the literal patterns miss — is
|
|
500
|
+
* healthy.
|
|
501
|
+
*/
|
|
502
|
+
export function probePushBlock(input) {
|
|
503
|
+
const { projectRoot, worktreePath } = input;
|
|
504
|
+
const configSource = safeConfigSource(input.configSource);
|
|
505
|
+
const overBudget = budgetExceeded(input);
|
|
506
|
+
if (overBudget)
|
|
507
|
+
return overBudget;
|
|
508
|
+
const deny = readDenyList(worktreePath);
|
|
509
|
+
if ('error' in deny) {
|
|
510
|
+
return { state: 'unknown', reason: deny.error };
|
|
511
|
+
}
|
|
512
|
+
const gaps = missingDenies(deny.deny, PUSH_MAIN_DENIES);
|
|
513
|
+
if (gaps.length > 0) {
|
|
514
|
+
return { state: 'fail', reason: `deny list is missing ${gaps.length} of ${PUSH_MAIN_DENIES.length} push-to-main rules (e.g. ${gaps[0]})` };
|
|
515
|
+
}
|
|
516
|
+
const guard = probeWorktreeGuard(projectRoot, worktreePath, configSource, input.resolveBundledDir);
|
|
517
|
+
if (!guard.ok) {
|
|
518
|
+
return { state: guard.unknown ? 'unknown' : 'fail', reason: guard.reason };
|
|
519
|
+
}
|
|
520
|
+
return { state: 'pass' };
|
|
521
|
+
}
|
|
522
|
+
// ── Run all ──────────────────────────────────────────────────────────────────
|
|
523
|
+
/** Run all three probes. Never throws: an unexpected error becomes `unknown`. */
|
|
524
|
+
export function probeIsolation(input) {
|
|
525
|
+
// One clock for the whole block, seeded here so each probe can bail out rather
|
|
526
|
+
// than letting a slow filesystem push session start past the budget.
|
|
527
|
+
const timed = {
|
|
528
|
+
...input,
|
|
529
|
+
budgetStartedAt: input.budgetStartedAt ?? Date.now(),
|
|
530
|
+
};
|
|
531
|
+
const safe = (fn) => {
|
|
532
|
+
try {
|
|
533
|
+
return fn();
|
|
534
|
+
}
|
|
535
|
+
catch (err) {
|
|
536
|
+
return {
|
|
537
|
+
state: 'unknown',
|
|
538
|
+
reason: `probe threw: ${err instanceof Error ? err.message : String(err)}`,
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
return {
|
|
543
|
+
containment: safe(() => probeContainment(timed)),
|
|
544
|
+
branchPin: safe(() => probeBranchPin(timed)),
|
|
545
|
+
pushBlock: safe(() => probePushBlock(timed)),
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
// ── Render ───────────────────────────────────────────────────────────────────
|
|
549
|
+
const MARKS = {
|
|
550
|
+
pass: { glyph: '✓', color: (s) => chalk.green(s) },
|
|
551
|
+
fail: { glyph: '✗', color: (s) => chalk.red(s) },
|
|
552
|
+
unknown: { glyph: '?', color: (s) => chalk.yellow(s) },
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* Sanitize a reason before it reaches the terminal (CWE-150).
|
|
556
|
+
*
|
|
557
|
+
* Reasons are not all ours. `checkHookCompleteness().unresolved` carries snippets
|
|
558
|
+
* of hook `command` strings straight out of `.claude/settings.json`, and that
|
|
559
|
+
* file is agent-editable. A crafted command containing cursor-movement and
|
|
560
|
+
* line-erase sequences can rewrite lines the banner has already printed: erase
|
|
561
|
+
* the real `✗`, paint a green `✓` in its place, and the operator reads a
|
|
562
|
+
* protection as verified when the probe said the opposite. Stripping control
|
|
563
|
+
* sequences at the single choke point every reason passes through covers all
|
|
564
|
+
* interpolation sites at once, including the stderr echo.
|
|
565
|
+
*
|
|
566
|
+
* Also length-capped: a reason is a one-line diagnostic, and an un-capped one can
|
|
567
|
+
* push the rest of the banner off screen, which forges by scrolling rather than
|
|
568
|
+
* by escape code.
|
|
569
|
+
*/
|
|
570
|
+
const MAX_REASON_CHARS = 200;
|
|
571
|
+
export function sanitizeReason(reason) {
|
|
572
|
+
return stripAnsi(reason || 'no reason given')
|
|
573
|
+
// Status glyphs are this codebase's success/failure signal — inferLevel in
|
|
574
|
+
// startup-report.ts keys on them, and an operator scans for them. A reason is
|
|
575
|
+
// untrusted text, so it must not be able to display one: with the escape
|
|
576
|
+
// sequences stripped a bare '✓' cannot reposition anything, but it can still
|
|
577
|
+
// read as a second verdict on a line that already has one.
|
|
578
|
+
.replace(/[✓✗⚠]/g, '')
|
|
579
|
+
.slice(0, MAX_REASON_CHARS);
|
|
580
|
+
}
|
|
581
|
+
/** One rendered banner line: mark, claim, and the reason when not a pass. */
|
|
582
|
+
export function renderProbeLine(claim, r) {
|
|
583
|
+
const m = MARKS[r.state] ?? MARKS.unknown;
|
|
584
|
+
const suffix = r.state === 'pass' ? '' : chalk.dim(` — ${sanitizeReason(r.reason)}`);
|
|
585
|
+
return ` ${m.color(m.glyph)} ${claim}${suffix}`;
|
|
586
|
+
}
|
|
587
|
+
/** Heading colour tracks the worst state, so a red line is not sold under a green header. */
|
|
588
|
+
export function bannerHeading(report) {
|
|
589
|
+
const states = [report.containment.state, report.branchPin.state, report.pushBlock.state];
|
|
590
|
+
if (states.includes('fail'))
|
|
591
|
+
return chalk.bold.red(' Isolation NOT fully enabled:');
|
|
592
|
+
if (states.includes('unknown'))
|
|
593
|
+
return chalk.bold.yellow(' Isolation partially verified:');
|
|
594
|
+
return chalk.bold.green(' Isolation Enabled (verified):');
|
|
595
|
+
}
|
|
596
|
+
export const ISOLATION_CLAIMS = {
|
|
597
|
+
containment: 'Directory restricted to worktree',
|
|
598
|
+
branchPin: 'git checkout/switch to main blocked',
|
|
599
|
+
pushBlock: 'git push origin main blocked',
|
|
600
|
+
};
|
|
601
|
+
/**
|
|
602
|
+
* Print the banner. Advisory only — never throws, never exits (FL-10). Failures
|
|
603
|
+
* are echoed to stderr as well as stdout so they surface where an operator
|
|
604
|
+
* scanning for problems will see them, without blocking the session.
|
|
605
|
+
*/
|
|
606
|
+
export function renderIsolationBanner(report) {
|
|
607
|
+
console.log();
|
|
608
|
+
console.log(bannerHeading(report));
|
|
609
|
+
console.log(chalk.dim(' ─────────────────────────────────────────────'));
|
|
610
|
+
const rows = [
|
|
611
|
+
[ISOLATION_CLAIMS.containment, report.containment],
|
|
612
|
+
[ISOLATION_CLAIMS.branchPin, report.branchPin],
|
|
613
|
+
[ISOLATION_CLAIMS.pushBlock, report.pushBlock],
|
|
614
|
+
];
|
|
615
|
+
for (const [claim, r] of rows) {
|
|
616
|
+
console.log(renderProbeLine(claim, r));
|
|
617
|
+
if (r.state === 'fail') {
|
|
618
|
+
// Same sanitizer as the stdout line: stderr is a terminal too.
|
|
619
|
+
console.error(`isolation: ${claim} — NOT VERIFIED: ${sanitizeReason(r.reason)}`);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
const unverified = rows.filter(([, r]) => r.state !== 'pass').length;
|
|
623
|
+
if (unverified > 0) {
|
|
624
|
+
console.log(chalk.dim(` ${unverified} of ${rows.length} isolation claims are not verified — run 'mx-agent verify-hooks'.`));
|
|
625
|
+
}
|
|
626
|
+
console.log();
|
|
627
|
+
}
|
|
628
|
+
//# sourceMappingURL=isolation-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolation-probe.js","sourceRoot":"","sources":["../../src/lib/isolation-probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CA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