Skip to content

fix(security): harden review findings#508

Open
dongmucat wants to merge 1 commit into
mainfrom
fix/security-review-hardening
Open

fix(security): harden review findings#508
dongmucat wants to merge 1 commit into
mainfrom
fix/security-review-hardening

Conversation

@dongmucat

@dongmucat dongmucat commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

变更内容

  • 收紧全局 namespace 成员列表接口权限,仅平台管理员可查看。
  • 修复 Session + Bearer 混用时的 CSRF 判定:只有无客户端 session 标识的纯 Bearer 请求才跳过 CSRF。
  • 收窄 OAuth Device Flow 的 CSRF 例外,只覆盖精确的设备授权 POST 端点。
  • scanner 禁用时对 PUBLIC / NAMESPACE_ONLY 发布 fail-closed,避免跳过安全扫描后公开发布。
  • 增加 CLI 下载大小限制和 ZIP central directory 限制,降低大包/压缩包资源消耗风险。
  • release/staging 配置中强制校验匿名下载 cookie secret,拒绝占位值和弱值。
  • 本地 dev server 默认注入 scanner upload 模式,并补齐 scanner 配置文档。
  • Vite dev server 默认绑定 loopback;补充 dependency-review / CodeQL / 脚本回归 guardrail。
  • 放宽 3 个慢 E2E spec 的 describe timeout,降低远端真实服务 E2E 偶发超时风险。

背景

这些改动用于修复 2026-06-10-security-review.pdf 中对最新 main 分支仍需处理的安全审查发现,并补齐对应的回归测试和 CI 防护。

实现说明

  • 在路由安全策略中区分纯 API token 请求和携带客户端 session 的浏览器请求,避免 Bearer header 被用来绕过浏览器 CSRF。
  • 新增 SecurityConfigTestRouteSecurityPolicyRegistryTestLocalAuthControllerTest 覆盖 CSRF/session/Bearer 边界。
  • 对匿名下载 secret 增加运行时 denylist 与长度校验,并补充 release 配置校验脚本测试。
  • 更新本地 profile 和 Makefile,使本地后端默认走 scanner upload 流程。
  • 更新 scanner 配置文档,明确 scanner disabled 时公开发布会 fail-closed。

验证

  • make test-backend-app:536 tests,0 failures / 0 errors。
  • make typecheck-web 通过。
  • make lint-web 通过。
  • bash scripts/tests/publish-cli-test.sh 通过。
  • bash scripts/tests/validate-release-config-test.sh 通过。
  • bash scripts/tests/dev-web-host-test.sh 通过。
  • bash scripts/tests/workflow-security-test.sh 通过。
  • pnpm exec playwright test --list e2e/skill-version-compare.spec.ts e2e/skill-subscription.spec.ts e2e/public-skill-detail-anonymous.spec.ts 通过。
  • git diff --check 通过。

远端 CI

  • Server Unit Tests:通过。
  • Web Build And Test:通过。
  • Docs Build:通过。
  • Script Regression Tests:通过。
  • E2E (Real Services):通过。
  • CLI ubuntu / macOS / windows:通过。
  • Dependency Review:通过。
  • DCO / CLA:通过。
  • CodeQL:在当前 PR workflow 中按配置跳过,不是失败。

影响

  • 对正常 API token CLI 请求保持兼容。
  • 对带 session cookie 的浏览器写请求继续强制 CSRF。
  • scanner 被禁用时,公开/namespace 可见发布将按安全策略失败关闭。

@dongmucat dongmucat force-pushed the fix/security-review-hardening branch 2 times, most recently from 20d617d to a4d94cb Compare June 11, 2026 11:51
Signed-off-by: dongmucat <1127093059@qq.com>
@dongmucat dongmucat force-pushed the fix/security-review-hardening branch from a4d94cb to 40d7de8 Compare June 12, 2026 06:40
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.

1 participant