Overview
Users can configure MCP servers with custom arguments, environment variables, HTTP headers, and query parameters. Without validation, these inputs could enable:- Command injection: Executing arbitrary commands via malicious args
- nsjail sandbox bypass: Using
--to terminate nsjail arguments - Library injection: Setting
LD_PRELOADorNODE_OPTIONSto load malicious code - Header injection: CRLF injection for HTTP response splitting
- Shell metacharacter attacks: Using
;,|,&for command chaining
Validation Library Architecture
The security validation library is located atservices/backend/src/lib/security/:
Command Validation (Stdio)
Only specific commands are allowed to spawn MCP servers. Absolute paths are rejected to prevent arbitrary command execution. Allowed Commands (strict allowlist):
Rejected Patterns:
- Absolute paths (
/bin/bash,/usr/bin/node) - Any command not in the allowlist
services/backend/src/lib/security/stdioValidator.ts
Argument Validation
Arguments are validated against both a blocklist (dangerous patterns) and an allowlist (valid characters).Blocked Patterns
Valid Argument Pattern
All arguments must match this pattern:- Alphanumeric:
a-z,A-Z,0-9 - Package name characters:
@,/,_,.,- - Flag characters:
=,: - Git refs:
#
-y,--verbose,--port=3000@modelcontextprotocol/server-sequential-thinkinggithub:user/repo#abc123def
Limits
Environment Variable Validation
Environment variables are validated to prevent library and code injection attacks.Blocked Environment Variables
These variables are blocked because they can be exploited for code injection: Linux Dynamic Linker:LD_PRELOAD- Shared library injection (most dangerous)LD_LIBRARY_PATH- Library search path hijackingLD_AUDIT,LD_DEBUG,LD_PROFILE- Various injection vectors
NODE_OPTIONS- Can inject--require,--inspect, etc.NODE_PATH- Module resolution hijackingNODE_EXTRA_CA_CERTS- CA certificate injection
PYTHONSTARTUP- Executes script on interpreter startPYTHONPATH- Module resolution hijackingPYTHONHOME- Installation path hijacking
BASH_ENV- Executed on non-interactive bash startENV- Executed on sh startSHELL- Default shell override
PATH,HOME,TMPDIR,TMP,TEMPIFS- Shell word splitting manipulation
Key Format Validation
Environment variable keys must follow POSIX naming:Limits
File Reference:
services/backend/src/lib/security/envValidator.ts
HTTP Header Validation
HTTP headers are validated to prevent header injection and request smuggling attacks.Blocked Headers
These headers cannot be set by users:Header Key Validation
Keys must match HTTP token format:Header Value Validation
Values are checked for CRLF injection:- No carriage return (
\r) - No line feed (
\n) - No null bytes (
\x00)
Limits
File Reference:
services/backend/src/lib/security/httpValidator.ts
Query Parameter Validation
URL query parameters have similar validation to headers.Key Validation
Value Validation
- No control characters (
\x00-\x1f)
Limits
Build Script Validation (GitHub Deployments)
For GitHub deployments, build scripts are validated before accepting the deployment to prevent arbitrary code execution duringnpm install or npm run build.
File Reference: services/backend/src/lib/security/build-script-validation.ts
Blocked Patterns in Build Scripts
Node.js Validation
Python Validation
setup.pyexistence (can execute arbitrary code during install)[tool.hatch.build.hooks](custom build hooks)[tool.setuptools.cmdclass](command class overrides)
JSON Schema Constraints
In addition to programmatic validation, JSON schemas provide early rejection at the Fastify validation layer. File Reference:services/backend/src/routes/mcp/installations/schemas.ts
JSON schema validation provides a first layer of defense at the HTTP request level. The programmatic validators provide deeper checks including blocklist matching and pattern analysis.
API Integration
Validation is applied in the following API routes:
Integration Pattern:
Error Response Format
When validation fails, the API returns a 400 status with details:Related Documentation
- Satellite MCP Server Security - Defense-in-depth validation
- MCP Configuration Architecture - Three-tier configuration system
- Security Policy - Overall backend security
- Security and Privacy - User-facing security documentation

