From dfd37078dff5ad09718fd735d564b6882fee1a81 Mon Sep 17 00:00:00 2001 From: grok-bot Date: Wed, 7 Oct 2026 17:34:57 -0700 Subject: [PATCH] Hidden-check commands off argv: stream them in on fd 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A hidden check's command is a secret the worker must not learn, but spawned through the shell the ordinary way it becomes an argv word and shows up in /proc//cmdline (world-readable) and ps. A runs+value check that executes the worker's own deliverable hands that deliverable a process whose command line it can read — even inside a per-check PID namespace, where a child can still read its parent's cmdline. runCommand gains hideCommand: when set (Linux/macOS), the shell is spawned as ' -c eval "$(cat <&3)"' and the real command is streamed in on fd 3, so the only thing in argv is that fixed wrapper. fd 3 rather than stdin so a check's stdin is untouched. Wired for every hidden-check spawn: the bar's runCheck, the mutation builtin's runs, the drafted-check trials in preflightCriteria, and the reference value-check try. Note in withhold.ts that masking is exact-substring only (a convenience for Maat's own records, not the confidentiality boundary). Test: a hidden-command run whose body reads its own and a child's cmdline and asserts the command's token is absent, that it still executes and propagates its exit code, and that stdin is left empty; plus a contrast run proving the ordinary spawn does leak the token. Linux-only (skipped on macOS). --- src/bar.ts | 9 ++++++-- src/criteria.ts | 3 +++ src/reference.ts | 3 ++- src/run.ts | 59 ++++++++++++++++++++++++++++++++++++++++-------- src/withhold.ts | 10 ++++++++ test/run.test.ts | 44 ++++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 12 deletions(-) diff --git a/src/bar.ts b/src/bar.ts index 8425eb1..184c54f 100644 --- a/src/bar.ts +++ b/src/bar.ts @@ -911,6 +911,7 @@ async function mutationCheck( sample: number, timeoutMs: number, allowEmpty = false, + hideCommand = false, ): Promise<{ ok: boolean; output: string; established?: boolean }> { // Source code only, and not the tests themselves. A live run mutated // package.json — `&&` to `||` inside a JSON string — and reported the @@ -1006,7 +1007,7 @@ async function mutationCheck( }; } if (!prior) { - const baseline = await runCommand(run, { cwd: ctx.cwd, timeoutMs, signal: ctx.signal }); + const baseline = await runCommand(run, { cwd: ctx.cwd, timeoutMs, signal: ctx.signal, hideCommand }); if (baseline.code !== 0) { return { ok: false, @@ -1039,6 +1040,7 @@ async function mutationCheck( cwd: ctx.cwd, timeoutMs, signal: ctx.signal, + hideCommand, }); // A mutation the command still passes is a line nothing checks — unless // it was a boundary nudge and negating the same condition is caught. @@ -1052,7 +1054,7 @@ async function mutationCheck( let negKilled = false; if (neg && negText !== null && negText !== file.text) { writeFileSync(file.abs, negText, "utf8"); - const rn = await runCommand(run, { cwd: ctx.cwd, timeoutMs, signal: ctx.signal }); + const rn = await runCommand(run, { cwd: ctx.cwd, timeoutMs, signal: ctx.signal, hideCommand }); negKilled = rn.code !== 0; } if (negKilled) boundaryOnly.push(`${m.path}:${m.line} (${m.operator}) — ${m.before.trim()}`); @@ -2151,6 +2153,7 @@ export async function runCheck(check: Check, ctx: BarContext): Promise