Feature-221 : Gateway-Level Input Validation & Output Sanitization#1536
Merged
crivetimihai merged 6 commits intomainfrom Dec 12, 2025
Merged
Feature-221 : Gateway-Level Input Validation & Output Sanitization#1536crivetimihai merged 6 commits intomainfrom
crivetimihai merged 6 commits intomainfrom
Conversation
rakdutta
approved these changes
Dec 11, 2025
Collaborator
rakdutta
left a comment
There was a problem hiding this comment.
The PR is working as expected. When testing through the main API, we correctly receive a warning message in the development environment and an error message in the production environment.
However, in the Admin UI, the user should also receive a clear and user-friendly warning or error message.
Please create a separate PR to address this UI handling issue.
Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com>
Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com>
Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com>
Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com>
Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
aec5026 to
d28a828
Compare
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
…BM#1536) * added input security validation Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com> * testcases fixed Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com> * fixed config.py Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com> * added env vars and fixed validation code Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com> * remove input_validator.py file Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com> * fix: remove duplicate SecurityValidator import Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Veeresh K <veeruveeresh1522@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
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.
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 environment variables for each mode and check logs.
This section explains—step by step—how to run the gateway in different validation modes and verify the expected log behavior.
Validation Behavior Summary
This document explains how validation behaves based on different environment configurations.
🧪 Development Mode — Validation Disabled
Environment variables:
Behavior:
🧪 Development Mode — Validation Enabled
Environment variables:
Behavior:
Example log level:
🚀 Production Mode — Validation Enabled
Environment variables:
Behavior:
Example log:
🧪 Test Script