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(workflows): allow inbound webhook trigger boundary

Rahman3b2743364daf
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 793c9c12..ae6e3a98 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` allow inbound webhook trigger boundary
- `workflows` honor responsive shell modal policy
- `workflows` compact graph mcp surface
- `workflows` complete cli and release gates
diff --git a/proxy-machine-protocol.test.ts b/proxy-machine-protocol.test.ts
index 6f0656ff..4af3f3d1 100644
--- a/proxy-machine-protocol.test.ts
+++ b/proxy-machine-protocol.test.ts
@@ -158,4 +158,27 @@ describe("single-origin mode (template unset) is unchanged", () => {
expect(res.status).toBe(404);
expect(res.headers.get("x-middleware-rewrite")).toBeNull();
});
+
+ it("allows cross-origin workflow webhook triggers while keeping workflow management CSRF-protected", async () => {
+ const proxy = await loadProxy("");
+ const webhook = await proxy(
+ req("mso.example.com", "/api/v1/workflows/webhook/graph-1/hook", {
+ method: "POST",
+ headers: { "sec-fetch-site": "cross-site", "content-type": "application/json" },
+ body: JSON.stringify({ event: "smoke" }),
+ }),
+ );
+ expect(webhook.status).toBe(200);
+
+ const management = await proxy(
+ req("mso.example.com", "/api/v1/workflows", {
+ method: "POST",
+ headers: { "sec-fetch-site": "cross-site", "content-type": "application/json" },
+ body: JSON.stringify({ action: "create" }),
+ }),
+ );
+ expect(management.status).toBe(403);
+ expect(await management.json()).toEqual({ error: "cross_origin_blocked" });
+ });
+
});
diff --git a/proxy.ts b/proxy.ts
index c2209f1a..d782b627 100644
--- a/proxy.ts
+++ b/proxy.ts
@@ -305,6 +305,11 @@ export async function proxy(request: NextRequest) {
const isA2A =
pathname === "/a2a/v1" || pathname === "/.well-known/agent-card.json";
const isMachineProtocol = isMcp || isA2A;
+ // Workflow webhook triggers are intentionally inbound machine endpoints. Their
+ // own route enforces method, rate, body bounds, idempotency and optional bearer
+ // auth; browser-cookie CSRF proof would make legitimate external webhooks
+ // impossible and is not their authentication authority.
+ const isWorkflowWebhook = pathname.startsWith("/api/v1/workflows/webhook/");
const isApi = pathname.startsWith("/api/") || isMachineProtocol || (["/integrations", "/integrations/manager", "/integrations/embed"].includes(pathname) && ["GET", "HEAD"].includes(request.method));
// The historical same-origin bridge is permanently closed. noVNC is executable
// third-party code and is served only from its reserved split-origin host above.
@@ -318,6 +323,7 @@ export async function proxy(request: NextRequest) {
MUTATING.has(request.method) &&
isApi &&
!isMachineProtocol &&
+ !isWorkflowWebhook &&
pathname !== "/api/integrations/setup" &&
crossOriginMutation(request)
)