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): harden credential and A2A boundaries
Abdurrahman Fakhrul4988ac6c1c73
diff --git a/.env.example b/.env.exampleindex 9650ec5f..4ec8fac3 100644--- a/.env.example+++ b/.env.example@@ -278,7 +278,7 @@ OS_SESSION_SECRET=# Set OS_A2A_INBOUND_ENABLED=0 as a kill switch. This publishes /.well-known/agent-card.json and /a2a/v1, but every protocol# call still requires an owner-minted scoped bearer from `mso a2a inbound create`.# OS_A2A_INBOUND_ENABLED=1-# Same-host A2A is enabled by default. Set OS_A2A_ALLOW_LOOPBACK=0 to disable it.+# Same-host A2A is disabled by default. Set OS_A2A_ALLOW_LOOPBACK=1 only for trusted same-host agents.# It permits# HTTP only for 127.0.0.1, ::1, and localhost; RFC1918/LAN/Docker/link-local and# hostnames resolving to private addresses remain blocked. This flag affects A2A only.diff --git a/docs/A2A.md b/docs/A2A.mdindex 912df0ab..3d3067bc 100644--- a/docs/A2A.md+++ b/docs/A2A.md@@ -128,7 +128,7 @@ See [Local Agents](./LOCAL-AGENTS.md) for lifecycle (`ready` / `idle` / `busy` /Durable Local Agent standby does **not** create a second orchestration engine. Once a structured local request is safely claimed, MSO executes it through the same bounded durable-session/A2A task machinery already used by `local_agent_request`; only the host-local mailbox/listener/claim layer is new. Public A2A keeps its own standard authenticated task lifecycle and trust boundary, but both paths converge on the existing bounded agent execution semantics rather than duplicating a model runtime.-The older `mso a2a local ...` and loopback virtual-card helpers remain as compatibility/protocol-testing surfaces for one-shot local delegation. They are not the native live-session transport. `OS_A2A_ALLOW_LOOPBACK=0` can disable those legacy A2A-over-loopback paths without disabling Local Agents.+The older `mso a2a local ...` and loopback virtual-card helpers remain as compatibility/protocol-testing surfaces for one-shot local delegation. They are not the native live-session transport. `OS_A2A_ALLOW_LOOPBACK=1` explicitly enables those legacy A2A-over-loopback paths for trusted same-host agents; Local Agents do not require it.## Outbound peers and credentialsdiff --git a/lib/a2a/network.test.ts b/lib/a2a/network.test.tsindex 1ae801f5..90086b01 100644--- a/lib/a2a/network.test.ts+++ b/lib/a2a/network.test.ts@@ -13,11 +13,10 @@ const resolver =(answers: Array<{ address: string; family: number }>) => async () =>answers;-describe("A2A loopback-only default", () => {- it("allows exact HTTP loopback by default", () => {- expect(- assertA2AUrl("http://127.0.0.1:4555/.well-known/agent-card.json").hostname,- ).toBe("127.0.0.1");+describe("A2A explicit loopback opt-in", () => {+ it("blocks exact HTTP loopback unless explicitly enabled", () => {+ vi.stubEnv(A2A_ALLOW_LOOPBACK_ENV, "");+ expect(() => assertA2AUrl("http://127.0.0.1:4555/.well-known/agent-card.json")).toThrow(/disabled/);});it("supports an explicit kill switch", () => {diff --git a/lib/a2a/network.ts b/lib/a2a/network.tsindex eebb6a33..e3a8c484 100644--- a/lib/a2a/network.ts+++ b/lib/a2a/network.ts@@ -31,7 +31,7 @@ function cleanHost(url: URL): string {}export function a2aLoopbackEnabled(): boolean {- return process.env[A2A_ALLOW_LOOPBACK_ENV] !== "0";+ return process.env[A2A_ALLOW_LOOPBACK_ENV] === "1";}export function isExactA2ALoopbackHost(host: string): boolean {diff --git a/lib/a2a/server.ts b/lib/a2a/server.tsindex 59f85fdc..31d4d83a 100644--- a/lib/a2a/server.ts+++ b/lib/a2a/server.ts@@ -1,5 +1,5 @@import { audit } from "@/lib/host/audit-api";-import { rateLimited } from "@/lib/host/limits-api";+import { rateLimited, rateLimitedUntrusted } from "@/lib/host/limits-api";import { clientIp } from "@/lib/host/request-ip";import { resolveAgentSessionOwnerRef } from "@/lib/agent/session-query";import type { AgentSession } from "@/lib/agent/session-types";@@ -33,7 +33,7 @@ export async function handleA2ARequest(req: Request, capabilities: CapabilityRunreturn a2aJson({ error: "not_found" }, 404);if (req.method !== "POST")return a2aJson({ error: "method_not_allowed" }, 405, { allow: "POST" });- if (rateLimited(`a2a.inbound.ip:${clientIp(req)}`, 120, 60_000))+ if (rateLimitedUntrusted(`a2a.inbound.ip:${clientIp(req)}`, 120, 60_000))return a2aJson({ error: "rate_limited" }, 429, { "retry-after": "60" });const profile = await authenticateA2ARequest(req);if (!profile) return a2aUnauthorized();diff --git a/lib/host/path-credentials.ts b/lib/host/path-credentials.tsindex 4e690111..024ba443 100644--- a/lib/host/path-credentials.ts+++ b/lib/host/path-credentials.ts@@ -6,7 +6,8 @@ import { homeDir, isUnderRoot } from "./path-roots";// off-limits to the FS API. Reading .env.local would leak OS_SESSION_SECRET —// turning one stolen session into the ability to mint cookies forever — and// ~/.mso holds the device allowlist, BYOK key and browser profile (cookies).-// Other projects' .env files stay readable (session = owner, their call).+// Viewer sessions and read-scope clients are not owners: project dotenv files+// have the same credential boundary, independent of the checkout running MSO.const APP_DIR = (() => {try {return realpathSync(process.cwd());@@ -93,7 +94,7 @@ export function isCredentialPath(real: string): boolean {// accounts). Their basename/extension is the reliable marker outside fixed ~/ paths.if (PRIVATE_KEY_NAMES.has(base) && process.env.OS_FS_ALLOW_SENSITIVE !== "1") return true;if (base.toLowerCase().endsWith(".pem")) return true;- return isAppSecret(real);+ return isAppSecret(real) || (base.startsWith(".env") && base !== ".env.example");}// `zip -r` validates the selected top-level names, then walks descendants itself.@@ -105,6 +106,6 @@ export function looseCredentialExcludes(): string[] {: PRIVATE_KEY_BASENAMES.flatMap((name) => [name, `*/${name}`]);// *.pem has historically been a hard credential boundary, independent of the// SENSITIVE_HOME escape hatch; keep that contract while extending id_* safely.- return ["*.pem", ...privateNames];+ return ["*.pem", ".env*", "*/.env*", ...privateNames];}diff --git a/lib/host/paths-credentials.test.ts b/lib/host/paths-credentials.test.tsindex 08e46a96..bd0f658d 100644--- a/lib/host/paths-credentials.test.ts+++ b/lib/host/paths-credentials.test.ts@@ -112,7 +112,7 @@ describe("recursive credential guard", () => {vi.stubEnv("HOME", fakeHome);vi.stubEnv("OS_FS_ALLOW_SENSITIVE", "1");expect(sensitiveExcludes(fakeHome)).toEqual([]);- expect(looseCredentialExcludes()).toEqual(["*.pem"]);+ expect(looseCredentialExcludes()).toEqual(["*.pem", ".env*", "*/.env*"]);expect(isCredentialPath(path.join(fakeHome, "safe", "id_rsa"))).toBe(false);expect(isCredentialPath(path.join(fakeHome, "safe", "deploy.pem"))).toBe(true);expect(() => assertNoSensitiveDescendants(parent)).not.toThrow();