Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(security): close exec expansion gap and exact test discovery
Rahmanbc0eb34091ac
diff --git a/README.md b/README.mdindex cbd6a240..cf6ef769 100644--- a/README.md+++ b/README.md@@ -439,6 +439,8 @@ links every committed official skill in `claude-skills/` into `~/.claude/skills/but every role shares one deployment and the same underlying Unix service account.MCP is disabled unless explicitly enabled. Approve only trusted devices and tokens; keepfilesystem write roots narrow and read the exact command on every approval card.+The one-shot exec guard refuses unresolved shell expansion in recursive-delete targets;+this is a conservative accident guard, not proof that arbitrary shell scripts are safe.Security checks are evidence at a particular revision, not a guarantee. The project has**not had an independent third-party security audit**. Read the [security policy](./SECURITY.md)diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 49e540c8..2ad26b24 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `security` close exec expansion gap and exact test discovery- `security` harden share audit and release verification**Changed**diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.mdindex c1d77c07..9255472e 100644--- a/docs/DEVELOPMENT.md+++ b/docs/DEVELOPMENT.md@@ -44,7 +44,7 @@ checkout's `.next`. A healthy push ends with `audit: clean at high/critical.` anThe local dependency audit may explicitly skip an unavailable registry; that is not a security pass.`bun run audit:strict`, the pre-push gate, and the assurance runner reject incomplete evidence. `test:features` distinguishes-PASS, PARTIAL, SKIPPED and FAIL; slices without colocated unit tests are listed as coverage gaps,+PASS, PARTIAL, SKIPPED and FAIL. Per-area exact-include configurations and result-set validation prevent substring-filter double counting; a root inventory contract prevents unregistered root tests. Slices without colocated unit tests are listed as coverage gaps,not invented successes. Browser rendering and live third-party operations need separate acceptance.The gate has no sibling-repository runner or dormant Convex deployment step. Worktree hook installationuses Git's shared hook path rather than assuming `.git` is a directory.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 81502c4f..26d7b821 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,4 +1,5 @@# mso — Progress Log+- **Previously hidden exec/discovery test gaps closed (2026-09-05):** the remaining expected-failure shell-expansion case is now a real passing refusal test. Recursive deletion with unresolved shell expansion is conservatively refused; literal reviewed targets remain subject to normal approvals, and the matcher is explicitly not a shell parser or sandbox. Added eight predicate-only expansion fixtures without executing destructive commands. Registered the previously omitted root machine-protocol proxy test in normal Vitest/coverage and added an inventory regression contract. Per-area runs now use isolated exact-include configurations and verify the exact returned file set, preventing substring matches from counting unrelated nested proxy tests twice. Earlier per-area totals from this audit are superseded by the exact-selection rerun.- **Compiler-enforced unused-code cleanup (2026-09-05):** resolved 49 unused import/local/parameter diagnostics across the shell, assistant, media, host, MCP and test modules. Calls with intentional side effects remain intact; positional callback placeholders are explicitly named. TypeScript `noUnusedLocals` and `noUnusedParameters` now make the ordinary typecheck/CI reject regressions. This is compiler-proven unused-symbol cleanup, not a claim that every exported symbol, runtime-discovered asset or optional integration is removable.- **Public-sharing security and maintenance audit (2026-09-05):** app `0.2.2` keeps the independently versioned CLI/MCP contracts unchanged. Release and assurance dependency audits now fail closed on unavailable, malformed or incomplete evidence; local developer skips are explicitly labelled, registry diagnostics do not expose raw URLs, and skipped optional scanners cannot produce an unconditional assurance PASS. Removed the dormant Convex deploy tail, fixed shared Git-hook installation and out-of-tree dependency copying for linked worktrees, and added functional regression tests. README now leads with a readable install/features/security overview and collapsible reference detail, preserving generated comparison evidence and public-alpha limits. `test:features` runs each test area in a separate process and distinguishes PASS/PARTIAL/SKIPPED/FAIL. The Forge Docker sandbox and synthetic credential-path fixture activate previously skipped security checks without using real secrets; CI now provisions the same bounded fixtures. Onboarding tests derive the app version from `package.json`; the browser suite follows the actual Activity & Runs UI, checks infrastructure deep-links, and never echoes session-cookie diagnostics. Full-history scanning now requests merge diffs explicitly in CI and the assurance runner; independent scanner outputs remain private; no genuine historical secret was identified by the configured scan, so shared history was not rewritten. Live-service deployment and remote CI status require separate exact-revision evidence and are not inferred from local tests.- **Rahmanef-aligned MCP widget palette / Block + Page v2 (2026-09-04):** MCP server `1.10.0` / toolset `2026.09.04.7` moves the two canonical ChatGPT resources to `ui://mso/block-v2.html` and `ui://mso/page-v2.html` so hosts do not reuse the old purple CSS cache key. Block and Page now share one visual-token source aligned with `rahmanef.com`: light `#f4f4f7` / `#1c1c1f`, dark `#1b1b20` / `#f2f2f5`, accent `#1f6df0`, Plus Jakarta Sans display copy, Inter body copy, fine separators, and editorial foreground/background primary-action inversion. ChatGPT theme changes propagate through `window.openai.theme` with a color-scheme fallback. Block/Page v1 and the earlier workflow/surface URIs remain readable but unlisted compatibility aliases; the headless workflow and two-surface/security contracts are unchanged.diff --git a/docs/SECURITY-ASSURANCE.md b/docs/SECURITY-ASSURANCE.mdindex eec57568..adb20f44 100644--- a/docs/SECURITY-ASSURANCE.md+++ b/docs/SECURITY-ASSURANCE.md@@ -65,6 +65,12 @@ The production baseline keeps five known passive signals visible as `INFO`: cachThese are rule-specific classifications in `security/zap-baseline.conf`, not a global warning bypass. Any other ZAP baseline alert remains a warning/failure and makes the gate non-zero.+## Command-guard evidence boundary++The one-shot command guard conservatively refuses recursive deletion with unresolved shell-variable or command-substitution targets. It does not evaluate those expressions or execute a command to inspect its meaning. A literal reviewed target still requires normal authorization and approval. Quoted prose and escaped/literal expansion syntax may be refused too; this is an intentional safety-biased false positive.++This remains a best-effort accident guard, **not a shell sandbox**. Script bodies, aliases, interpreters and dynamically assembled commands are not generally proven safe by a regular expression. The service user's Unix permissions, authentication, device/token scope and approvals remain the trust boundary. The old expected-failure fixture is now a normal passing predicate test; no destructive fixture command is executed.+## ASVS-oriented coverageThe automated suite materially exercises ASVS areas including authentication, session management, authorization, OAuth/MCP access control, validation/sanitization, stored-file/path handling, SSRF/network destinations, security headers/browser policy, logging/redaction, dependency integrity and secure configuration. The historical audit in [`AUDIT-2026-08-24.md`](./AUDIT-2026-08-24.md) documents concrete adversarial reproductions and remediations.diff --git a/lib/host/destructive-patterns.test.ts b/lib/host/destructive-patterns.test.tsindex 84cc5a7a..3ce7aa39 100644--- a/lib/host/destructive-patterns.test.ts+++ b/lib/host/destructive-patterns.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from "vitest";import { matchDestructive } from "./destructive-patterns";+// Predicate-only fixtures: these strings are never sent to a shell.describe("matchDestructive", () => {it("flags box-wrecking commands", () => {expect(matchDestructive("rm -rf /")).toBeTruthy();@@ -10,12 +11,27 @@ describe("matchDestructive", () => {expect(matchDestructive("kill -9 1")).toBeTruthy();});- it("allows ordinary commands", () => {+ it.each([+ 'HOME=/ rm -rf "$HOME"',+ 'rm -rf "${TARGET}"',+ 'rm --recursive --force -- "$TARGET"',+ 'rm -R "$1"',+ 'rm -fr "${TARGET:-/}"',+ 'rm "$TARGET" -rf',+ 'rm -rf "$(printf target)"',+ 'rm -rf `printf target`',+ ])("refuses unresolved recursive-delete expansion: %s", (command) => {+ expect(matchDestructive(command)).toMatch(/unresolved shell expansion/);+ });++ it("allows ordinary commands and reviewed literal cleanup targets", () => {expect(matchDestructive("ls -la ~/projects")).toBeNull();expect(matchDestructive("git status")).toBeNull();expect(matchDestructive("npm run build")).toBeNull();- // The load-bearing case: deleting the OWNER's data inside a write root is NOT- // on the denylist — the human approval gate is what protects it, not this.+ expect(matchDestructive('printf "%s" "$HOME"')).toBeNull();+ // Literal deletion still requires normal human approval. This guard is not+ // a filesystem sandbox or authorization to delete arbitrary owner data.expect(matchDestructive("rm -rf ~/projects/scratch")).toBeNull();+ expect(matchDestructive("rm -rf /tmp/mso-owned-fixture")).toBeNull();});});diff --git a/lib/host/destructive-patterns.ts b/lib/host/destructive-patterns.tsindex ddfe2285..73e5b87c 100644--- a/lib/host/destructive-patterns.ts+++ b/lib/host/destructive-patterns.ts@@ -1,15 +1,16 @@// SERVER + CLIENT safe — pure regex, NO node imports. The catastrophic-command// denylist, extracted from exec.ts so two callers share one source of truth:// • exec.ts (server) enforces it — refuses the command with code 126.-// • the assistant's approval card (client) advisely flags a command the server-// will refuse, so a human isn't tricked into approving a guaranteed error.-// exec.ts layers the OS_EXEC_ALLOW_DESTRUCTIVE override on top of this.+// • the assistant's approval card (client) flags commands the server will refuse.+// exec.ts layers the explicit owner override on top; this is NOT a shell sandbox.-// High-confidence catastrophic patterns: commands that wreck the whole box and-// are almost never run on purpose through a web cockpit. Genuine disk surgery-// should go over SSH.+// High-confidence catastrophic patterns plus conservative recursive-delete+// expansion checks. Runtime shell values cannot be proven safe statically, so+// unresolved recursive-delete targets require an explicit reviewed literal path.+// Quoted prose or escaped/literal dollar signs may also be refused intentionally.export const DESTRUCTIVE: { re: RegExp; why: string }[] = [{ re: /\brm\b(?:\s+-\S*)*\s+-\S*[rf]\S*\s+(?:--no-preserve-root\s+)?\/(?:\s|$|\*)/, why: "rm -rf on /" },+ { re: /\brm\b(?=[^;&|\n]*\s(?:--recursive\b|-[A-Za-z]*[rR][A-Za-z]*(?:\s|$)))[^;&|\n]*(?:\$[A-Za-z_0-9@*#?$!{(]|`)/, why: "recursive rm with unresolved shell expansion — use an explicit reviewed path" },{ re: /--no-preserve-root/, why: "rm --no-preserve-root" },{ re: /\bmkfs(?:\.\w+)?\b/, why: "mkfs (format a filesystem)" },{ re: /\bdd\b[^\n]*\bof=\/dev\/(?:sd|nvme|vd|xvd|disk|hd)/, why: "dd to a block device" },@@ -24,23 +25,14 @@ export const DESTRUCTIVE: { re: RegExp; why: string }[] = [];// Shell metacharacters that start a new command, open a subshell, or open/close a-// quoted string. The patterns above anchor the catastrophic argument on `\s`, `$` or-// `*`, so a `/` followed by `;`, `)` or `"` used to slip straight past them:-// echo hi; rm -rf /; echo bye `/` then `;`-// (rm -rf /) & `/` then `)`-// bash -c "rm -rf /" `/` then `"`-// Splitting on these puts each command on its own, where the trailing `/` lands at-// end-of-segment and the existing patterns can see it. Widening every regex instead-// was the alternative and is the wrong shape — a regex over a shell string leaks a-// new way in for every character you forget.+// quoted string. Whole-string evaluation stays first so multi-segment patterns+// (fork bombs and recursive-delete expansion) are not lost through splitting.const SEPARATORS = /[;&|()"'`\n]+/;-// The reason a command matches the denylist, or null. Pure (no env override —-// that's exec.ts's job); safe to call from the browser.+// A best-effort accident guard, not a parser for every shell spelling, interpreter,+// script body, alias, or dynamically assembled executable. Auth/scope/approval and+// the operating-system service user's authority remain the real trust boundary.export function matchDestructive(cmd: string): string | null {- // WHOLE STRING FIRST, and it must stay first: the fork-bomb pattern is built out- // of `(){}|&;:` — the very characters SEPARATORS splits on — so testing only the- // segments would stop detecting it.for (const part of [cmd, ...cmd.split(SEPARATORS)]) {if (!part) continue;for (const d of DESTRUCTIVE) if (d.re.test(part)) return d.why;diff --git a/lib/host/exec-filter.test.ts b/lib/host/exec-filter.test.tsindex 7c85f726..55d96e69 100644--- a/lib/host/exec-filter.test.ts+++ b/lib/host/exec-filter.test.ts@@ -132,13 +132,11 @@ describe("destructiveReason — adversarial encodings", () => {expect(destructiveReason('git commit -m "never run rm -rf / on prod"')).toMatch(/rm -rf on \//);});- // REMAINING GAP, and not fixable by a static filter: the destructive argument- // only exists after the shell expands the variable. `it.fails` PASSES while the- // assertion fails, so this turns the suite RED if it ever starts being caught —- // a built-in alarm that the note below has gone stale.- it.fails("GAP: variable-expansion form `HOME=/ rm -rf \"$HOME\"` — no literal `/` after -rf", () => {- expect(destructiveReason('HOME=/ rm -rf "$HOME"')).toMatch(/rm -rf on \//);+ // Former expected failure: unresolved recursive-delete operands now fail closed.+ it("refuses variable-expansion form `HOME=/ rm -rf \"$HOME\"` — no literal `/` after -rf", () => {+ expect(destructiveReason('HOME=/ rm -rf "$HOME"')).toMatch(/unresolved shell expansion/);});+});describe("runCommand", () => {diff --git a/scripts/feature-test-result.test.ts b/scripts/feature-test-result.test.tsindex 64148703..8833faeb 100644--- a/scripts/feature-test-result.test.ts+++ b/scripts/feature-test-result.test.ts@@ -20,3 +20,20 @@ describe("per-feature evidence classification", () => {});}});++describe("exact test-file selection", () => {+ const cases = [+ [["/repo/proxy.test.ts"], [{ name: "/repo/proxy.test.ts" }], true],+ [["/repo/proxy.test.ts"], [{ name: "/repo/lib/proxy.test.ts" }], false],+ [["/repo/proxy.test.ts"], [{ name: "/repo/proxy.test.ts" }, { name: "/repo/lib/proxy.test.ts" }], false],+ [["/repo/proxy.test.ts"], [], false],+ [["/repo/a.test.ts", "/repo/b.test.ts"], [{ name: "/repo/a.test.ts" }, { name: "/repo/a.test.ts" }], false],+ ] as const;+ for (const [expected, actual, matches] of cases) {+ it(`validates the exact set: ${JSON.stringify(actual)}`, () => {+ const script = `import { featureSelectionMatches } from "./scripts/lib/feature-test-result.mjs"; console.log(featureSelectionMatches(${JSON.stringify(expected)}, ${JSON.stringify(actual)}));`;+ const run = spawnSync(process.execPath, ["--input-type=module", "-e", script], { cwd: process.cwd(), encoding: "utf8" });+ expect(run.status).toBe(0); expect(run.stdout.trim()).toBe(String(matches));+ });+ }+});diff --git a/scripts/lib/feature-test-result.mjs b/scripts/lib/feature-test-result.mjsindex 6e26d23d..a12e515b 100644--- a/scripts/lib/feature-test-result.mjs+++ b/scripts/lib/feature-test-result.mjs@@ -6,3 +6,11 @@ export function classifyFeatureResult(exitCode, result) {if ((result.numPendingTests ?? 0) + (result.numTodoTests ?? 0) > 0) return "PARTIAL";return "PASS";}++// CLI filters are substrings. Require every exact inventory file once, and no extras.+export function featureSelectionMatches(expected, results) {+ if (!Array.isArray(results)) return false;+ const names = results.map((result) => result.name);+ return names.length === expected.length && new Set(names).size === expected.length+ && names.every((name) => expected.includes(name));+}diff --git a/scripts/test-features.mjs b/scripts/test-features.mjsindex b3f89a92..4b870b5d 100644--- a/scripts/test-features.mjs+++ b/scripts/test-features.mjs@@ -1,6 +1,6 @@#!/usr/bin/env node// Run each test area in a separate Vitest process; never call an untested slice PASS.-import { classifyFeatureResult } from "./lib/feature-test-result.mjs";+import { classifyFeatureResult, featureSelectionMatches } from "./lib/feature-test-result.mjs";import { spawnSync } from "node:child_process";import { chmodSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";@@ -51,9 +51,16 @@ let failed = false;for (const [name, files] of [...groups].sort(([a], [b]) => a.localeCompare(b))) {const basename = name.replaceAll("/", "-");const resultFile = join(outputDir, `${basename}.json`);+ const configFile = join(outputDir, `${basename}.config.mts`);+ // CLI filters match substrings, even with absolute paths. Override include+ // instead, then independently verify the exact result-file inventory below.+ const exactIncludes = files.map((file) => file.replace(/[?*{}\[\]]/g, "\\$&"));+ writeFileSync(configFile,+ `import base from ${JSON.stringify(join(root, "vitest.config.mts"))};\nexport default {...base, test: {...base.test, include: ${JSON.stringify(exactIncludes)}}};\n`,+ { mode: 0o600 });const started = Date.now();const result = spawnSync(join(root, "node_modules/.bin/vitest"), [- "run", ...files.sort(), "--maxWorkers=2", "--reporter=json", `--outputFile=${resultFile}`,+ "run", "--config", configFile, "--maxWorkers=2", "--reporter=json", `--outputFile=${resultFile}`,], { cwd: root, encoding: "utf8", timeout: 240_000, maxBuffer: 10 * 1024 * 1024,env: { ...process.env, CI: "1", NO_COLOR: "1" } });let parsed = {};@@ -62,7 +69,8 @@ for (const [name, files] of [...groups].sort(([a], [b]) => a.localeCompare(b)))name, files: files.length, total: parsed.numTotalTests ?? 0,passed: parsed.numPassedTests ?? 0, failed: parsed.numFailedTests ?? 0,skipped: (parsed.numPendingTests ?? 0) + (parsed.numTodoTests ?? 0),- status: classifyFeatureResult(result.status, parsed),+ status: featureSelectionMatches(files.map((file) => resolve(root, file)), parsed.testResults)+ ? classifyFeatureResult(result.status, parsed) : "FAIL",durationMs: Date.now() - started,};if (row.status === "FAIL") {diff --git a/scripts/worktree-gates.test.ts b/scripts/worktree-gates.test.tsindex 2cbed90c..d22f07ff 100644--- a/scripts/worktree-gates.test.ts+++ b/scripts/worktree-gates.test.ts@@ -1,5 +1,5 @@import { spawnSync } from "node:child_process";-import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";+import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";import os from "node:os";import path from "node:path";import { afterEach, describe, expect, it } from "vitest";@@ -44,3 +44,12 @@ describe("isolated worktree release guards", () => {expect(existsSync(path.join(repo, ".env.local"))).toBe(true);});});++describe("root test inventory", () => {+ it("registers every root-level test in the normal verification gate", () => {+ const config = readFileSync(path.join(process.cwd(), "vitest.config.mts"), "utf8");+ for (const file of readdirSync(process.cwd()).filter((name) => /\.test\.tsx?$/.test(name))) {+ expect(config, `unregistered root test: ${file}`).toContain(JSON.stringify(file));+ }+ });+});diff --git a/vitest.config.mts b/vitest.config.mtsindex 3ba204c2..0713b511 100644--- a/vitest.config.mts+++ b/vitest.config.mts@@ -38,6 +38,7 @@ export default defineConfig({// which is worse than having no test at all, because the suite still says green."proxy.test.ts","proxy-websocket.test.ts",+ "proxy-machine-protocol.test.ts",],environment: "node",// `bun run coverage`, and it IS in `verify`, so these are gates.