fix: path traversal in fs commands + tighten HTTP/CSP/asset permissions#94
Open
zuiyi001 wants to merge 1 commit intonashsu:mainfrom
Open
fix: path traversal in fs commands + tighten HTTP/CSP/asset permissions#94zuiyi001 wants to merge 1 commit intonashsu:mainfrom
zuiyi001 wants to merge 1 commit intonashsu:mainfrom
Conversation
Security audit identified 4 vulnerabilities: 1. Critical: Path traversal - fs commands accepted arbitrary paths without validation, allowing ../../ traversal to access files outside the workspace. Added validate_path() guard to all file-system command entry points. 2. Critical: Overly permissive HTTP capabilities - wildcard http://* / https://* allowed webview requests to any server. Replaced with explicit whitelist. 3. High: Loose CSP connect-src allowed any https/http endpoint. Restricted to app-specific domains. 4. High: assetProtocol scope granted access to all local files. Restricted to project-relevant directories.
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.
Summary
Security audit identified and fixes 4 vulnerabilities.
Changes
1. 🔴 Critical: Path Traversal in
fs.rsProblem:
read_file,write_file,delete_file,copy_file,copy_directory,list_directory,create_directory,read_file_as_base64,file_existsaccepted arbitrary paths without validation, allowing../../traversal to read/write/delete files outside the intended workspace.Fix: Added
validate_path()that rejects paths containing..or absolute paths. Applied to all 10 file-system command entry points.2. 🔴 Critical: Overly Permissive HTTP Capabilities
Problem:
capabilities/default.jsonused wildcardhttp://*/https://*allowing the webview to make requests to any external server.Fix: Replaced with explicit whitelist:
https://api.tavily.com/*andhttps://api.anthropic.com/*3. 🟡 High: Loose CSP
connect-srcProblem: CSP allowed
connect-src 'self' https: http:— any HTTPS/HTTP endpoint.Fix: Restricted to
'self' https://api.tavily.com https://api.anthropic.com. Also removed'unsafe-inline'fromstyle-src.4. 🟡 High:
assetProtocolScope["**"]Problem: Asset protocol granted access to all local files.
Fix: Restricted to
[".", "./wiki", "./raw", "./.llm-wiki", "./.cache"]Files Changed
src-tauri/src/commands/fs.rs— path validation (+31 lines, -13 lines)src-tauri/capabilities/default.json— HTTP permission whitelistsrc-tauri/tauri.conf.json— CSP + assetProtocol scopeNotes
*on 127.0.0.1 left as-is (local-only service)