Merged
Conversation
Implement comprehensive security validation for MCP server manifests with clear warnings about limitations. Core Features: - ManifestValidator class for static analysis of manifests - Risk-based scoring system (CRITICAL, HIGH, MEDIUM, LOW, INFO) - CWE ID mapping for industry-standard vulnerability classification - Detection of: dangerous operations, input validation issues, SQL/command injection, path traversal, SSRF, sensitive data exposure CLI Integration: - New `mcp validate` command with multiple options: * Validate from file or app * --fail-on option for CI/CD (critical/high/medium/low) * --json output for automated processing * Pretty console output with color-coded severity Validation Checks: - Dangerous tool names (delete, execute, admin, etc.) - Unbounded strings without maxLength or enum constraints - Unvalidated path/file parameters (path traversal risk) - SQL query parameters with context awareness (only flags if SQL-related) - Command execution parameters (command injection risk) - Unvalidated URL parameters (SSRF risk) - Sensitive data mentions (password, token, secret) - Missing authentication indicators - Large attack surface (many exposed tools) Components: - nextmcp/security/__init__.py - Module exports with security warnings - nextmcp/security/validation.py - Core validator (850+ lines) - nextmcp/cli.py - Enhanced with `mcp validate` command - tests/test_security_validation.py - 31 comprehensive test cases (100% passing) - examples/security_validation/ - Complete examples: * README.md - Comprehensive guide with clear limitations * secure_server.py - Well-secured server example * insecure_server.py - Vulnerable server (educational, marked "DO NOT USE") * validate_custom.py - Custom validation script for CI/CD Documentation: - README.md updated with extensive security warnings section -⚠️ CRITICAL SECURITY WARNINGS prominently displayed - Clear documentation of what validator CANNOT do: * Cannot detect malicious implementation code * Cannot verify authentication is properly enforced * Cannot detect business logic flaws * Cannot prevent supply chain attacks * Cannot detect runtime vulnerabilities - Defense-in-depth best practices - CI/CD integration examples Design Decisions: - Static analysis only (Tier 1 MVP approach) - Focused on obvious security issues in manifest structure - Explicit about limitations to avoid false sense of security - Designed as ONE layer in defense-in-depth strategy - Enum constraints recognized as valid bounds (fixes for path traversal and unbounded string checks) - JSON string parsing support in validate_manifest() - Context-aware SQL injection detection (only flags "query" if SQL-related) Test Coverage: - 31 new security validation tests (100% passing) - All 394 total tests passing - Tests cover: valid/invalid manifests, all vulnerability types, risk scoring, real-world scenarios Bug Fixes: - Fixed false positives for generic "query" parameters that aren't SQL-related - Fixed enum constraint recognition in path traversal detection - Fixed unbounded string detection to respect enum constraints This validator is designed to catch obvious security issues but should NOT be considered a complete security solution. Always use as ONE LAYER in a defense-in-depth security strategy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.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.
Summary
Implements comprehensive security validation for MCP server manifests with clear warnings about limitations. This adds the ability to automatically check manifests for common security vulnerabilities before deployment.
This validator is designed to catch obvious security issues in manifest structure but should NOT be considered a complete security solution. It is intended as ONE LAYER in a defense-in-depth security strategy.
What This Validator DOES:
✅ Detects dangerous operation names (delete, execute, admin, etc.)
✅ Identifies missing input validation (unbounded strings, unconstrained objects)
✅ Flags potential injection vulnerabilities (SQL, command, path traversal)
✅ Detects SSRF risks and sensitive data exposure
✅ Assesses overall risk with CWE mapping
What This Validator CANNOT Do:
❌ Detect malicious code in server implementation
❌ Verify authentication/authorization is properly enforced
❌ Detect business logic flaws or runtime vulnerabilities
❌ Prevent supply chain attacks or sophisticated exploits
Features Added
🔒 Security Validation Module
🛠️ CLI Integration
New
mcp validatecommand with multiple options:📚 Examples & Documentation
3 complete example servers in
examples/security_validation/:secure_server.py- Demonstrates security best practicesinsecure_server.py- Shows vulnerabilities (educational, marked "DO NOT USE")validate_custom.py- Custom validation script for CI/CD pipelinesComprehensive documentation with:
🧪 Test Coverage
Security Checks Implemented
Design Decisions
Files Changed
Core Implementation
nextmcp/security/__init__.py- Module exports with security warningsnextmcp/security/validation.py- Core validator (850+ lines)nextmcp/cli.py- Enhanced withmcp validatecommandTests
tests/test_security_validation.py- 31 comprehensive test casesExamples
examples/security_validation/README.md- Complete guideexamples/security_validation/secure_server.py- Best practices exampleexamples/security_validation/insecure_server.py- Vulnerability examplesexamples/security_validation/validate_custom.py- CI/CD integrationDocumentation
README.md- Updated with security validation section and warningsTesting
All 394 tests pass, including:
Example Output
Breaking Changes
None - This is a new feature with no impact on existing functionality.
Migration Guide
N/A - This is a new opt-in feature.
Checklist
Related Issues
Addresses user request for manifest security validation capabilities.
🤖 Generated with Claude Code