fix: production hardening for MCP server#34
Merged
ApiliumDevTeam merged 3 commits intomainfrom Mar 12, 2026
Merged
Conversation
- Prevent command injection in setup-claude host validation - Timing-safe bearer token comparison in HTTP transport - Graceful shutdown with closeAllConnections + SSE session tracking - Shutdown guard prevents double SIGINT execution - Word-boundary regex in governance to avoid substring false positives - Wrap all bare fetch calls in try/catch for Cortex-down resilience - Cap cortex_query limit at 500 to prevent abuse - Add hardening.test.ts covering all fixes (12 tests)
- Prefix unused variable with underscore in test - Add explicit unknown type annotation to catch clauses
- CORS default-deny when allowedOrigins is empty - Cap SSE sessions at 50 to prevent connection exhaustion - Require Content-Type application/json on POST endpoints - Wrap .json() calls in try/catch for non-JSON 200 responses - Validate tags with Array.isArray, cap limit/k at 100 - Use execFileSync instead of execSync to avoid shell injection - Add port validation (NaN, range 1-65535) in setup-claude - Add host validation in config parser for all code paths - Cache shutdown promise to prevent concurrent signal races - Add skipSignalHandlers option to CortexSidecar - Log sidecar/agent errors to stderr instead of swallowing - Explicit process.exit after shutdown in both HTTP and stdio modes - Rewrite hardening tests to exercise production code directly (20 tests)
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
Test plan
npx vitest run extensions/mcp-server/— 112 tests pass (9 files)npx vitest run extensions/memory-semantic/— 185 tests pass (10 files)pnpm build— compiles without errors