security: 为 Tauri WebView 启用最小 CSP#359
Merged
Merged
Conversation
The desktop WebView no longer runs with an unexplained disabled CSP. The policy keeps scripts self-hosted, permits Tauri IPC and local Vite development connections, keeps provider/update/model networking on the Rust side, and documents the only unsafe allowance for React inline styles used by the existing pixel-aligned UI. Constraint: Issue Open-Less#226 requires csp:null to be replaced or explicitly bounded Constraint: Provider validation, updater checks, and model downloads are Rust-side paths, not frontend fetch allowlist entries Rejected: Keep csp:null with documentation only | weaker defense-in-depth and leaves the WebView effectively unconstrained Confidence: high Scope-risk: narrow Directive: Do not add external provider domains to WebView connect-src unless a frontend fetch path is introduced Tested: npm run build Tested: npm run tauri -- info Tested: cargo check --manifest-path src-tauri/Cargo.toml
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
User description
概述
csp: null改为最小 CSP,避免无说明地关闭纵深防御。docs/tauri-csp.md记录 CSP 边界,说明 provider / updater / 模型下载走 Rust 侧,不在 WebView CSP 放开外部域名。验证
npm run buildnpm run tauri -- infocargo check --manifest-path src-tauri/Cargo.tomlCloses #226
PR Type
Enhancement, Documentation
Description
Replaced null CSP with minimal Content Security Policy.
Restricted script, object, base, form, frame sources.
Allowed only IPC, local dev, and inline styles.
Added
docs/tauri-csp.mdexplaining boundaries and Rust networking.Diagram Walkthrough
File Walkthrough
tauri-csp.md
Document CSP boundaries and rationaledocs/tauri-csp.md
WebView fetch.
defense.
tauri.conf.json
Enable minimal CSP in Tauri WebView configopenless-all/app/src-tauri/tauri.conf.json
csp: nullwith a minimal Content Security Policy.script-srcto'self',object-src/base-uri/form-actionto'none'.connect-srconly foripc:,localhost:1420, and WebSocket HMR.implementation.