security: path traversal guard, null byte rejection, and CORS tightening#209
Merged
Conversation
- resolveProjectFsPath: validate resolved path stays within project root - lightcode-local:// protocol handler: reject null bytes and normalize paths - BrowserMcpIngress + WSL bridge MCP proxy: restrict CORS to localhost origins Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Three defense-in-depth security hardening fixes:
resolveProjectFsPathpath traversal guard — thepathfield from IPC was joined to the project root viapath.joinwithout checking the result stayed inside the root.../../etc/passwdcould escape:Now normalizes the joined path and verifies it starts with the project root prefix.
lightcode-local://null byte rejection + path normalization — the protocol handler now rejects paths containing null bytes (which can confuse C-level file APIs) andresolve()s the path before serving.CORS restricted to localhost —
BrowserMcpIngressand the WSL bridge MCP proxy previously setAccess-Control-Allow-Origin: *on OPTIONS responses. Now only reflects the request origin when it's a localhost address (127.0.0.1,localhost,[::1]). Remote web pages can no longer pass CORS preflight against the local MCP endpoint.Motivation
Audit of the codebase identified these as the highest-impact defense-in-depth improvements. The existing auth (bearer tokens,
contextIsolation,sandbox) is the primary security boundary; these fixes add a second layer:revealProjectEntry, it couldshell.showItemInFolderany file on disk.*allows any web page to pass preflight and issue POST requests (the token still blocks access, but the request still reaches the server).Testing
pnpm run typecheckpnpm run lintpnpm run fmt:check— Not run; formatting unchanged (only logic additions)pnpm run test— bridge tests (14/14 pass), BrowserMcpIngress tests (2/2 pass).localFiles.test.tsrequires Electron binary (unavailable in headless CI-less env).Screenshots
No UI changes.
Linked issue
N/A — proactive security audit
Link to Devin session: https://app.devin.ai/sessions/d7d2434b4b4846c0a7aa3176f8ea71f7
Requested by: @SDSLeon