fix(security): 修复安全审计的 P1/P2/P3 项,含全局复查新发现的两处越权与外跳
P1: - 外链图片:markdown 渲染层只放行站内与自有 CDN 图片。配置里的 image_bucket_cdn_host 常写成 host/path,统一归一化后再比对,避免把自家图一起剥掉 - 密码:页面/提问密码最小 6 位;密码比对挪到验证码之后;页面密码失败锁定 5 次/10 分钟 - 客户端 IP:CF-Connecting-IP / EO-Client-IP 只在 TCP 对端可信(回环或 trusted_proxies) 时采信,公网对端带来的权威头一律忽略 P2/P3: - 跳转参数收敛到 shared.SafeRedirectTarget:拒反斜杠与控制字符(url.Parse 会把 %0d%0a 解成 CRLF,伪造 Location),最后再用 path.Clean 验一次前缀 - 注册不再暴露「邮箱已注册 / 已停用」:与全新注册共用同一个成功出口,只在日志留痕 - CSP:默认 enforce,白名单由配置派生,覆盖 umami(运行时注入)、Turnstile 与 按 sentry_dsn 条件放行的 Sentry CDN - /user 与 /_ 下发 no-store;补 X-XSS-Protection、Permissions-Policy,并把安全头前移到 静态资源中间件之前(原先静态文件拿不到 nosniff/HSTS) - 封禁事实落库 ban_records;429 统一带 Retry-After 与本地化文案 - token 比较改常量时间;探索页页码上限;JSON 响应显式 Content-Type 全局复查补的两处: - 私聊 SendMessage 的 POST 缺 conv.OwnerID 校验,被拉黑者可换 domain 继续发消息 - 页面密码 next 与登录 to 同源的反斜杠外跳 验收:verify_p1_fixes 4/4、verify_round2 19/19、verify_page_next 6/6、 verify_chat_owner 3/3(含变异对照);单测与 go build ./... 全通过。
This commit is contained in:
+21
-17
@@ -16,21 +16,22 @@ var zhCNDict = map[string]string{
|
||||
"nav.lang": "语言",
|
||||
|
||||
// 通用
|
||||
"common.login": "登录",
|
||||
"common.forgot": "忘记密码",
|
||||
"common.submit": "提交",
|
||||
"common.cancel": "取消",
|
||||
"common.save": "保存",
|
||||
"common.close": "关闭",
|
||||
"common.delete": "删除",
|
||||
"common.moveUp": "上移",
|
||||
"common.moveDown": "下移",
|
||||
"common.share": "分享",
|
||||
"common.verifying": "验证中...",
|
||||
"common.submitting": "提交中...",
|
||||
"common.uploading": "上传中...",
|
||||
"common.lang": "语言",
|
||||
"common.menu": "菜单",
|
||||
"common.login": "登录",
|
||||
"common.forgot": "忘记密码",
|
||||
"common.submit": "提交",
|
||||
"common.cancel": "取消",
|
||||
"common.save": "保存",
|
||||
"common.tooManyRequests": "请求过于频繁,请稍后再试。",
|
||||
"common.close": "关闭",
|
||||
"common.delete": "删除",
|
||||
"common.moveUp": "上移",
|
||||
"common.moveDown": "下移",
|
||||
"common.share": "分享",
|
||||
"common.verifying": "验证中...",
|
||||
"common.submitting": "提交中...",
|
||||
"common.uploading": "上传中...",
|
||||
"common.lang": "语言",
|
||||
"common.menu": "菜单",
|
||||
|
||||
"common.pleaseWait": "请稍候...",
|
||||
"common.backHome": "返回首页",
|
||||
@@ -182,9 +183,9 @@ var zhCNDict = map[string]string{
|
||||
"admin.tagInputHint": "输入后按回车或逗号添加",
|
||||
"admin.tagInputDuplicate": "已存在,已忽略",
|
||||
"admin.pagePassword": "页面访问密码",
|
||||
"admin.pagePasswordHint": "设置访问密码(留空则关闭)",
|
||||
"admin.pagePasswordHint": "设置访问密码(6–30 位,留空则关闭)",
|
||||
"admin.askPassword": "提问密码",
|
||||
"admin.askPasswordHint": "设置提问密码(留空则关闭)",
|
||||
"admin.askPasswordHint": "设置提问密码(6–30 位,留空则关闭)",
|
||||
"admin.saveProfile": "保存修改",
|
||||
"admin.updated": "更新个人信息成功",
|
||||
"admin.logout": "退出登录",
|
||||
@@ -619,6 +620,7 @@ var zhCNDict = map[string]string{
|
||||
"vote.page.submit": "提交投票",
|
||||
"vote.page.alreadyVoted": "你已参与过该投票,感谢参与!",
|
||||
"vote.page.resultsTitle": "投票结果",
|
||||
"vote.page.anonymousNotice": "匿名投票,每人一票,结果仅供参考。",
|
||||
"vote.page.totalVotes": "总参与",
|
||||
"vote.page.avgRating": "平均分",
|
||||
"vote.page.avgRank": "平均排名",
|
||||
@@ -757,6 +759,7 @@ var zhCNDict = map[string]string{
|
||||
|
||||
// 提问箱页:访客可见(P0)
|
||||
"question.errWrongPassword": "密码错误",
|
||||
"question.errPasswordLocked": "密码错误次数过多,请 %d 分钟后再试",
|
||||
"question.errAskPasswordWrong": "提问密码错误",
|
||||
"question.errLoginRequired": "提问箱的主人设置了仅注册用户才能提问,请先登录。",
|
||||
"question.errSelfChat": "不能给自己发起私聊",
|
||||
@@ -938,6 +941,7 @@ var zhCNDict = map[string]string{
|
||||
"form.profile.name": "昵称不能为空,且不超过 20 个字符",
|
||||
"form.profile.newPassword": "新密码长度不能超过 30 个字符",
|
||||
"form.profile.passwordMax": "密码长度不能超过 30 个字符",
|
||||
"form.profile.passwordLen": "请设置 6 至 30 位的密码",
|
||||
"form.question.content": "问题内容不能为空",
|
||||
"form.question.contentTooLong": "问题内容不能超过 %d 个字符",
|
||||
"form.question.receiveReplyEmail": "请填写有效的电子邮箱地址以接收回复",
|
||||
|
||||
Reference in New Issue
Block a user