Skip to content

armgit / mso

Public Imported from GitHub
0

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.

fix(security): block recursive credential relocation

Rahman3976674d9f49
diff --git a/.github/workflows/codex-security.yml b/.github/workflows/codex-security.yml
index 23454043..efb610b4 100644
--- a/.github/workflows/codex-security.yml
+++ b/.github/workflows/codex-security.yml
@@ -23,6 +23,8 @@ jobs:
CODEX_SECURITY_FAIL_ON_SEVERITY: high
CODEX_SECURITY_COMPONENT_WORKERS: "2"
CODEX_SECURITY_COMPONENT_MAX_COST_USD: "5"
+ CODEX_SECURITY_MODEL: "gpt-5.6-terra"
+ CODEX_SECURITY_EFFORT: "high"
steps:
- name: Checkout
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index a03939b9..2ac1f5ef 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -4,6 +4,16 @@
Newest first. `docs/PROGRESS.md` is the source of truth for *why* a change was made;
this is the *what*, and it is what Settings → About shows as “What's new”.
+## 2026-08-28
+
+**Added**
+
+- `mcp` add bounded async exec jobs
+
+**Fixed**
+
+- `security` block recursive credential relocation
+
## 2026-08-26
**Added**
diff --git a/docs/SECURITY-ASSURANCE.md b/docs/SECURITY-ASSURANCE.md
index f9103eab..ff3bc3a9 100644
--- a/docs/SECURITY-ASSURANCE.md
+++ b/docs/SECURITY-ASSURANCE.md
@@ -47,7 +47,7 @@ bun run security:ultimate
The command creates a `0700` private run directory under `~/.mso/security-assurance`, snapshots **tracked files only**, and runs the repository verification plus Trivy, OSV-Scanner, Gitleaks, Semgrep, ShellCheck, the official Codex Security component scan across the full tracked repository and the passive ZAP baseline. Detailed scanner output stays outside the repository. A failing scanner produces a failing command; the script does not convert scanner outages into security passes.
-Codex Security is intentionally not an automatic per-commit hosted gate because it consumes model/API budget. MSO uses OpenAI's official `scan-components` command because repeated monolithic Standard scans of this repository reached bounded spend limits without producing a terminal coverage result. The committed [`security/codex-components.json`](../security/codex-components.json) plan was generated by the official planner and covers all tracked files through twenty non-overlapping components. The official auto-plan was refined along subsystem boundaries after bounded trial scans proved that its two largest groups were too broad to reach a terminal result within the per-component guard. Each component receives a Standard scan, then Codex Security performs cross-component root-cause matching; incomplete component coverage or incomplete matching fails closed. The default guard is $5 **per component**, with two concurrent workers, and can be changed explicitly through `CODEX_SECURITY_COMPONENT_MAX_COST_USD` and `CODEX_SECURITY_COMPONENT_WORKERS`. The result gate independently validates `summary.json` and the combined `findings.json`; High/Critical groups fail the run. A maintainer can explicitly skip the lane with `MSO_SECURITY_SKIP_CODEX=1`, but a run with a skipped lane must not be advertised as the full ultimate gate. ZAP is likewise skippable for offline development, but not for a published assurance run.
+Codex Security is intentionally not an automatic per-commit hosted gate because it consumes model/API budget. MSO uses OpenAI's official `scan-components` command because repeated monolithic Standard scans of this repository reached bounded spend limits without producing a terminal coverage result. The committed [`security/codex-components.json`](../security/codex-components.json) plan was generated by the official planner and covers all tracked files through twenty non-overlapping components. The official auto-plan was refined along subsystem boundaries after bounded trial scans proved that its two largest groups were too broad to reach a terminal result within the per-component guard. Each component receives a Standard scan, then Codex Security performs cross-component root-cause matching; incomplete component coverage or incomplete matching fails closed. The default guard is $5 **per component**, with two concurrent workers. MSO pins the component lane to `gpt-5.6-terra` with `high` reasoning because calibration on the security-critical `lib/host` component reached complete terminal coverage under that bounded budget, while `gpt-5.6-sol` at xhigh/medium repeatedly exhausted bounded spend without a terminal coverage result. Model, effort, budget and workers remain explicit overrides through `CODEX_SECURITY_MODEL`, `CODEX_SECURITY_EFFORT`, `CODEX_SECURITY_COMPONENT_MAX_COST_USD` and `CODEX_SECURITY_COMPONENT_WORKERS`. The result gate independently validates `summary.json` and the combined `findings.json`; High/Critical groups fail the run. A maintainer can explicitly skip the lane with `MSO_SECURITY_SKIP_CODEX=1`, but a run with a skipped lane must not be advertised as the full ultimate gate. ZAP is likewise skippable for offline development, but not for a published assurance run.
## Reviewed Gitleaks fixtures
diff --git a/lib/host/fs.test.ts b/lib/host/fs.test.ts
index 86eaa949..a4d34c8e 100644
--- a/lib/host/fs.test.ts
+++ b/lib/host/fs.test.ts
@@ -11,7 +11,7 @@ import {
import os from "node:os";
import path from "node:path";
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
-import { move, remove, writeFile } from "./fs";
+import { copy, move, remove, writeFile } from "./fs";
// Mirrors paths.test.ts setup. Layout:
// base/read/ ← read root
@@ -137,3 +137,19 @@ describe("remove", () => {
await expect(remove(writeRoot)).rejects.toThrow(/root directory/i);
});
});
+
+describe("recursive credential mutation guard", () => {
+ it("refuses copy, move, and delete when a nested loose credential exists", async () => {
+ useRoots(readRoot, writeRoot);
+ const source = path.join(writeRoot, "credential-tree");
+ const nested = path.join(source, "nested");
+ mkdirSync(nested, { recursive: true });
+ writeFileSync(path.join(nested, "deploy.pem"), "synthetic");
+
+ await expect(copy(source, path.join(writeRoot, "copied-tree"))).rejects.toThrow(/credential/i);
+ await expect(move(source, path.join(writeRoot, "moved-tree"))).rejects.toThrow(/credential/i);
+ await expect(remove(source)).rejects.toThrow(/credential/i);
+ expect(existsSync(path.join(nested, "deploy.pem"))).toBe(true);
+ rmSync(source, { recursive: true, force: true });
+ });
+});
diff --git a/lib/host/fs.ts b/lib/host/fs.ts
index 7ee5d197..f66038c9 100644
--- a/lib/host/fs.ts
+++ b/lib/host/fs.ts
@@ -9,6 +9,7 @@ import { projectAliasTarget } from "./project-aliases";
import {
appSecretCopyFilter,
assertNoAppSecretDescendants,
+ assertNoCredentialDescendants,
assertNoSensitiveDescendants,
assertNotRoot,
isSensitivePath,
@@ -76,14 +77,16 @@ export async function makeDir(requested: string): Promise<void> {
export async function remove(requested: string): Promise<void> {
const p = await safeWritePath(requested, true);
await assertNotRoot(p);
+ await assertNoCredentialDescendants(p);
await fs.rm(p, { recursive: true, force: true });
}
export async function move(from: string, to: string): Promise<void> {
const src = await safeWritePath(from, true);
await assertNotRoot(src);
- assertNoSensitiveDescendants(src); // rename/cp recurse past the per-path gate
- assertNoAppSecretDescendants(src); // ...and so do they past the app's own .env*
+ assertNoSensitiveDescendants(src); // fixed sensitive locations under a parent
+ assertNoAppSecretDescendants(src); // the cockpit's own .env* under a parent
+ await assertNoCredentialDescendants(src); // loose id_* / *.pem anywhere below
const dest = await safeWritePath(to, false);
try {
await fs.rename(src, dest);
@@ -99,7 +102,10 @@ export async function move(from: string, to: string): Promise<void> {
export async function copy(from: string, to: string): Promise<void> {
const src = await safeWritePath(from, true);
- assertNoSensitiveDescendants(src); // fs.cp recurses past the per-path gate
+ assertNoSensitiveDescendants(src); // fixed sensitive locations under a parent
+ // The app's own .env* are intentionally filtered below; every other credential
+ // descendant (including arbitrary nested id_* / *.pem) makes the copy fail closed.
+ await assertNoCredentialDescendants(src, { ignoreAppSecrets: true });
const dest = await safeWritePath(to, false);
// Skip the cockpit's own .env* rather than refuse the copy — on the default
// roots APP_DIR sits under ~/projects, so refusing would block copying it.
diff --git a/lib/host/paths-credentials.test.ts b/lib/host/paths-credentials.test.ts
index 1be117c8..e295d711 100644
--- a/lib/host/paths-credentials.test.ts
+++ b/lib/host/paths-credentials.test.ts
@@ -1,10 +1,11 @@
-import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import {
appSecretCopyFilter,
assertNoAppSecretDescendants,
+ assertNoCredentialDescendants,
assertNoSensitiveDescendants,
isCredentialPath,
isSensitivePath,
@@ -83,6 +84,32 @@ describe("recursive credential guard", () => {
expect(() => assertNoSensitiveDescendants(path.join(fakeHome, "safe"))).not.toThrow();
});
+ it("recursively rejects loose private keys and PEM files at arbitrary depth", async () => {
+ vi.stubEnv("HOME", fakeHome);
+ const tree = path.join(fakeHome, "safe", "recursive-credentials");
+ const nested = path.join(tree, "a", "b");
+ mkdirSync(nested, { recursive: true });
+ writeFileSync(path.join(nested, "id_ed25519"), "synthetic");
+ await expect(assertNoCredentialDescendants(tree)).rejects.toThrow(/id_ed25519/);
+ rmSync(path.join(nested, "id_ed25519"));
+ writeFileSync(path.join(nested, "deploy.PEM"), "synthetic");
+ await expect(assertNoCredentialDescendants(tree)).rejects.toThrow(/deploy\.PEM/i);
+ rmSync(tree, { recursive: true, force: true });
+ });
+
+ it("does not follow descendant symlinks while inspecting a recursive source", async () => {
+ vi.stubEnv("HOME", fakeHome);
+ const tree = path.join(fakeHome, "safe", "symlink-tree");
+ const outside = path.join(base, "outside-credential-dir");
+ mkdirSync(tree, { recursive: true });
+ mkdirSync(outside, { recursive: true });
+ writeFileSync(path.join(outside, "id_rsa"), "synthetic");
+ symlinkSync(outside, path.join(tree, "external"));
+ await expect(assertNoCredentialDescendants(tree)).resolves.toBeUndefined();
+ rmSync(tree, { recursive: true, force: true });
+ rmSync(outside, { recursive: true, force: true });
+ });
+
it("honours the OS_FS_ALLOW_SENSITIVE escape hatch", () => {
vi.stubEnv("HOME", fakeHome);
vi.stubEnv("OS_FS_ALLOW_SENSITIVE", "1");
diff --git a/lib/host/paths.ts b/lib/host/paths.ts
index e727ef3f..694d8236 100644
--- a/lib/host/paths.ts
+++ b/lib/host/paths.ts
@@ -198,6 +198,41 @@ export function assertNoSensitiveDescendants(real: string): void {
);
}
+/** Walk a recursive mutation source and apply the same credential predicate used
+ * by per-path reads/writes to every descendant. Directory operations otherwise
+ * let fs.cp/fs.rename/fs.rm walk past the top-level gate. Symlinks are inspected
+ * by their own path/name but never followed, so this guard cannot escape the
+ * already-resolved mutation root or traverse a cycle. */
+export async function assertNoCredentialDescendants(
+ realBase: string,
+ options: { ignoreAppSecrets?: boolean } = {},
+): Promise<void> {
+ const rootStat = await fs.lstat(realBase).catch(() => null);
+ if (!rootStat?.isDirectory()) return;
+
+ const stack = [realBase];
+ while (stack.length) {
+ const dir = stack.pop()!;
+ let entries: import("fs").Dirent[];
+ try {
+ entries = await fs.readdir(dir, { withFileTypes: true });
+ } catch (error) {
+ throw new HostError(`Refusing recursive mutation: cannot inspect ${path.relative(realBase, dir) || "."}`);
+ }
+ for (const entry of entries) {
+ const child = path.join(dir, entry.name);
+ const credential = isCredentialPath(child);
+ const ignoredAppSecret = options.ignoreAppSecrets === true && isAppSecret(child);
+ if (credential && !ignoredAppSecret) {
+ throw new HostError(
+ `Refusing: this directory contains a credential path (${path.relative(realBase, child)})`,
+ );
+ }
+ if (entry.isDirectory()) stack.push(child);
+ }
+ }
+}
+
// The app's own `.env*` needed the narrower fix the ~/ list can't give: on the
// DEFAULT roots (~ and ~/projects) APP_DIR is a descendant of a copyable dir, so
// `copy(~/projects, ~/backup)` walked past the per-path gate and duplicated
diff --git a/scripts/codex-security-components.sh b/scripts/codex-security-components.sh
index 63c183dc..ebbcaeff 100755
--- a/scripts/codex-security-components.sh
+++ b/scripts/codex-security-components.sh
@@ -8,6 +8,8 @@ AUTH="${CODEX_SECURITY_AUTH:-auto}"
FAIL_ON="${CODEX_SECURITY_FAIL_ON_SEVERITY:-high}"
WORKERS="${CODEX_SECURITY_COMPONENT_WORKERS:-2}"
MAX_COST="${CODEX_SECURITY_COMPONENT_MAX_COST_USD:-5}"
+MODEL="${CODEX_SECURITY_MODEL:-gpt-5.6-terra}"
+EFFORT="${CODEX_SECURITY_EFFORT:-high}"
REPO_ROOT="$(git rev-parse --show-toplevel)"
REPO_NAME="$(basename "$REPO_ROOT")"
PLAN="${CODEX_SECURITY_COMPONENT_PLAN:-$REPO_ROOT/security/codex-components.json}"
@@ -36,6 +38,8 @@ args=(
--auth "$AUTH"
--components-file "$PLAN"
--workers "$WORKERS"
+ --model "$MODEL"
+ --effort "$EFFORT"
--max-cost "$MAX_COST"
--knowledge-base "$REPO_ROOT/SECURITY.md"
--output-dir "$OUTPUT_DIR"