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): verify exact branch dispositions and narrow message origins
Rahman4ccecb99b3b1
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.ymlindex 1f0d3d57..5b62cad4 100644--- a/.github/workflows/codeql.yml+++ b/.github/workflows/codeql.yml@@ -42,3 +42,9 @@ jobs:- name: Report every result from this exact CodeQL analysisrun: node scripts/codeql-report.mjs "$RUNNER_TEMP/mso-codeql-results"++ - name: Inspect actual branch findings after SARIF processing+ if: github.event_name == 'push'+ run: node scripts/security-alerts.mjs --inventory --include-closed --ref "$GITHUB_REF"+ env:+ GITHUB_TOKEN: ${{ github.token }}diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex ebb6a125..0f72dbbd 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -15,6 +15,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `security` verify exact branch dispositions and narrow message origins- `security` retain artifact-lock compatibility and require fresh scan evidence- `security` pin store paths and eliminate unsafe file-read patterns- `mcp` add explicit browser sign-in for reviewed embedded appsdiff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 8dbeda3a..e96706f1 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,7 @@+## 2026-09-05 — Scope the final security evidence to the scanned revision++The inventory can now inspect the exact scanned branch after SARIF processing, distinguishes open findings from pre-existing reviewed/closed findings, and rejects a concurrent HEAD change. Reports stream to Actions logs rather than writing remote API content back to files. A newly merged MCP browser fixture now targets the exact widget origin instead of a wildcard; the 17 browser assertions retain their negative-navigation checks. No scanner rule, authentication boundary, or existing disposition is removed by this change.+## 2026-09-05 — Permission-fixture portability under private umaskThe deliberately public artifact fixture now sets its final 0644 permissions explicitly: a secure caller umask of 077 otherwise silently creates it as 0600, so the test was asking valid private data to be rejected. The runtime permission check and assertion remain unchanged.diff --git a/scripts/e2e/mcp-page.mjs b/scripts/e2e/mcp-page.mjsindex 09420290..a66028bb 100644--- a/scripts/e2e/mcp-page.mjs+++ b/scripts/e2e/mcp-page.mjs@@ -75,7 +75,7 @@ try {const authAction = component.getByRole("button", { name: "Google login in browser", exact: true });await authAction.waitFor();const opensBeforeAuth = (await page.evaluate(() => window.calls)).filter(call => call.method === "ui/open-link").length;- await reloaded.evaluate(() => parent.postMessage({ type: "mso:app-auth-request", schemaVersion: 1, provider: "google" }, "*"));+ await reloaded.evaluate(() => parent.postMessage({ type: "mso:app-auth-request", schemaVersion: 1, provider: "google" }, "https://mso-ui.rahmanef.com"));await page.waitForTimeout(50);assert.equal((await page.evaluate(() => window.calls)).filter(call => call.method === "ui/open-link").length, opensBeforeAuth, "Nested messages must not trigger external navigation"); assertions++;if (!legacy) {diff --git a/scripts/security-alerts.mjs b/scripts/security-alerts.mjsindex cc91ebea..53bd8dbd 100644--- a/scripts/security-alerts.mjs+++ b/scripts/security-alerts.mjs@@ -1,19 +1,24 @@#!/usr/bin/env node-// Inspect GitHub's actual default-branch findings, not merely successful scan jobs.-// Uses only a repository-scoped Actions token; never emits tokens or secret-scan values.-import fs from "node:fs";-import path from "node:path";--const { GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_STEP_SUMMARY, RUNNER_TEMP } = process.env;+// GitHub's actual findings, not merely a completed analysis. Read-only API calls;+// structured stdout is retained by Actions, without downloading remote content to files.+const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env;const args = process.argv.slice(2);-if (args.some((arg) => arg !== "--inventory")) throw new Error("usage: node scripts/security-alerts.mjs [--inventory]");+let selectedRef;+let inventory = false;+let includeClosed = false;+for (let i = 0; i < args.length; i++) {+ if (args[i] === "--inventory") inventory = true;+ else if (args[i] === "--include-closed") includeClosed = true;+ else if (args[i] === "--ref" && args[i + 1]) selectedRef = args[++i];+ else throw new Error("usage: node scripts/security-alerts.mjs [--inventory] [--ref refs/heads/branch] [--include-closed]");+}+if (selectedRef && (!/^refs\/heads\/[A-Za-z0-9_./-]+$/.test(selectedRef) || selectedRef.includes("..") || selectedRef.endsWith("/"))) {+ throw new Error("An exact branch ref is required");+}if (!GITHUB_TOKEN || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(GITHUB_REPOSITORY ?? "")) {throw new Error("A repository-scoped GitHub token and repository identifier are required");}const root = `https://api.github.com/repos/${GITHUB_REPOSITORY}`;-const directory = fs.mkdtempSync(path.join(RUNNER_TEMP || process.cwd(), "mso-code-scanning-"));-fs.chmodSync(directory, 0o700);-const safe = (value) => String(value ?? "").replace(/[\r\n|<>]/g, " ").slice(0, 500);async function get(suffix) {const response = await fetch(root + suffix, { headers: {Accept: "application/vnd.github+json", Authorization: `Bearer ${GITHUB_TOKEN}`,@@ -32,41 +37,48 @@ async function pages(suffix) {}throw new Error("Pagination incomplete; no clean result may be claimed");}+function descriptor(alert) {+ if (!Number.isSafeInteger(alert.number)) throw new Error("Invalid GitHub alert number");+ return { number: alert.number, state: alert.state, tool: alert.tool?.name,+ rule: { id: alert.rule?.id, severity: alert.rule?.severity, security_severity_level: alert.rule?.security_severity_level, description: alert.rule?.description },+ html_url: alert.html_url, created_at: alert.created_at,+ dismissed_reason: alert.dismissed_reason, dismissed_comment: alert.dismissed_comment,+ location: alert.most_recent_instance?.location };+}try {const repository = (await get("")).value;- const branch = (await get(`/branches/${encodeURIComponent(repository.default_branch)}`)).value;- const ref = `refs/heads/${repository.default_branch}`;- const alerts = await pages(`/code-scanning/alerts?state=open&ref=${encodeURIComponent(ref)}`);+ const ref = selectedRef ?? `refs/heads/${repository.default_branch}`;+ const branchName = ref.slice("refs/heads/".length);+ const branch = (await get(`/branches/${encodeURIComponent(branchName)}`)).value;const recent = await get(`/code-scanning/analyses?ref=${encodeURIComponent(ref)}&per_page=100`);- if (!Array.isArray(recent.value) || !recent.value.length) throw new Error("No scan evidence for the default branch");+ if (!Array.isArray(recent.value) || !recent.value.length) throw new Error("No scan evidence for the selected branch");if (!recent.value.some((scan) => scan.tool?.name === "CodeQL" && scan.commit_sha === branch.commit.sha && !scan.error)) {- throw new Error("CodeQL has not completed successfully for the current default-branch commit");+ throw new Error("CodeQL has not completed successfully for the current selected-branch commit");}+ const alerts = await pages(`/code-scanning/alerts?state=open&ref=${encodeURIComponent(ref)}`);const rows = [];for (const alert of alerts) {- if (!Number.isSafeInteger(alert.number)) throw new Error("Invalid GitHub alert number");- const instances = await pages(`/code-scanning/alerts/${alert.number}/instances?ref=${encodeURIComponent(ref)}`);- rows.push({ number: alert.number, state: alert.state, tool: alert.tool?.name,- rule: alert.rule, html_url: alert.html_url, created_at: alert.created_at,- instances: instances.map(({ ref, analysis_key, category, state, message, location, classifications }) =>- ({ ref, analysis_key, category, state, message, location, classifications })) });+ const row = descriptor(alert);+ const instances = await pages(`/code-scanning/alerts/${row.number}/instances?ref=${encodeURIComponent(ref)}`);+ rows.push({ ...row, instances: instances.map(({ ref, analysis_key, category, state, message, location, classifications }) =>+ ({ ref, analysis_key, category, state, message, location, classifications })) });}+ const closed = includeClosed ? (await pages(`/code-scanning/alerts?state=closed&ref=${encodeURIComponent(ref)}`)).map(descriptor) : [];+ // Detect a concurrent publication before reporting stale findings as current.+ const after = (await get(`/branches/${encodeURIComponent(branchName)}`)).value;+ if (after.commit.sha !== branch.commit.sha) throw new Error("Branch changed during security verification; retry");const report = { capturedAt: new Date().toISOString(), repository: GITHUB_REPOSITORY,- ref, head: branch.commit.sha, openCount: rows.length, alerts: rows,+ ref, head: branch.commit.sha, openCount: rows.length, alerts: rows, closed,recentAnalyses: recent.value.map(({ id, commit_sha, ref, created_at, category, error, tool }) =>- ({ id, commit_sha, ref, created_at, category, error, tool })),- olderAnalysesOmitted: recent.more };- fs.writeFileSync(path.join(directory, "code-scanning.json"), `${JSON.stringify(report, null, 2)}\n`, { mode: 0o600 });+ ({ id, commit_sha, ref, created_at, category, error, tool })), olderAnalysesOmitted: recent.more };+ console.log(`CODE_SCANNING_REF ${ref}`);console.log(`CODE_SCANNING_HEAD ${report.head}`);console.log(`CODE_SCANNING_OPEN ${rows.length}`);for (const alert of rows) console.log(`ALERT ${JSON.stringify(alert)}`);- const summary = ["## Default-branch code scanning", "", `Commit: \`${report.head}\` · **${rows.length} open findings**`, "",- "Analysis completion is not alert clearance. No alert was dismissed or deleted by this read-only job.", "",- "| Alert | Tool | Severity | Rule | Location |", "|---|---|---|---|---|",- ...rows.map((alert) => `| ${alert.number} | ${safe(alert.tool)} | ${safe(alert.rule?.security_severity_level ?? alert.rule?.severity)} | ${safe(alert.rule?.id)} | ${safe(alert.instances[0]?.location?.path)}:${alert.instances[0]?.location?.start_line ?? ""} |`), ""].join("\n");- if (GITHUB_STEP_SUMMARY) fs.appendFileSync(GITHUB_STEP_SUMMARY, summary);- console.log(`REPORT_DIRECTORY ${directory}`);- process.exitCode = rows.length && !args.includes("--inventory") ? 1 : 0;+ for (const alert of closed) console.log(`CLOSED_ALERT ${JSON.stringify(alert)}`);+ console.log(`CODE_SCANNING_REPORT ${JSON.stringify(report)}`);+ console.log("No alert was dismissed or deleted by this read-only verification.");+ process.exitCode = rows.length && !inventory ? 1 : 0;} catch (error) {console.error(`INCOMPLETE: ${error.message}`);process.exitCode = 2;diff --git a/scripts/security-alerts.test.ts b/scripts/security-alerts.test.tsindex d13b99d9..c979ecfd 100644--- a/scripts/security-alerts.test.ts+++ b/scripts/security-alerts.test.ts@@ -1,5 +1,5 @@import { spawnSync } from "node:child_process";-import { mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";+import { mkdtempSync, rmSync } from "node:fs";import { tmpdir } from "node:os";import path from "node:path";import { afterEach, describe, expect, it } from "vitest";@@ -21,9 +21,8 @@ function run(options: { count?: number; denied?: boolean; noAnalysis?: boolean;};await import(${JSON.stringify(path.join(process.cwd(), "scripts/security-alerts.mjs"))});`;const result = spawnSync(process.execPath, ["--input-type=module", "-e", stub], { encoding: "utf8", timeout: 10_000,env: { NODE_ENV: "test", PATH: process.env.PATH, GITHUB_TOKEN: "synthetic-test-value", GITHUB_REPOSITORY: "example/repository", RUNNER_TEMP: root } });- const reportDir = readdirSync(root).find((name) => name.startsWith("mso-code-scanning-"));- let report: { openCount: number; alerts: unknown[] } | undefined;- try { report = JSON.parse(readFileSync(path.join(root, reportDir ?? "", "code-scanning.json"), "utf8")); } catch { /* failed evidence is expected in negative cases */ }+ let report: { openCount: number; alerts: unknown[]; ref: string } | undefined;+ try { report = JSON.parse(result.stdout.split("\n").find((line) => line.startsWith("CODE_SCANNING_REPORT "))!.slice("CODE_SCANNING_REPORT ".length)); } catch { /* failed evidence is expected in negative cases */ }return { ...result, report };}describe("GitHub open-alert evidence", () => {