Stop advertising the session header no handler reads

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`.
This commit is contained in:
gitea committed 2026-09-30 01:17:12 +08:00
1 parent faf26b4c5b
commit d530f9a47b
5 files changed
+19 -29

No files matched your search

+2 -2
View File
@@ -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
+1 -14
View File
@@ -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",
+5 -12
View File
@@ -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:
+6 -1
View File
@@ -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);
+5
View File
@@ -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");
});
});