Skip to content

fix(console): send browser hardening headers on the operator console - #650

Merged
caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
guyu233:fix/console-security-headers
Dec 4, 2026
Merged

caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
guyu233:fix/console-security-headers

Conversation

@guyu233

@guyu233 guyu233 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Problem

The authenticated operator console and its embedded SPA assets were served without basic browser hardening headers. Because the console and the public gateway share one mux, the headers must be scoped to the console only.

Change

  • setUISecurityHeaders adds X-Content-Type-Options: nosniff, X-Frame-Options: DENY, and Referrer-Policy: no-referrer.
  • withUISecurityHeaders wraps the embedded webui.Handler() used for /assets/, the favicons, the manifest, and the SPA fallback.
  • The OpenAI/Anthropic /v1/* endpoints are untouched and keep their protocol-only response surface.

Validation

  • go vet ./internal/server/...
  • go test ./internal/server/... -run TestConsoleUISendsSecurityHeaders -v
  • git diff --check

Add X-Content-Type-Options: nosniff, X-Frame-Options: DENY, and Referrer-Policy: no-referrer to console HTML, the SPA fallback, and embedded assets. The public OpenAI/Anthropic gateway endpoints keep their protocol-only response surface.

@caigee-cmd caigee-cmd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已审:控制台加固头只加在 /assets/、favicon、manifest 和 SPA 回退的 HTML 响应上,/v1/* 网关端点不受影响(本地逐路径验证过)。新增测试覆盖 /、/login、/assets/。CI 全绿。可以合;PR 只落后 main 一个提交(#649,store 改动),无冲突。

小建议(不阻塞):未知路径的 404(http.NotFound)和 /api/* 控制台接口没有这几个头,可以后续再补。

@caigee-cmd
caigee-cmd merged commit 5198391 into caigee-cmd:main Dec 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants