From d530f9a47be612f9e33f2fc6b990677c3b4a3fe3 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Wed, 30 Sep 2026 01:17:12 +0800 Subject: [PATCH] Stop advertising the session header no handler reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The adapter's CORS allow-list offered `X-Seal-Home-Session` and openapi declared it as a `localSession` security scheme required on every operation — while no handler ever consulted the header and the scheme's own description admitted it authenticates nothing. Generated clients would fabricate a token for a check that does not exist, and a browser client sending it could fail a preflight against a header the server no longer offers. Remove the header from the allow-list (it now mirrors the two headers this adapter actually reads), drop the scheme and its `security` requirement, and state the trust model plainly in `info.description` where an API consumer sees it. SECURITY.md keeps the authoritative wording and points at that paragraph instead of at a scheme that no longer exists. The local-adapter stance itself is untouched: no authentication is added, per `.agents/rules/security-posture.md`. --- SECURITY.md | 4 ++-- dist/openapi.json | 15 +-------------- openapi/openapi.yaml | 17 +++++------------ src/http/routes.ts | 7 ++++++- src/http/server.test.ts | 5 +++++ 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 26a88d3..203dd3a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -35,8 +35,8 @@ than described here. `seal-use service start` serve `/api/cli`, `/v1/*` and `/shutdown` on `127.0.0.1:8787` with no token check and `Access-Control-Allow-Origin: *`; the adapter acts with the credentials already stored on the machine. It is a local automation surface. Keep it bound to loopback, and do not - run it on a shared or multi-user host. See the `securitySchemes.localSession` note in - `openapi/openapi.yaml`. + run it on a shared or multi-user host. The OpenAPI document declares no security scheme — it + says so in `info.description` rather than advertising a header nothing checks. - **Self-update and the install script do not verify signatures.** `seal-use update` downloads a release binary and replaces the running executable; `scripts/install.sh` compares `checksums.txt` but only warns on a mismatch. Prefer the direct GitHub source diff --git a/dist/openapi.json b/dist/openapi.json index b03df1b..9a773f9 100644 --- a/dist/openapi.json +++ b/dist/openapi.json @@ -3,7 +3,7 @@ "info": { "title": "seal-use Wrapped API", "version": "0.10.40", - "description": "HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n" + "description": "HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n\nAuthentication: none. The adapter answers every request with the enterprise credentials already\nstored on this machine, and never checks who is calling — so keep it on loopback (the default)\nand never expose the port to a network or an origin you do not control. The full trust model is\nin SECURITY.md, \"Trust model and documented limitations\".\n" }, "servers": [ { @@ -11,11 +11,6 @@ "description": "Local HTTP adapter (`seal-use http`, or the `seal-use service start` daemon). Loopback-only by default." } ], - "security": [ - { - "localSession": [] - } - ], "tags": [ { "name": "Corps", @@ -2777,14 +2772,6 @@ } }, "components": { - "securitySchemes": { - "localSession": { - "type": "apiKey", - "in": "header", - "name": "X-Seal-Home-Session", - "description": "Reserved header. The local adapter does not currently authenticate requests: it acts with\nthe credentials already stored on this machine for the selected enterprise. Keep it bound\nto loopback (`--host 127.0.0.1`) and do not expose the port to a network or an origin you\ndo not control.\n" - } - }, "parameters": { "CorpId": { "name": "corpId", diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index cb689e3..18e70ea 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -19,11 +19,14 @@ info: The same capabilities are reachable through the CLI, and through the optional MCP server when it is enabled. + + Authentication: none. The adapter answers every request with the enterprise credentials already + stored on this machine, and never checks who is calling — so keep it on loopback (the default) + and never expose the port to a network or an origin you do not control. The full trust model is + in SECURITY.md, "Trust model and documented limitations". servers: - url: http://localhost:8787 description: Local HTTP adapter (`seal-use http`, or the `seal-use service start` daemon). Loopback-only by default. -security: - - localSession: [] tags: - name: Corps description: Local enterprise configuration selection. @@ -40,16 +43,6 @@ tags: paths: $ref: ./paths/index.yaml components: - securitySchemes: - localSession: - type: apiKey - in: header - name: X-Seal-Home-Session - description: | - Reserved header. The local adapter does not currently authenticate requests: it acts with - the credentials already stored on this machine for the selected enterprise. Keep it bound - to loopback (`--host 127.0.0.1`) and do not expose the port to a network or an origin you - do not control. parameters: $ref: ./components/parameters.yaml responses: diff --git a/src/http/routes.ts b/src/http/routes.ts index 5eb2216..bb012f7 100644 --- a/src/http/routes.ts +++ b/src/http/routes.ts @@ -45,7 +45,12 @@ export async function handleHttpRequest(req: IncomingMessage, res: ServerRespons // 1. CORS headers res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH"); - res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Seal-Corp, X-Seal-Home-Session"); + // Mirrors the headers this adapter actually consults: `X-Seal-Corp` selects + // the enterprise (`extractCorpId`), `Authorization` is kept because generic + // clients attach it by default. The historic `X-Seal-Home-Session` is gone — + // no handler ever read it, and the adapter has no session to authenticate + // (openapi's info.description states that plainly). + res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Seal-Corp"); if (req.method === "OPTIONS") { res.writeHead(204); diff --git a/src/http/server.test.ts b/src/http/server.test.ts index 131c97e..676db51 100644 --- a/src/http/server.test.ts +++ b/src/http/server.test.ts @@ -102,5 +102,10 @@ describe("HTTP Server", () => { const res = await fetch(`${baseUrl}/v1/corps`, { method: "OPTIONS" }); expect(res.status).toBe(204); expect(res.headers.get("access-control-allow-methods")).toContain("GET"); + const allowHeaders = res.headers.get("access-control-allow-headers") ?? ""; + expect(allowHeaders).toContain("X-Seal-Corp"); + // Advertises only headers a handler reads: the historic reserved session + // header was never consulted, and the openapi no longer claims otherwise. + expect(allowHeaders).not.toContain("X-Seal-Home-Session"); }); });