Feature-221 : Gateway-Level Input Validation & Output Sanitization #1536
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.
Gateway-Level Input Validation & Output Sanitization
Closes #221
🔒 Security Enhancement
This PR introduces a comprehensive security layer for input validation and output sanitization within the MCP Gateway, significantly reducing the attack surface for path traversal, command injection, and control-character exploits.
🎯 Key Features
1. Path Traversal Defense
2. Parameter Validation
javascript:)3. Output Sanitization
4. Configurable Security Modes
EXPERIMENTAL_VALIDATE_IO5. System-Wide Coverage
🛠️ Implementation Details
New Components
Updated Components
🔧 Configuration Added (in
.env)🎯 Security Impact
Prevents:
Benefits:
-Foundation for future MCP spec hardening
🛡️ Quick Security Validation Tests
Essential attack patterns that MUST be blocked by the Gateway.
Export the environment variables
Run this in your terminal:
If false → validation disabled, tests will execute normally
If true → validation enabled, tests will block invalid inputs
🧪 Test Script