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.

test(security): exercise webhook admission with explicit proxy trust

Abdurrahman Fakhrul34b697985f38
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 1b9665be..0f099034 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Tests**
+- `security` exercise webhook admission with explicit proxy trust
- `auth` isolate default proxy policy from host configuration
## 2026-10-09
diff --git a/lib/channels/webhook-admission.test.ts b/lib/channels/webhook-admission.test.ts
index d068e522..ba662c63 100644
--- a/lib/channels/webhook-admission.test.ts
+++ b/lib/channels/webhook-admission.test.ts
@@ -1,12 +1,21 @@
-import { expect, it, vi } from "vitest";
+import { afterEach, expect, it, vi } from "vitest";
import { randomUUID } from "node:crypto";
+afterEach(() => vi.unstubAllEnvs());
it("bounds ID/IP churn without evicting the global ingress budget", async () => {
vi.resetModules();
+ vi.stubEnv("OS_TRUSTED_PROXY_HOPS", "1");
const { admitChannelWebhook } = await import("./webhook-admission");
const { rateLimitedUntrusted } = await import("@/lib/host/rate-limit");
- for (let n = 0; n < 600; n++) admitChannelWebhook(new Request("https://host.test", { headers: { "x-forwarded-for": `spoof-${n}` } }), randomUUID());
+ for (let n = 0; n < 600; n++) admitChannelWebhook(new Request("https://host.test", { headers: { "x-forwarded-for": `198.51.${Math.floor(n / 250)}.${n % 250}` } }), randomUUID());
for (let n = 0; n < 5000; n++) rateLimitedUntrusted(`unrelated:${n}`, 1, 60_000);
expect(() => admitChannelWebhook(new Request("https://host.test"), randomUUID())).toThrow("rate_limited");
expect(() => admitChannelWebhook(new Request("https://host.test"), "arbitrary-id")).toThrow("channel_not_found");
});
+it("rejects rotating forwarding headers as source attribution without explicit proxy trust", async () => {
+ vi.resetModules();
+ vi.stubEnv("OS_TRUSTED_PROXY_HOPS", "0");
+ const { admitChannelWebhook } = await import("./webhook-admission");
+ for (let n = 0; n < 60; n++) admitChannelWebhook(new Request("https://host.test", { headers: { "x-forwarded-for": `198.51.100.${n}` } }), randomUUID());
+ expect(() => admitChannelWebhook(new Request("https://host.test", { headers: { "x-forwarded-for": "203.0.113.9" } }), randomUUID())).toThrow("rate_limited");
+});