fix: harden security — patch 7 critical and 3 high vulnerabilities - #29
Open
dngnguyen wants to merge 1 commit into
Open
fix: harden security — patch 7 critical and 3 high vulnerabilities#29dngnguyen wants to merge 1 commit into
dngnguyen wants to merge 1 commit into
Conversation
- C2: Replace exec() with execFile() in reveal.post.ts to prevent command injection - C3: Add path restriction to files.get.ts — block arbitrary file reads outside ~/.claude - C4: Restrict directories.get.ts to home directory and ~/.claude - C5: Default SDK permission mode to 'default' instead of 'bypassPermissions' - C6: Add DOMPurify to sanitize all markdown v-html output, fix XSS amplifier in decodeHTMLEntities - C7: Validate MCP import config schema — require command/url, whitelist fields, validate URLs - H1: Add path traversal protection to agent slugs via safePath utility - H3: Remove PATH environment variable leak from debug endpoint - H9: Add SIGTERM/SIGINT handlers for PTY session cleanup Adds server/utils/path-security.ts with safePath(), safeClaudePath(), isUnderAllowedPath(). Adds vitest test suite: 37 tests (unit + E2E) verifying all security fixes.
|
Hey @dngnguyen, I was just looking through the repo and stumbled on this PR. Really nice work on hardening the security. The changes look thoughtful and it should make running this locally feel a lot safer. Hope to see this landed. |
cbeaulieu-gt
added a commit
to cbeaulieu-gt/claude-code-cli-ui
that referenced
this pull request
Jun 22, 2026
…view fixes (#2) Cherry-picks upstream Ngxba/claude-code-cli-ui PR Ngxba#29 (6 critical + 3 high vuln fixes) onto the fork, plus cross-platform path-security fixes and resolutions for all Codex review findings (projectDir bypass, SSR XSS, e2e HOME isolation, signal-cleanup, MCP disabled-flag preservation). Remaining file-read-scope hardening tracked in #3. Closes #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
Full security audit identified 7 critical and 10 high severity vulnerabilities. This PR fixes all 7 critical and 3 high-priority issues with a comprehensive test suite.
No backdoors, telemetry, or malicious code was found in the codebase.
Critical Fixes
exec()server/api/reveal.post.tsexec()→execFile()(no shell) + path restrictionserver/api/files.get.tsisUnderAllowedPath()— restricts to~/.claudeserver/api/directories.get.tshomedir()+~/.claudebypassPermissionsclaudeSdk.ts,claudeProvider.ts'default'permission modev-htmlsinks, no sanitizerapp/utils/markdown.ts+ componentsserver/api/mcp/import.post.tsHigh Fixes
server/utils/agentUtils.ts..///\in slugs +safeClaudePath()process.env.PATHserver/api/debug/claude-cli.get.tspathEnvironmentfrom responseserver/utils/cliSession.tsSIGTERM/SIGINTcleanup handlersNew Files
server/utils/path-security.ts— Core security utilities:safePath(),safeClaudePath(),isUnderAllowedPath(),getAllowedPaths()tests/security/path-security.test.ts— 10 unit tests for path securitytests/security/xss-sanitization.test.ts— 6 unit tests for XSS fixestests/security/api-security-e2e.test.ts— 21 E2E tests hitting live endpointsvitest.config.ts— Test framework setupDependencies Added
dompurify+@types/dompurify— HTML sanitization for XSS preventionvitest,@nuxt/test-utils,happy-dom— Test framework (dev)Test plan
npm run test)safePath()blocks traversal,decodeHTMLEntitiessafe, lang attribute escaped/api/files?path=/etc/passwd→ 403,/api/revealshell injection → blocked,/api/directories?path=/etc/→ 403, agent slug traversal → 400, MCP import validation → 400 for invalid configsnpx nuxi build)