Skip to main content
Glama
SECURITY.md9.26 kB
# Security Audit Report **Project:** Domain Search MCP **Audit Date:** December 2024 **Audit Type:** Comprehensive Security Review --- ## Executive Summary This codebase has undergone multiple layers of security analysis using both AI-powered code review tools and static analysis security scanners. All identified vulnerabilities have been addressed, and the remaining findings have been analyzed and documented as acceptable risks. | Category | Tools Used | Critical | High | Medium | Low | |----------|-----------|----------|------|--------|-----| | AI Code Review | 2 platforms | 0 | 0 | 0 | 2 (false positives) | | Static Analysis (SAST) | Pattern-based scanner | 0 | 0 | 1 (mitigated) | 0 | | Dependency Scan (SCA) | Package vulnerability scanner | 0 | 0 | 0 | 0 | **Overall Security Posture: PRODUCTION READY** --- ## 1. Vulnerabilities Found & Fixed ### 1.1 IP Address Disclosure (P1 - Critical) **Location:** `src/registrars/namecheap.ts` **Issue:** External service call to determine client IP exposed user's IP address to third-party service. **CWE:** CWE-200 (Exposure of Sensitive Information) **Resolution:** - Removed external IP lookup dependency - IP now configured via `NAMECHEAP_CLIENT_IP` environment variable - Added IP format validation (IPv4/IPv6) ```typescript // Before (vulnerable) const ip = await axios.get('https://external-ip-service.com'); // After (secure) const ip = config.namecheap.clientIp; // User-configured, no external call ``` --- ### 1.2 Unbounded Cache Growth (P2 - High) **Location:** `src/utils/cache.ts` **Issue:** Cache had no size limit, allowing potential memory exhaustion through repeated unique queries. **CWE:** CWE-400 (Uncontrolled Resource Consumption) **Resolution:** - Implemented LRU (Least Recently Used) eviction policy - Added configurable maximum cache size (default: 10,000 entries) - Added `lastAccessedAt` tracking for intelligent eviction ```typescript // Cache now implements size limits with LRU eviction const DEFAULT_MAX_CACHE_SIZE = 10000; // ~10MB max memory ``` --- ### 1.3 Missing API Response Validation (P2 - High) **Location:** `src/registrars/porkbun.ts`, `src/registrars/namecheap.ts`, `src/fallbacks/rdap.ts` **Issue:** External API responses were used without schema validation, risking type confusion or injection. **CWE:** CWE-20 (Improper Input Validation) **Resolution:** - Added Zod schema validation for all external API responses - Implemented strict type inference from schemas - Added safe parsing with `.safeParse()` for graceful error handling ```typescript // All external responses now validated const parseResult = ResponseSchema.safeParse(response.data); if (!parseResult.success) { throw new RegistrarApiError('Invalid API response format'); } ``` --- ### 1.4 Unsafe vCard Array Access (P2 - Medium) **Location:** `src/fallbacks/rdap.ts` **Issue:** RDAP vCard arrays accessed without bounds checking, risking crashes on malformed data. **CWE:** CWE-129 (Improper Validation of Array Index) **Resolution:** - Added comprehensive bounds checking before array access - Wrapped extraction in try-catch for defensive error handling - Validated array structure at each nesting level ```typescript // Safe extraction with bounds checking if (!Array.isArray(vcardArray) || vcardArray.length < 2) { return undefined; } ``` --- ## 2. Findings Analyzed & Accepted ### 2.1 Dynamic RegExp Construction **Location:** `src/registrars/namecheap.ts:77,94` **Scanner Finding:** "Potential ReDoS via dynamic RegExp" **Severity Reported:** Medium **Analysis:** | Factor | Assessment | |--------|------------| | Input source | Hardcoded whitelist (`ALLOWED_XML_TAGS`) | | User control | None - parameters are literal strings in code | | Regex complexity | Simple pattern, no nested quantifiers | | Backtracking risk | None - `[^<]*` cannot cause catastrophic backtracking | **Conclusion:** FALSE POSITIVE The scanner cannot determine that the `tag` parameter is constrained by a compile-time whitelist. The regex pattern itself is mathematically immune to ReDoS attacks. **Mitigation:** Whitelist validation occurs before RegExp construction: ```typescript const ALLOWED_XML_TAGS = new Set(['Error', 'Errors', 'DomainCheckResult']); if (!ALLOWED_XML_TAGS.has(tag)) { return undefined; // Reject non-whitelisted tags } ``` --- ### 2.2 Format String in Example Files **Location:** `examples/*.ts` **Scanner Finding:** "Unsafe format string concatenation" **Severity Reported:** Info **Analysis:** - Located in example/demo files only - Not part of production server code - No user input reaches these code paths - Examples run locally by developers only **Conclusion:** ACCEPTABLE - Example code, not production --- ## 3. Dependency Security ### 3.1 Package Vulnerability Scan ``` Scan Date: December 2024 Vulnerabilities Found: 0 Dependencies Analyzed: ├── @modelcontextprotocol/sdk (runtime) ├── axios (runtime) ├── zod (runtime) ├── dotenv (runtime) ├── winston (runtime) └── [dev dependencies excluded from production] ``` ### 3.2 Outdated Packages | Package | Current | Latest | Risk Assessment | |---------|---------|--------|-----------------| | zod | 3.x | 4.x | Major version, breaking changes - defer upgrade | | dotenv | 16.x | 17.x | No security implications | | @types/* | Various | Various | Dev-only, no runtime impact | **Recommendation:** No immediate action required. Schedule major version upgrades during planned maintenance windows. --- ## 4. Security Architecture ### 4.1 Defense in Depth ``` ┌─────────────────────────────────────────────────────────┐ │ MCP Protocol Layer │ │ (Zod schema validation at entry) │ ├─────────────────────────────────────────────────────────┤ │ Input Validation │ │ (Domain/TLD validators with sanitization) │ ├─────────────────────────────────────────────────────────┤ │ Rate Limiting │ │ (Token bucket per registrar adapter) │ ├─────────────────────────────────────────────────────────┤ │ Response Validation │ │ (Zod schemas for all external APIs) │ ├─────────────────────────────────────────────────────────┤ │ Resource Limits │ │ (LRU cache eviction, request timeouts) │ └─────────────────────────────────────────────────────────┘ ``` ### 4.2 Security Controls Summary | Control | Implementation | Status | |---------|---------------|--------| | Input validation | Zod schemas + custom validators | ✅ | | Output encoding | N/A (JSON only) | ✅ | | Authentication | API keys via environment variables | ✅ | | Rate limiting | Per-adapter token bucket | ✅ | | Error handling | Custom error types, no stack traces to clients | ✅ | | Logging | Winston with configurable levels | ✅ | | Secrets management | Environment variables, no hardcoding | ✅ | | Dependency security | 0 known vulnerabilities | ✅ | --- ## 5. Recommendations for Future Development 1. **Before adding new external APIs:** Add Zod schema validation for responses 2. **Before adding user-facing inputs:** Validate and sanitize at entry point 3. **When modifying cache logic:** Maintain size limits and eviction policies 4. **When updating dependencies:** Run vulnerability scan before merging 5. **For sensitive configurations:** Use environment variables, never commit secrets --- ## 6. Audit Methodology This security review employed a multi-layer approach: 1. **AI-Powered Code Review** - Semantic analysis for logic flaws, security anti-patterns, and architectural issues 2. **Static Application Security Testing (SAST)** - Pattern-based scanning for OWASP Top 10, CWE vulnerabilities 3. **Software Composition Analysis (SCA)** - Dependency vulnerability database matching 4. **Manual Code Review** - Verification of automated findings, false positive elimination Each finding was triaged using: - **Exploitability assessment** - Can this actually be exploited? - **Data flow analysis** - Where does the data come from? - **Framework context** - What protections exist at other layers? --- ## Approval This codebase has been reviewed and approved for production deployment. ``` Security Review: PASSED Last Updated: December 2024 Next Review: Recommended before major version releases ```

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/dorukardahan/domain-search-mcp'

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