Skip to main content
DeployStack Backend implements a comprehensive input validation system to protect against security threats when users configure MCP servers. This validation occurs before any data is stored in the database, serving as the first line of defense. For satellite-side validation (defense-in-depth), see Satellite MCP Server Security.

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_PRELOAD or NODE_OPTIONS to load malicious code
  • Header injection: CRLF injection for HTTP response splitting
  • Shell metacharacter attacks: Using ;, |, & for command chaining
The validation library prevents all these attack vectors through strict allowlists and blocklists.

Validation Library Architecture

The security validation library is located at services/backend/src/lib/security/:
ValidationResult Interface:

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
File Reference: 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:
Allowed characters:
  • Alphanumeric: a-z, A-Z, 0-9
  • Package name characters: @, /, _, ., -
  • Flag characters: =, :
  • Git refs: #
Valid examples:
  • -y, --verbose, --port=3000
  • @modelcontextprotocol/server-sequential-thinking
  • github: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 hijacking
  • LD_AUDIT, LD_DEBUG, LD_PROFILE - Various injection vectors
Node.js Specific:
  • NODE_OPTIONS - Can inject --require, --inspect, etc.
  • NODE_PATH - Module resolution hijacking
  • NODE_EXTRA_CA_CERTS - CA certificate injection
Python Specific:
  • PYTHONSTARTUP - Executes script on interpreter start
  • PYTHONPATH - Module resolution hijacking
  • PYTHONHOME - Installation path hijacking
Shell Injection:
  • BASH_ENV - Executed on non-interactive bash start
  • ENV - Executed on sh start
  • SHELL - Default shell override
Path Manipulation:
  • PATH, HOME, TMPDIR, TMP, TEMP
  • IFS - Shell word splitting manipulation

Key Format Validation

Environment variable keys must follow POSIX naming:

Limits

File Reference: services/backend/src/lib/security/envValidator.ts
The blocked environment variables list is synchronized between backend and satellite to ensure consistent protection across both validation layers.

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 during npm 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

Python-Specific Blocks:
  • setup.py existence (can execute arbitrary code during install)
  • [tool.hatch.build.hooks] (custom build hooks)
  • [tool.setuptools.cmdclass] (command class overrides)
Build script validation is mirrored in the satellite for defense-in-depth. See Satellite MCP Server Security.

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:
Security validation failures are logged with full context for audit purposes: