Skip to content

fix(remote-input): 收紧局域网输入配对与依赖安全 - #1431

Open
SipengXie2024 wants to merge 1 commit into
Open-Less:betafrom
SipengXie2024:security/remote-input-hardening
Open

SipengXie2024 wants to merge 1 commit into
Open-Less:betafrom
SipengXie2024:security/remote-input-hardening

Conversation

@SipengXie2024

Copy link
Copy Markdown
Contributor

摘要

修复安全审查中发现的局域网远程输入、模型下载与依赖问题。

修复 / 新增 / 改进

  • 远程输入配对码可被暴力破解(中):原有限速为每 IP 5 次 / 60 秒、全局 20 次 / 60 秒,同一局域网内的攻击者平均约 17 天即可猜中 6 位配对码,之后可向电脑当前光标注入文字。新增「同一配对码累计 100 次错误即锁定」,需在电脑端重新生成配对码才能解锁;正确配对或重新生成会清零计数。猜中概率上限因此为 100 / 10^6。手机端沿用现有的 locked 文案(「请在电脑上重新生成配对码」)。
  • 远程输入监听所有网卡(低):仍绑定 0.0.0.0 以适应网卡变化,但在 accept 阶段只放行 RFC1918 私网与回环来源(与界面展示的访问地址一致),公网、CGNAT、链路本地来源直接断开。
  • 手机页缺少安全响应头(低):所有响应增加 X-Content-Type-Options: nosniff、X-Frame-Options: DENY、Referrer-Policy: no-referrer;首页增加 CSP。内联启动脚本按实际下发内容的 sha256 放行,不使用 unsafe-inline;blob: 用于 app.js 动态构建的 AudioWorklet。
  • 模型下载完整性(低):非本机的明文 http 模型文件必须声明 sha256(https 与本机测试服务不受影响);ZIP 解压按实际写出字节限制大小,并要求与条目头声明一致,防止伪造头部撑满磁盘。
  • 依赖(RustSec / GHSA 公告修复版,仅调整 lock 中对应条目,其余解析结果不变):
    • rustls-webpki 0.103.15 → 0.103.16(RUSTSEC-2026-0382,可能接受已撤销信任的中间证书)
    • webpki-roots / webpki-root-certs 1.0.9 → 1.0.10(RUSTSEC-2026-0381 / 0383)
    • ctutils 0.4.3 → 0.4.4(RUSTSEC-2026-0385)
    • rustix 1.1.5 → 1.1.6(RUSTSEC-2026-0486)
    • zstd 0.13.3 → 0.13.4、zstd-safe 7.3.0 → 7.4.1(RUSTSEC-2026-0391、0395–0406)
    • js-yaml 4.3.0 → 4.3.2(开发依赖,仅测试脚本解析工作流 YAML)

兼容

  • 不包含:
    • rsa 0.9(RUSTSEC-2023-0071,无 0.9 修复版)与 crypto-bigint 0.5:需升级主版本。
    • zip 2.6.1 / 4.6.1:由 tauri-plugin-updater、sherpa-onnx-sys、foundry-local-sdk 间接引入,需上游升级;项目自身的解压路径已使用 zip 9.0.5,并经过路径校验。
    • Android 更新白名单中的 fastgit.cc:现有镜像回退路径仍在使用,且 APK 已用内置公钥做 minisign 验签。
    • glib 0.18、proc-macro-error、zbus 系列的 unsound / unmaintained 公告:均为 Linux GTK 依赖链,需随 Tauri 升级。
  • 对现有用户 / 本地环境 / 构建流程的影响:
    • 通过 Tailscale(100.64/10)等非私网地址连接远程输入将被拒绝。
    • 自建 http 模型镜像需改用 https,或在清单中提供 sha256。

测试计划

  • 命令:cargo fmt --all --check(Rust 1.99)
  • 结果:通过
  • 命令:对三个 Cargo.lock 分别运行 cargo metadata --locked
  • 结果:均通过
  • 命令:node scripts/frontend-test-runner.mjs --platform-only windows,以及 pin-persistence-security-contract、remote-input-*、shared-backend-wire-contract 和所有使用 js-yaml 的合同测试
  • 结果:与本改动相关的合同测试全部通过。ci-performance、release-distribution、release-publication-contract、windows-msi-release-contract 以及缓存预算断言在本机失败,原因均为本机环境:沙箱文件系统 os error 4395、D:\D:\ 路径拼接、PowerShell 受限语言模式。
  • 命令:cargo test -p openless-core --locked、cargo test --locked --manifest-path src-tauri/Cargo.toml --lib
  • 结果:本机沙箱下 rustc 无法删除归档临时目录(os error 4395),未能编译,需依赖 CI 验证。新增单测:exhausted_pin_budget_locks_pairing_until_the_code_is_regenerated、plaintext_remote_model_urls_require_a_checksum、only_private_lan_and_loopback_peers_are_accepted、index_csp_pins_the_served_inline_script_instead_of_allowing_unsafe_inline
  • 证据路径:CI
  • 真机:iPhone Safari / Android Chrome 打开远程输入页,确认录音(AudioWorklet)与 wss 连接在 CSP 下正常

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-13T05:25:39.945056Z
We couldn’t complete this review. Comment @codex review to try again.
cacafac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

- 远程输入:同一配对码累计 100 次错误后锁定,需在电脑端重新生成配对码;
  原有每 IP / 全局 60 秒窗口限速只能拖慢局域网内的 6 位码暴力猜测。
- 远程输入:监听仍绑定 0.0.0.0,但只接受私有局域网与回环来源,
  与界面展示的访问地址一致,公网/CGNAT 来源直接断开。
- 远程输入:手机页增加 nosniff、X-Frame-Options、Referrer-Policy 与 CSP;
  内联启动脚本按实际下发内容的 sha256 放行,不使用 unsafe-inline。
- 本地模型:非本机的明文 http 模型文件必须声明 sha256;
  ZIP 解压按实际写出字节限制大小,并要求与条目头一致。
- 依赖:rustls-webpki 0.103.16、webpki-roots/webpki-root-certs 1.0.10、
  ctutils 0.4.4、rustix 1.1.6、zstd 0.13.4/zstd-safe 7.4.1(RustSec 公告修复版),
  js-yaml 4.3.2(仅测试脚本使用)。

Co-authored-by: AiWork <noreply@aiwork.local>
@SipengXie2024
SipengXie2024 force-pushed the security/remote-input-hardening branch from cacafac to 76124d7 Compare November 16, 2026 03:59
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