Skip to content

fix(security): remediate CodeQL alerts#572

Open
dongmucat wants to merge 2 commits into
mainfrom
fix/codeql-alerts
Open

fix(security): remediate CodeQL alerts#572
dongmucat wants to merge 2 commits into
mainfrom
fix/codeql-alerts

Conversation

@dongmucat

Copy link
Copy Markdown
Collaborator

概述

修复当前 9 个打开的 CodeQL code scanning alerts,并把旧 CLI loopback token 回调迁移到设备授权入口,避免浏览器端生成或重定向携带 token。

变更内容

  • 使用 SnakeYAML SafeConstructorLoaderOptions 加固 SKILL.md frontmatter 解析,并在 loose fallback 前拒绝显式 YAML tag。
  • 将 pre-publish secret placeholder 判断从通配正则改为线性 marker 检查,避免 ReDoS 风险。
  • 将公开 label security chain 限定为 GET /api/v1/labelsGET /api/web/labels,并移除该 chain 上的 CSRF disable。
  • 停用旧 /cli/auth token redirect 页面,新增受登录保护的 /device 路由作为 CLI 设备授权入口。
  • 修复 CLI skill name suffix 判断,并将告警涉及的 E2E 随机后缀改为 randomUUID
  • 修正 staging 设备授权 URI 覆盖,并让 staging web 使用本地构建镜像,避免本机 bind mount 权限导致 nginx 启动失败。

测试覆盖

  • 新增 YAML explicit tag 拒绝、anchor tag 拒绝、普通 !important 文案兼容测试。
  • 新增长 placeholder validator 测试。
  • 新增 public label matcher GET/POST 测试。
  • 更新 cli-auth 单测和 Playwright 覆盖。
  • 新增 /device 提交单测,覆盖用户码归一化、CSRF header、失败消息。
  • 新增 CLI parser namespace--slug-- 回归测试。

质量门禁

  • make test-backend-app
  • make typecheck-web
  • make lint-web
  • make test-frontend
  • cd cli && bun test
  • cd web && pnpm exec playwright test e2e/cli-auth.spec.ts e2e/register-email-required.spec.ts
  • make test-e2e-smoke-frontend
  • make staging
  • git diff --check

安全考虑

  • 不再在浏览器端创建 CLI token 或通过外部 redirect URI/hash 传递 token。
  • YAML 解析仅使用 safe constructor,并阻断显式 tag fallback。
  • Public label chain 不再覆盖写请求,也不再关闭 CSRF。
  • 测试随机值改为 randomUUID,清理 CodeQL insecure randomness alerts。

相关 Issue

测试说明

本地门禁全部通过;PR 后继续等待 GitHub checks 和 security.yml CodeQL workflow。

Signed-off-by: dongmucat <1127093059@qq.com>
@dongmucat dongmucat force-pushed the fix/codeql-alerts branch from 68e417f to f4fec3f Compare July 6, 2026 07:44
Signed-off-by: dongmucat <1127093059@qq.com>
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