security: validate IPC file paths, sanitize viewer HTML, add CSP (port upstream #27) - #43
Merged
Merged
Conversation
Port of upstream doctly#27 (author @navedr), adapted to the fork's diverged main.js / viewer panels. - IPC file handlers (read-file-for-panel, save-file-for-panel, watch-file) reject well-known credential paths via isSensitivePath denylist. - read-memory / save-memory confined to ~/.claude or active project paths via isAllowedMemoryPath allowlist (replaces the weak any-existing-.md check). - Viewer markdown rendering sanitized with DOMPurify before innerHTML (viewer-panel.js, viewer-toolbar.js); dompurify vendored via index.html. - Content-Security-Policy header set on the default session. See PR body for two runtime caveats requiring verification before merge.
…active sessions The get-memories panel surfaces CLAUDE.md/agents.md/.claude/*.md from every indexed project; confining isAllowedMemoryPath to active-session paths would return empty content for any project without an open session. Enumerate all known project roots (same source as get-memories) plus ~/.claude.
Merged
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.
Port of upstream doctly/switchboard#27 by @navedr, adapted to the fork's diverged
main.jsand viewer panels.Vectors fixed
read-file-for-panel,save-file-for-panel,watch-filenow reject well-known credential locations (.ssh,.gnupg,.aws/credentials,.env,.netrc,.docker/config.json,.kube/config) viaisSensitivePath(ipc-path-validator.js). Denylist (not allowlist) because the file panel intentionally accepts arbitrary project paths from terminal OSC 8 hyperlinks.read-memory/save-memoryconfined to~/.claudeor active project paths viaisAllowedMemoryPath(replaces the weak!startsWith(CLAUDE_DIR) && !existsSynccheck that let any existing .md be read).viewer-panel.js+viewer-toolbar.jssanitizemarked.parse()output with DOMPurify beforeinnerHTML. DOMPurify vendored viaindex.html(same mechanism as morphdom/xterm).Content-Security-Policyheader on the default session (script-src 'self',style-src 'self' 'unsafe-inline'— inline styles are set via JS).SWITCHBOARD_DATA_DIR=~/.switchboard-dev task dev) and confirm no scripts are blocked underfile://and the terminal/CodeMirror/xterm still render.isAllowedMemoryPathusesactiveSessions(live-PTY sessions). If the Plans/Memory panels read files for a selected-but-not-opened project, those reads would now be rejected. Needs confirmation that the renderer only requests memory/plan paths for projects with an active session — otherwise the allowlist must also include the currently-selected project path.Tests
test/ipc-path-validator.test.js(node:test) — denylist matches, allowlist accepts~/.claude+ project paths, rejects../traversal. Native-module suite must be validated viatask checkin the primary checkout.Credit: @navedr / doctly#27.