Repository navigation
修复第 1 轮(安全):按审查报告修复后端/前端安全问题 - #119
Merged
todosdev[bot] merged 3 commits intoOct 17, 2026
Merged
Conversation
- BE-S1/FE-S3: mask smtp_pass/resend_api_key in audit log and settings API; frontend submits secrets only on explicit input - BE-S2/BE-R1: fail closed on STARTTLS decline; add 10s timeouts to SMTP I/O and Resend fetch - FE-S1/FE-S2: BroadcastChannel signals only (no token); whitelist http/https before rendering destination_url - BE-S3/S4: per-user token_version revokes all sessions on password change/reset and admin disable/demote (new migration 0002) - BE-S5: setup endpoint to POST + X-Setup-Secret header, constant-time compare, per-IP rate limit; docs updated - BE-S6: email+IP login rate limit; IP rate limits for register and forgot-password Checkpoint: MaC98N20lH3HRjjCAndsB
- BE-S1: only mask non-empty secret settings so empty values stay readable as "not set" - BE-S1/FE-S3: backend drops empty/*** secret fields so a direct API call can't wipe or corrupt credentials - FE-S1: serialize cross-tab refresh via Web Locks and drop the init refresh broadcast to avoid refresh-token rotation races Checkpoint: u70S3COfi5zwWtBeoH63n
…4-7ba7-aa5f-decadc808241
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
token_version会话吊销、setup 端点加固、email+IP 双维度限流。users.token_version字段(只加列、向后兼容),用于密码修改/重置与 admin 停用/降权时即时吊销该用户全部会话。Changes
后端
apps/workerroutes/admin.ts:smtp_pass/resend_api_key在审计日志与GET /settings中脱敏(仅非空值返回***);PUT /settings丢弃空值/***的密钥字段,避免直接调 API 清空或把掩码当密码写库。lib/smtp.ts+lib/email.ts:STARTTLS 被拒即中断(不再降级明文);SMTP 读写与 Resend fetch 加 10s 超时。lib/jwt.ts、middleware/auth.ts、routes/auth.ts、types.ts:access/refresh token 内嵌tv(token_version),每个受保护请求与 refresh 时比对;改密/重置/admin 停用/降权自增token_version即全端吊销;requireAuth/requireAdmin改为从 DB 读role。lib/kv.ts、routes/auth.ts:登录改 email+IP 双维度限流,/register、/forgot-password新增 IP 维度限流(IP 取cf-connecting-ip)。routes/setup.ts+lib/crypto.ts:setup 端点改为POST /setup+X-Setup-Secret请求头,常量时间比较,按 IP 限流;新增内联schema_v2。migrations/0002_token_version.sql:新增迁移,ALTER TABLE users ADD COLUMN token_version ...,与setup.ts的schema_v2内容/编号一致。前端
apps/webcontexts/AuthContext.tsx、api/client.ts:BroadcastChannel 只传refresh/logout信号、不传 token;各标签页凭 HttpOnly cookie 自行 refresh,并用 Web Locks 跨标签页串行化,避免 refresh-token 轮换竞态。lib/utils.ts、components/link-table-cells.tsx、pages/dashboard/AnalyticsPage.tsx:新增isSafeUrl(),渲染destination_url前做 http/https 协议白名单。pages/admin/AdminSettingsPage.tsx:密钥输入框不再回填,仅在管理员显式输入时提交。文档
README.md、README.zh-CN.md、CLAUDE.md:同步 setup 端点调用说明与安全说明。Testing
pnpm check、pnpm typecheck、pnpm build全部通过。部署注意事项
tvclaim,与库内默认0不匹配)。