Skip to content

security(tauri): 为桌面 WebView 建立最小 CSP 或记录关闭边界 #226

Closed

Description

@appergb

背景

#216 中把 “Tauri CSP 关闭” 和 QA markdown / IPC 风险混在一起。这个 issue 只跟踪 Tauri CSP 策略:要么建立最小 CSP,要么写清楚关闭 CSP 的边界和理由。

现状

openless-all/app/src-tauri/tauri.conf.json 中:

"security": {
  "csp": null
}

桌面 app 不是普通网页,但 OpenLess 前端存在:

  • Tauri IPC surface
  • QA markdown 渲染
  • provider credential 读取/写入路径
  • shell/updater/autostart 等 plugin capability

因此 CSP 关闭应当是明确决策,而不是默认遗留。

代码证据

  • openless-all/app/src-tauri/tauri.conf.json:68-70
  • openless-all/app/src-tauri/capabilities/default.json:5-20

建议修复

  • 建立可运行的最小 CSP,至少限制 script-src、object-src、base-uri,并根据实际 provider/API 请求补齐 connect-src。
  • 如果某些 Tauri/WebView 限制导致短期不能启用 CSP,在 tauri.conf.json 附近和安全文档中写明关闭原因、风险边界和重新开启条件。
  • QA markdown XSS 的 sanitizer 修复应独立进行;CSP 作为纵深防御,不替代 sanitizer。

验收标准

  • csp: null 不再是无说明的默认状态。
  • 如果启用 CSP,主窗口、capsule、QA 窗口均可正常启动和调用必要 IPC。
  • provider 校验、模型列表请求、更新检查等必要网络路径不被误拦。
  • CSP 不能放开到等同无保护;如需 unsafe-*,必须有局部理由。

关联

Activity

  1. added
    bug
    on May 4, 2026
  2. H-Chris233 commented on May 8, 2026

    @H-Chris233
    Collaborator

    认领

  3. self-assigned this
    on May 8, 2026
  4. added
    enhancement
    and removed
    bug
    on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions