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(workflows): isolate external editors from cockpit session cookies
Rahmancc8ad97bdb88
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex a5ba423f..0a1bd0cf 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `workflows` isolate external editors from cockpit session cookies- `workflows` keep runtime registry out of deployment tracing- `security` apply existing ZAP informational policy explicitly- `security` require executed passive scan evidencediff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex b0b4b1c5..5ea559a7 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,19 @@+## 2026-09-18 — Keep external editor links outside the cockpit session-cookie scope++The pending external-editor review exposed a domain-cookie leak: different origins can+still receive the same session cookie. A new shared surface policy reuses the validated+session-cookie authority and also accounts for host-only cookies across different ports.+External Workflow entries that would receive cockpit credentials now remain visible as+blocked metadata but expose no iframe, editor link or login URL. The same unsafe entries+are omitted from the MCP Page catalogue and cannot be resolved as Page routes. Registry+approval never grants cookie trust; exact cockpit links remain remote-only. No cookie,+TLS, CSP, same-origin or role protection is relaxed and provider sessions are untouched.++Regression tests reproduce the previous unsafe URLs before the fix and cover domain/host+scope, leading-dot/case normalization, suffix lookalikes, remote-only links, runtime policy+refresh and shared readers. The browser journey additionally verifies the blocked panel+and zero unsafe requests rather than interpreting a hidden iframe as sufficient isolation.+## 2026-09-18 — Reviewed workflow provider tabs- Keep the native automation/session editor unchanged and mounted while switching to external workflow editors such as n8n. The new wrapper consumes explicit workflow placements in the existing owner-reviewed surface registry, not app-store HTML or credential values.diff --git a/docs/WORKFLOW-GRAPH.md b/docs/WORKFLOW-GRAPH.mdindex a7e333bd..5a97449f 100644--- a/docs/WORKFLOW-GRAPH.md+++ b/docs/WORKFLOW-GRAPH.md@@ -224,3 +224,13 @@ MSO targets **core self-hosted workflow parity**, not n8n's SaaS business surfac## Organization seat routingOrganization is not owned by Workflow Graph. An `agent` node may set `orgSeatId`; at execution time MSO resolves that seat from the private Organization registry and routes to its current Project Agent, Local Agent, or A2A target. This indirection lets a workflow say “send to the CTO seat” without duplicating which concrete agent currently fills that seat. Direct project-bound Agent nodes remain backward compatible. See [`ORGANIZATION.md`](./ORGANIZATION.md).++### External editor credential isolation++Different origins do not by themselves isolate cookies. Reviewed external editors must+be outside `OS_SESSION_COOKIE_DOMAIN` and must not reuse a cockpit hostname on another+port, including when cookies are host-only. MSO blocks both framing and editor/login links+for colliding destinations and shows the configuration reason. Shared MCP Page discovery+also excludes them. Use a distinct cookie-isolated editor hostname; registry review is not+a credential-sharing exception. Native managed-app/browser proxy routes keep their separate+existing authentication boundaries and are not granted trust by a registry entry.diff --git a/frontend/slices/workflows/components/workflow-embed-panel.test.tsx b/frontend/slices/workflows/components/workflow-embed-panel.test.tsxnew file mode 100644index 00000000..fa91f6a1--- /dev/null+++ b/frontend/slices/workflows/components/workflow-embed-panel.test.tsx@@ -0,0 +1,16 @@+import { describe, expect, it } from "vitest";+import { renderToStaticMarkup } from "react-dom/server";+import { WorkflowEmbedPanel } from "./workflow-embed-panel";+import type { WorkflowEmbed } from "@/lib/contracts/surface-app";+const app: WorkflowEmbed = { id: "editor", title: "Editor", origin: "https://editor.example.test", description: "", renderer: "iframe", sandbox: "allow-scripts", url: "https://editor.example.test/", loginUrl: "https://editor.example.test/login" };+describe("blocked external editor rendering", () => {+ it("never renders an iframe, navigation or login URL for a blocked destination", () => {+ const html = renderToStaticMarkup(<WorkflowEmbedPanel app={{ ...app, blocked: true, reason: "Blocked session cookie scope" }} />);+ expect(html).toContain("Blocked session cookie scope");+ expect(html).not.toContain("<iframe"); expect(html).not.toContain('href='); expect(html).not.toContain(app.origin);+ });+ it("fails closed if a destination is missing even without the blocked flag", () => {+ const html = renderToStaticMarkup(<WorkflowEmbedPanel app={{ ...app, url: undefined }} />);+ expect(html).not.toContain("<iframe"); expect(html).not.toContain('href=');+ });+});diff --git a/frontend/slices/workflows/components/workflow-embed-panel.tsx b/frontend/slices/workflows/components/workflow-embed-panel.tsxindex 95c85dc9..764bf99d 100644--- a/frontend/slices/workflows/components/workflow-embed-panel.tsx+++ b/frontend/slices/workflows/components/workflow-embed-panel.tsx@@ -13,6 +13,10 @@ export function WorkflowEmbedPanel({ app }: { app: WorkflowEmbed }) {const timer = setTimeout(() => setSlow(true), 15000);return () => clearTimeout(timer);}, [revision]);+ if (app.blocked || !app.url) return <div className="flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6 text-center text-sm" data-slot="workflow-embed-panel" role="alert">+ <p>{app.reason || "This editor destination is unavailable."}</p>+ <p className="text-xs text-muted-foreground">No editor or login link is opened. Configure a separate cookie-isolated origin before connecting.</p>+ </div>;const reload = () => { setLoading(true); setSlow(false); setRevision((value) => value + 1); };return <div className="flex h-full min-h-0 min-w-0 flex-col" data-slot="workflow-embed-panel"><div className="flex min-h-11 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1.5">diff --git a/frontend/slices/workflows/workspace.tsx b/frontend/slices/workflows/workspace.tsxindex 449084d6..b1810b44 100644--- a/frontend/slices/workflows/workspace.tsx+++ b/frontend/slices/workflows/workspace.tsx@@ -46,6 +46,6 @@ export default function WorkflowsWorkspace(props: AppProps) {<section id={`${prefix}-panel-__native`} role={apps.length ? "tabpanel" : undefined} aria-labelledby={apps.length ? `${prefix}-tab-__native` : undefined} hidden={active !== "__native"} className={cn("min-h-0 min-w-0 flex-1 overflow-hidden", active !== "__native" && "hidden")}><NativeWorkflowsApp {...props}/></section>- {apps.map((app) => <section key={app.id + app.url} id={`${prefix}-panel-${app.id}`} role="tabpanel" aria-labelledby={`${prefix}-tab-${app.id}`} hidden={active !== app.id} className={cn("min-h-0 min-w-0 flex-1 overflow-hidden", active !== app.id && "hidden")}>{visited.includes(app.id) ? <WorkflowEmbedPanel app={app}/> : null}</section>)}+ {apps.map((app) => <section key={app.id + app.origin + String(app.blocked)} id={`${prefix}-panel-${app.id}`} role="tabpanel" aria-labelledby={`${prefix}-tab-${app.id}`} hidden={active !== app.id} className={cn("min-h-0 min-w-0 flex-1 overflow-hidden", active !== app.id && "hidden")}>{visited.includes(app.id) ? <WorkflowEmbedPanel app={app}/> : null}</section>)}</div>;}diff --git a/lib/contracts/surface-app.ts b/lib/contracts/surface-app.tsindex 7055a38f..b37a3eed 100644--- a/lib/contracts/surface-app.ts+++ b/lib/contracts/surface-app.ts@@ -20,6 +20,6 @@ export type SurfaceApp = {export type WorkflowEmbed = {- id: string; title: string; description: string; origin: string; url: string;+ id: string; title: string; description: string; origin: string; url?: string; blocked?: boolean;loginUrl?: string; renderer: SurfaceRenderer; sandbox: string; reason?: string;};diff --git a/lib/host/workflow-embed-cookie.test.ts b/lib/host/workflow-embed-cookie.test.tsnew file mode 100644index 00000000..94466957--- /dev/null+++ b/lib/host/workflow-embed-cookie.test.ts@@ -0,0 +1,39 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { workflowEmbeds, listWorkflowEmbeds, workflowEmbedSettings } from "./workflow-embeds-api";+const cockpit = "https://mso.example.com";+const app = { id: "editor", title: "Editor", description: "Reviewed external editor", origin: "https://n8n.mso.example.com", startPath: "/editor", externalAuthPath: "/signin", renderer: "iframe" as const, presentation: "inline" as const, environment: "production" as const, placements: ["workflows", "mcp-page"] as Array<"workflows" | "mcp-page"> };+afterEach(() => vi.unstubAllEnvs());+describe("external editor session-cookie isolation", () => {+ it.each(["mso.example.com", ".MSO.EXAMPLE.COM", " example.com "])("blocks frames AND navigation under cookie domain %s", domain => {+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", domain);+ const result = workflowEmbeds([app], [cockpit])[0];+ expect(result).toMatchObject({ id: "editor", renderer: "remote", blocked: true });+ expect(result.url).toBeUndefined(); expect(result.loginUrl).toBeUndefined();+ expect(result.reason).toContain("session cookie");+ });+ it("does not offer unsafe top-level navigation for remote-only providers", () => {+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "mso.example.com");+ expect(workflowEmbeds([{ ...app, renderer: "remote" }], [cockpit])[0].url).toBeUndefined();+ });+ it("allows a separately hosted editor and rejects label-prefix tricks", () => {+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "mso.example.com");+ for (const origin of ["https://n8n.example.com", "https://othermso.example.com", "https://mso.example.com.editor.test"]) {+ expect(workflowEmbeds([{ ...app, origin }], [cockpit])[0]).toMatchObject({ renderer: "iframe", url: origin + "/editor" });+ }+ });+ it("protects host-only cookies across different ports without disabling sibling hosts", () => {+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "");+ expect(workflowEmbeds([{ ...app, origin: cockpit + ":8443" }], [cockpit])[0].url).toBeUndefined();+ expect(workflowEmbeds([app], [cockpit])[0].renderer).toBe("iframe");+ expect(workflowEmbeds([{ ...app, origin: cockpit }], [cockpit])[0]).toMatchObject({ renderer: "remote", url: cockpit + "/editor" });+ });+ it("rechecks runtime cookie policy through settings, list and shared Page readers", async () => {+ vi.stubEnv("OS_PUBLIC_ORIGIN", cockpit);+ vi.stubEnv("MSO_SURFACE_APPS_JSON", JSON.stringify([app]));+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "mso.example.com");+ expect((await listWorkflowEmbeds("http://localhost:4005"))[0].url).toBeUndefined();+ expect((await workflowEmbedSettings("http://localhost:4005")).apps[0].url).toBeUndefined();+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "");+ expect((await listWorkflowEmbeds("http://localhost:4005"))[0].renderer).toBe("iframe");+ });+});diff --git a/lib/host/workflow-embeds-api.ts b/lib/host/workflow-embeds-api.tsindex eaa9265a..6e3e07e8 100644--- a/lib/host/workflow-embeds-api.ts+++ b/lib/host/workflow-embeds-api.ts@@ -1,10 +1,16 @@import type { SurfaceApp, WorkflowEmbed } from "@/lib/contracts/surface-app";import { configuredSurfaceApps } from "@/lib/surfaces/config";+import { externalSurfaceSharesSession } from "@/lib/surfaces/cookie-policy";import { surfaceRegistrySnapshot } from "@/lib/surfaces/manage";/** Presentation metadata only. An embed never inherits the cockpit's credentials. */export function workflowEmbeds(apps: SurfaceApp[], cockpitOrigins: string[]): WorkflowEmbed[] {return apps.filter((app) => app.placements?.includes("workflows")).map((app) => {+ if (externalSurfaceSharesSession(app.origin, cockpitOrigins)) return {+ id: app.id, title: app.title, description: app.description, origin: app.origin,+ renderer: "remote" as const, sandbox: app.sandbox ?? "allow-scripts allow-same-origin allow-forms", blocked: true,+ reason: "Blocked: this editor would receive the MSO session cookie. Use an origin outside the cockpit cookie scope.",+ };const ownOrigin = cockpitOrigins.includes(app.origin);return {id: app.id, title: app.title, description: app.description, origin: app.origin,diff --git a/lib/mcp/surface-catalog.ts b/lib/mcp/surface-catalog.tsindex 3332ab07..a0703565 100644--- a/lib/mcp/surface-catalog.ts+++ b/lib/mcp/surface-catalog.ts@@ -1,9 +1,12 @@+import { externalSurfaceSharesSession } from "@/lib/surfaces/cookie-policy";import { mcpUiOrigin, publicMsoOrigin } from "./ui-config";import { configuredSurfaceApps, type SurfaceApp } from "./surface-config";export type { SurfaceApp, SurfaceRenderer, SurfacePresentation, SurfaceEnvironment } from "./surface-config";export async function surfaceApps(): Promise<readonly SurfaceApp[]> {- return (await configuredSurfaceApps()).filter(app => !app.placements || app.placements.includes("mcp-page")).map(app => [mcpUiOrigin(), publicMsoOrigin()].includes(app.origin) ? { ...app, renderer: "remote" as const, reason: "MSO authentication stays in the owner browser." } : app);+ return (await configuredSurfaceApps())+ .filter(app => !externalSurfaceSharesSession(app.origin, [mcpUiOrigin(), publicMsoOrigin()]))+ .filter(app => !app.placements || app.placements.includes("mcp-page")).map(app => [mcpUiOrigin(), publicMsoOrigin()].includes(app.origin) ? { ...app, renderer: "remote" as const, reason: "MSO authentication stays in the owner browser." } : app);}const ROUTE_MAX = 1024;diff --git a/lib/mcp/surface-cookie.test.ts b/lib/mcp/surface-cookie.test.tsnew file mode 100644index 00000000..b687da87--- /dev/null+++ b/lib/mcp/surface-cookie.test.ts@@ -0,0 +1,13 @@+import { afterEach, expect, it, vi } from "vitest";+import { surfaceApps, surfaceAppById, resolveSurfaceRoute } from "./surface-catalog";+afterEach(() => vi.unstubAllEnvs());+it("rejects Page access to an external editor in the cockpit cookie domain", async () => {+ vi.stubEnv("OS_PUBLIC_ORIGIN", "https://mso.example.com");+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", ".mso.example.com");+ vi.stubEnv("MSO_SURFACE_APPS_JSON", JSON.stringify([{ id: "external", title: "External editor", origin: "https://editor.mso.example.com", startPath: "/", renderer: "iframe", presentation: "inline", environment: "production", placements: ["mcp-page"] }]));+ expect(await surfaceApps()).toEqual([]);+ expect(await surfaceAppById("external")).toBeUndefined();+ await expect(resolveSurfaceRoute("/apps/external")).rejects.toThrow("unknown MSO Page app");+ vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "");+ expect((await surfaceApps())[0].id).toBe("external");+});diff --git a/lib/surfaces/cookie-policy.ts b/lib/surfaces/cookie-policy.tsnew file mode 100644index 00000000..fc2a24e1--- /dev/null+++ b/lib/surfaces/cookie-policy.ts@@ -0,0 +1,17 @@+import { sessionCookieDomain } from "@/lib/auth/session-cookie";++/** A different origin is not enough: cookies are domain scoped, never port scoped.+ * Registry review is presentation approval, not permission to receive MSO credentials. */+export function externalSurfaceSharesSession(origin: string, cockpitOrigins: string[]): boolean {+ let target: URL;+ try { target = new URL(origin); } catch { return true; }+ const hostname = (url: URL) => url.hostname.replace(/\.$/, "").toLowerCase();+ const cockpits = cockpitOrigins.flatMap(value => {+ try { return [new URL(value)]; } catch { return []; }+ });+ // Exact cockpit navigation is allowed; consumers still refuse to frame it.+ if (cockpits.some(url => url.origin === target.origin)) return false;+ if (cockpits.some(url => hostname(url) === hostname(target))) return true;+ // Reuse the actual validated cookie-domain authority, including legacy leading dots.+ return sessionCookieDomain(new Request(target, { headers: { host: hostname(target) } })) !== undefined;+}diff --git a/scripts/e2e/workflow-embeds.mjs b/scripts/e2e/workflow-embeds.mjsindex 68f9f6ff..32124fb5 100644--- a/scripts/e2e/workflow-embeds.mjs+++ b/scripts/e2e/workflow-embeds.mjs@@ -96,6 +96,24 @@ try {await expect(page.locator('iframe[title="n8n workflow editor"]')).toHaveCount(0);evidence.push({ ownerDemotion: '403 and frame removed', remoteOnly: 'no iframe' });console.log('PASS remote-only fallback');+ // Cookies have no port isolation: prove a reviewed same-host HTTPS editor is+ // visibly blocked before any frame/login/navigation can send the fixture session.+ const unsafe = new URL(fixture.base); unsafe.protocol = 'https:'; unsafe.port = '4443';+ let unsafeRequests = 0;+ const watchUnsafe = request => { if (request.url().startsWith(unsafe.origin)) unsafeRequests++; };+ page.on('request', watchUnsafe);+ await writeFile(path.join(fixture.dir, 'surface-apps.json'), JSON.stringify([{ ...app, origin: unsafe.origin }]));+ await page.evaluate(() => window.dispatchEvent(new Event('focus')));+ await page.getByRole('tab', { name: 'n8n', exact: true }).click();+ await expect(page.getByRole('alert').filter({ hasText: 'this editor would receive the MSO session cookie' })).toBeVisible();+ await expect(page.locator('iframe[title="n8n workflow editor"]')).toHaveCount(0);+ await expect(page.getByRole('link', { name: 'Open n8n', exact: true })).toHaveCount(0);+ await expect(page.getByRole('link', { name: 'Sign in', exact: true })).toHaveCount(0);+ expect(unsafeRequests).toBe(0);+ page.off('request', watchUnsafe);+ evidence.push({ cookieCollision: 'blocked frame, login and navigation', unsafeRequests });+ console.log('PASS cookie-isolated external editors: no unsafe frame, link or request');+if (liveOrigin) {await writeFile(path.join(fixture.dir, 'surface-apps.json'), JSON.stringify([{ ...app, id: 'live-n8n', origin: liveOrigin, startPath: '/home/workflows' }]));await page.setViewportSize({ width: 1280, height: 900 });