fix(security): pre-release security hardening#79
Merged
Conversation
…sing headers Replace exec() with execFile() in repoConverter to prevent shell injection via malicious git URLs. Add validateRepoUrl() with protocol, structure, and metacharacter checks. Apply safePath() to root/outputDir in server handlers to block path traversal. Add per-session CSRF token required on all POST requests. Set X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Cache-Control, and CSP headers on all responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
exec()withexecFile()inrepoConverter.jsto eliminate shell interpolation on git clone URLs; addvalidateRepoUrl()with protocol, structure, and metacharacter validationsafePath()torootandoutputDirinhandleAnalyzeandhandleConvertserver handlers, returning 403 on escape attemptscrypto.randomUUID()token at server startup; requireX-Hamlet-Tokenheader on all POST requests (401 on mismatch); expose token via/api/healthfor local client bootstrappingX-Content-Type-Options: nosniff,X-Frame-Options: DENY,Referrer-Policy: no-referrer,Cache-Control: no-store,Content-Security-Policy: default-src 'none'on all responses; return 204 on OPTIONS preflightTest plan
npm run format:checkpassesnpm run lintpassesnpm testpasses (726 suites, 2231 tests)validateRepoUrltests cover valid URLs, injection payloads, null bytes, non-string input, unrecognized protocols, and malformed URLshamlet convert "https://github.com/x/y; touch /tmp/pwned" --from jest --to vitest→ "Invalid repository URL" before any execcurl -X POST http://127.0.0.1:<port>/api/analyze -d '{"root":"/etc"}'→ 401 (missing token) or 403 (path outside root)🤖 Generated with Claude Code