fix: critical security vulnerabilities in IPC handlers and renderer#27
Open
navedr wants to merge 2 commits into
Open
fix: critical security vulnerabilities in IPC handlers and renderer#27navedr wants to merge 2 commits into
navedr wants to merge 2 commits into
Conversation
- add DOMPurify to sanitize marked markdown output (XSS via malicious .md files) - add Content Security Policy header (default-src 'self') - add path allowlisting to read-file-for-panel, save-file-for-panel, watch-file, read-memory, and save-memory IPC handlers (arbitrary file read/write) - add shell metacharacter validation for permissionMode, worktreeName, and addDirs fields passed to PTY spawn (command injection) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Great stuff. Thank you |
Contributor
|
@navedr the OSC8 hyperlinks in the terminal can point to any file. So in Claude when you are modifying a file, it becomes clickable and clicking it opens it in a side panel. So this restriction would break that: Read-file-for-panel, save-file-for-panel, watch-file. |
Address review feedback from @abasiri: the file panel intentionally opens arbitrary files via OSC8 hyperlinks from terminal output, so a strict allowlist breaks that functionality. Changed approach: - file panel IPC (read/save/watch): denylist of sensitive paths (.ssh, .gnupg, .aws/credentials, .env, .netrc, .docker/config, .kube/config) - memory IPC (read/save): strict allowlist (unchanged, ~/.claude/ + project dirs) The primary XSS→file-access chain is mitigated by CSP + DOMPurify; the sensitive path denylist is defense-in-depth. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Author
|
Good point — updated in dc2e2a4. Changed the approach for file panel IPC (
Memory IPC ( The primary defense against the XSS→file-access chain is CSP + DOMPurify — the sensitive path denylist is defense-in-depth. |
This was referenced May 6, 2026
ivandobskygithub
approved these changes
May 7, 2026
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 several critical and high-severity vulnerabilities. This PR fixes the top 6:
read-file-for-panel,save-file-for-panel,watch-file,read-memory, andsave-memoryaccepted any file path from the renderer with no validation. Added path allowlisting (~/.claude/+ active session project dirs).marked.parse()output was assigned toinnerHTMLwithout sanitization. Added DOMPurify to sanitize all markdown rendering.permissionMode,worktreeName, andaddDirswere interpolated into shell command strings without validation. Added shell metacharacter rejection.default-src 'self') viasession.defaultSession.webRequest.onHeadersReceived.What's NOT in this PR
preLaunchCmdis intentionally a shell command (by design), so it's left as-is. A future refactor could move PTY spawning to array-based args to eliminate the entire shell interpretation surface.allow-dyld-environment-variables, etc.) are required by native modules and can't be tightened without breakingnode-pty/better-sqlite3.Files changed
main.jspackage.jsondompurifydependencypublic/index.htmlpublic/viewer-toolbar.jspublic/viewer-panel.jsTest plan
npm testpassesnpm run bundle:codemirrorbuilds successfully🤖 Generated with Claude Code