Skip to content

fix: 收紧 Relay 安全与交付边界 - #4

Merged
damingishere-coder merged 1 commit into
mainfrom
codex/fix-relay-security-boundary
Aug 31, 2026
Merged

fix: 收紧 Relay 安全与交付边界#4
damingishere-coder merged 1 commit into
mainfrom
codex/fix-relay-security-boundary

Conversation

@damingishere-coder

Copy link
Copy Markdown
Owner

改动摘要

  • 将 Relay processing 重领改为数据库条件更新;并发请求只有一个可取得有效 claim token
  • 对公开填写写请求执行 256 KiB 有界流式读取,未知或伪造 Content-Length 不能触发无上限缓冲
  • 本机 Relay 客户端拒绝向非回环 HTTP 地址发送 Bearer,仅允许 HTTPS 或本机回环 HTTP
  • Synology Relay 宿主机端口改为只绑定 127.0.0.1:18081
  • 明确使用 Tailscale Serve 8443 提供 tailnet 内 HTTPS,公网 Funnel 443 继续只进入 Gateway
  • CloudBase 静态托管同时覆盖 /f/*/fill/*

验证结果

  • 后端:160 passed(3 条既有 Python 3.12 SQLite 日期适配器弃用警告)
  • 前端:113 passed
  • ESLint:通过
  • TypeScript 类型检查:通过
  • 管理端构建:通过(保留既有 618 kB 主 chunk 建议)
  • 公网端构建:通过
  • Synology Compose 渲染:通过;Gateway/Relay 均只绑定 127.0.0.1,PostgreSQL 无宿主机端口
  • git diff --check:通过

部署风险与顺序

本 PR 只修改仓库,未操作真实 NAS、Tailscale、防火墙、CloudBase 或生产数据库。合并不等于已经完成设备侧切换。

设备侧部署时必须按受控窗口完成:

  1. 更新 Synology Relay/Gateway 配置,使 Relay 只绑定回环
  2. 在 NAS 配置 Tailscale Serve 8443,并确认 tailnet ACL 只允许指定 Windows 来源
  3. 验证 HTTPS 证书和 /api/ready
  4. 把 Windows CATCARE_INTAKE_RELAY_URL 切换为 https://<NAS-tailnet-DNS>:8443
  5. 确认 NAS LAN 的 18081 已不可达,再恢复同步

若只完成其中一部分,客户登记同步会暂时不可用。设备侧变更和公网更新仍需用户另行确认,本 PR 不执行。

回滚

  • 应用代码可回滚本提交;Relay CAS 与请求体门禁没有数据库迁移
  • 设备侧回滚应先停止业务同步,再撤销 Serve/恢复旧容器配置;不得把明文 LAN HTTP 当作长期方案

范围

这是整改计划 PR2。备份结果识别、脱敏 Worker readiness 和 UI 可见回归留给 PR3。本 PR 不自动合并,等待用户确认。

@damingishere-coder
damingishere-coder merged commit ac332ea into main Aug 31, 2026
2 checks passed
@damingishere-coder
damingishere-coder deleted the codex/fix-relay-security-boundary branch August 31, 2026 06:06
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