Skip to content

fix: path traversal in fs commands + tighten HTTP/CSP/asset permissions#94

Open
zuiyi001 wants to merge 1 commit intonashsu:mainfrom
zuiyi001:fix/security-vulnerabilities
Open

fix: path traversal in fs commands + tighten HTTP/CSP/asset permissions#94
zuiyi001 wants to merge 1 commit intonashsu:mainfrom
zuiyi001:fix/security-vulnerabilities

Conversation

@zuiyi001
Copy link
Copy Markdown

Summary

Security audit identified and fixes 4 vulnerabilities.

Changes

1. 🔴 Critical: Path Traversal in fs.rs

Problem: read_file, write_file, delete_file, copy_file, copy_directory, list_directory, create_directory, read_file_as_base64, file_exists accepted 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.json used wildcard http://* / https://* allowing the webview to make requests to any external server.

Fix: Replaced with explicit whitelist: https://api.tavily.com/* and https://api.anthropic.com/*

3. 🟡 High: Loose CSP connect-src

Problem: 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' from style-src.

4. 🟡 High: assetProtocol Scope ["**"]

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 whitelist
  • src-tauri/tauri.conf.json — CSP + assetProtocol scope

Notes

  • No malicious code found; all issues are convenience-vs-security tradeoffs
  • Clip server CORS * on 127.0.0.1 left as-is (local-only service)

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.
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