Skip to content

fix(): restrict CORS to localhost and prevent shell injection#50

Merged
alexandrelam merged 2 commits into
mainfrom
fix/security-hardening-cors-shell-injection
Mar 25, 2026
Merged

fix(): restrict CORS to localhost and prevent shell injection#50
alexandrelam merged 2 commits into
mainfrom
fix/security-hardening-cors-shell-injection

Conversation

@julien-meichelbeck
Copy link
Copy Markdown
Collaborator

Summary

  • Replace wildcard cors() with a localhost-only origin check, closing the CSRF vector where a malicious website could make fetch requests to localhost:3325/api/*
  • Replace execSync with execFileSync for all git/tmux commands in worktree.ts, preventing shell injection via branch names, worktree paths, or tmux session names
  • Add CORS validation tests (5 new tests) and update worktree tests for the new execFileSync signatures

Test plan

  • npm run build compiles clean
  • npx vitest run test/worktree.test.ts test/server-security.test.ts — all 20 tests pass
  • Manual: curl -H "Origin: http://evil.com" -v http://localhost:3325/api/projects — should fail CORS
  • Manual: curl -H "Origin: http://localhost:5173" -v http://localhost:3325/api/projects — should work
  • Manual: frontend at localhost still works normally

🤖 Generated with Claude Code

…tmux calls

Close CSRF vector by replacing wildcard CORS with a localhost-only origin check.
Replace execSync with execFileSync for git/tmux commands to prevent shell injection via branch names or paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexandrelam alexandrelam merged commit 28a0434 into main Mar 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants