Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel
SECURITY.md5.33 kB
# Security Assessment - MCP Time Server ## Current Security Measures ✅ ### 1. Input Validation - **Strong validation** for all parameters using dedicated validation functions - Type checking enforced by TypeScript - Timezone validation against date-fns-tz library - Date format validation with parseISO - Enum validation for time units and recurrence patterns - Numeric range validation (day of week, day of month) ### 2. Rate Limiting - Sliding window rate limiter implemented - Default: 100 requests per minute - Configurable via environment variables - Returns proper rate limit headers ### 3. Memory Protection - Cache has 10MB memory limit - Automatic eviction when limit reached - Memory-aware caching prevents DoS via cache flooding ### 4. No External Dependencies - No external API calls - No network requests - Reduces attack surface significantly ### 5. Error Handling - Structured error responses - No stack traces exposed to clients - Consistent error format ## Security Gaps & Recommendations 🚨 ### 1. Missing Security Linting **Risk**: Common security vulnerabilities may go undetected **Action Required**: Add ESLint security plugin ```bash npm install --save-dev eslint-plugin-security ``` Update `.eslintrc.json`: ```json { "plugins": ["@typescript-eslint", "security"], "extends": [ // ... existing "plugin:security/recommended" ] } ``` ### 2. Input Length Limits **Risk**: Large inputs could cause memory exhaustion or processing delays **Current State**: No explicit length limits on: - Timezone strings - Date strings - Format strings - Custom format patterns - Holiday arrays **Action Required**: Add length validation ```typescript // Add to validation.ts export const MAX_STRING_LENGTH = 1000; export const MAX_ARRAY_LENGTH = 365; // For holiday arrays export function validateStringLength(str: string, maxLength = MAX_STRING_LENGTH): boolean { return str.length <= maxLength; } ``` ### 3. JSON Injection Prevention **Risk**: While we use JSON.stringify safely, we should ensure no user input is parsed as JSON **Current State**: Good - we don't use JSON.parse on user input **Recommendation**: Document this as a security principle ### 4. Cache Key Injection **Risk**: Malicious cache keys could cause collisions or memory issues **Current State**: Cache keys include user input via JSON.stringify **Action Required**: Sanitize cache keys ```typescript // Use hash instead of raw user input import { createHash } from 'crypto'; function sanitizeCacheKey(key: string): string { return createHash('sha256').update(key).digest('hex').substring(0, 16); } ``` ### 5. Prototype Pollution **Risk**: Object spread/assign with user input **Current State**: Limited risk - we don't merge user objects **Recommendation**: Add tests to verify resistance ### 6. Regular Expression DoS (ReDoS) **Risk**: Complex regex patterns could cause CPU exhaustion **Current State**: We use simple regex patterns (low risk) **Action Required**: Document regex safety requirements ### 7. Missing Security Headers **Risk**: MCP protocol may not support security headers, but we should document this **Action Required**: Research MCP security best practices ## Testing Requirements (TDD) ### Security Test Suite Needed: 1. **Input validation extremes** - Very long strings (> 10KB) - Special characters in all fields - Unicode edge cases - Null bytes - Control characters 2. **Rate limiting effectiveness** - Burst attempts - Distributed attempts - Reset behavior 3. **Cache poisoning attempts** - Collision attempts - Memory exhaustion - Invalid data types 4. **Error disclosure** - Verify no sensitive info in errors - No file paths exposed - No internal state leaked ## MCP-Specific Security Considerations ### 1. Tool Parameter Injection **Risk**: MCP tools receive arbitrary JSON parameters **Mitigation**: - Never use parameters in shell commands - Never construct file paths from parameters - Never use eval() or Function() constructor ### 2. Resource Limits **Current**: Rate limiting only **Needed**: - Maximum execution time per tool call - Maximum memory usage per operation - Queue depth limits ### 3. Audit Logging **Current**: None **Recommendation**: Log security events - Rate limit violations - Invalid parameter attempts - Unusual patterns ## Security Tools to Add 1. **npm audit** - Already clean ✅ 2. **eslint-plugin-security** - Needed 3. **husky pre-commit** - Already configured ✅ 4. **OWASP Dependency Check** - Consider for CI/CD 5. **Snyk** - Consider for continuous monitoring ## Priority Actions 1. **HIGH**: Add input length validation 2. **HIGH**: Add eslint-plugin-security 3. **HIGH**: Write security test suite 4. **MEDIUM**: Implement cache key sanitization 5. **MEDIUM**: Add execution timeouts 6. **LOW**: Add security logging ## Summary The codebase has good foundational security: - Strong input validation - No external dependencies - Rate limiting - Memory limits However, it needs: - Security-focused linting - Input length limits - Security test coverage - Better documentation of security measures No critical vulnerabilities found, but implementing the recommendations above will significantly improve the security posture before any public release or CVE exposure.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pshempel/mcp-time-server-node'

If you have feedback or need assistance with the MCP directory API, please join our Discord server