fix: harden clip server against CSRF and arbitrary file write (security)#272
Open
xkvrum1n wants to merge 1 commit into
Open
fix: harden clip server against CSRF and arbitrary file write (security)#272xkvrum1n wants to merge 1 commit into
xkvrum1n wants to merge 1 commit into
Conversation
- Replace wildcard CORS with explicit origin allowlist (HIGH, CVSS 8.1) - Validate projectPath against registered projects before file write (CRITICAL, CVSS 9.1)
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
This PR fixes two security vulnerabilities in the local clip server (
src-tauri/src/clip_server.rs) identified during an internal security audit.Vulnerabilities Fixed
1. CSRF via wildcard CORS — HIGH (CVSS 8.1)
Before: The server returned
Access-Control-Allow-Origin: *on all responses, allowing any website to make cross-origin requests to the clip server running on127.0.0.1:19827.After: Replaced wildcard with an explicit allowlist. Requests from unlisted origins receive
Access-Control-Allow-Origin: null.2. Arbitrary file write via unvalidated
projectPath— CRITICAL (CVSS 9.1)Before: The
/clipPOST endpoint accepted any filesystem path in theprojectPathfield with no validation, allowing a caller to write attacker-controlled content to any location on the user's filesystem.After: The submitted path is validated against the list of registered projects. Unrecognized paths are rejected with an error.
Attack Chain Broken (Combined CVSS 9.3)
Without these fixes, a malicious website could:
GET http://127.0.0.1:19827/projectsto enumerate all wiki project paths (unauthenticated endpoint)/clipwith each discovered path and arbitrary contentBoth prerequisites are now blocked.
Testing
curl -H "Origin: http://evil.com" http://127.0.0.1:19827/projects→ response header should beAccess-Control-Allow-Origin: null/clipwith aprojectPathnot in the registered project list → should return{"ok":false,"error":"projectPath is not a registered project"}