REAL THREATS
Shell Injection & Command Execution (Critical)
• Shell command injection via eval in hook scripts (2, 3, 45-54) - Direct code execution from untrusted JSON input
• PID file race condition enabling arbitrary command execution (16) - Classic TOCTOU vulnerability
• Shell hook wrappers enable command injection chains (29, 30, 89) - Multiple injection points in hook system
• Path traversal in transcript path expansion (55) - File system access outside intended directories
Multi-Tenant Data Isolation Failures (Critical)
• Global backend instance cache shared across tenants (5, 6, 26) - Data leakage between users
• Entity registry shared across tenants (11, 14) - Cross-tenant entity visibility
• Knowledge graph queries lack tenant filtering (15, 17) - Information disclosure
• Palace export includes all tenants' data (12, 13) - Mass data exfiltration
• Deduplication operates across all tenants (9, 10) - Privacy violation
• Configuration system lacks tenant isolation (8) - Settings leakage
SQL/NoSQL Injection (High)
• Unvalidated parameters in where clauses (75, 76, 95-98) - Direct SQL injection vectors
• Raw SQL query construction without parameterization (111-113) - Database compromise
• Dynamic predicate construction without validation (84) - Query manipulation
Server-Side Request Forgery (High)
• SSRF via ChromaDB PersistentClient with malicious palace_path (60) - Internal network access
• SSRF via user-controlled LLM endpoint URLs (67, 188) - External service abuse
• Unrestricted Wikipedia API calls (80) - Proxy attacks
Plugin System Vulnerabilities (High)
• Arbitrary code execution via malicious entry points (61, 128) - Supply chain attacks
• Dynamic plugin loading without security boundaries (62, 129) - Untrusted code execution
• Source adapter code execution via entry point exploitation (128) - Plugin compromise
MCP Server Security Issues (High)
• 29 MCP tools exposed without authentication (99-101) - Unauthorized access to all functionality
• Race condition vulnerabilities in MCP server (923) - Concurrent access issues
• Lack of LLM security boundary (924) - Prompt injection and data exfiltration
Architectural Vulnerabilities (Critical)
• Architectural SQL/NoSQL injection patterns (916) - Systemic query construction flaws
• Architectural graph traversal injection (917) - Knowledge graph manipulation
• Architectural filter injection in search (918) - Search query tampering
• Architectural multi-tenant isolation failure (920) - Systemic data leakage
• Architectural shell injection in hook system (922) - Systemic command execution flaws
ATTACK CHAINS
1. Tenant Data Exfiltration Chain: An attacker can exploit the lack of tenant isolation (4-15, 17-26) combined with the MCP server's lack of authentication (99-101) to access all users' data. The export functionality (12-13) provides a direct exfiltration path.
2. Shell Injection to Full Compromise: The hook system's shell injection vulnerabilities (2-3, 45-54) chain with PID file race conditions (16) and command injection in subprocess calls (89) to achieve arbitrary code execution with the privileges of the MemPalace process.
3. Plugin Supply Chain Attack: The plugin architecture (61-62, 128-130) allows loading untrusted code, which combined with the MCP server's lack of authentication (99-101) creates a remote code execution vector through malicious plugins.
4. SSRF to Internal Network: User-controlled LLM endpoints (67, 188) and ChromaDB paths (60) enable SSRF attacks that can reach internal services, potentially accessing sensitive internal APIs or cloud metadata endpoints.
VERDICT
Immediate Critical Fixes Required:
1. Shell injection in hooks - Replace eval with safe JSON parsing and sanitize all shell command inputs
2. Multi-tenant isolation - Implement tenant context throughout the data layer, especially in backend caching and queries
3. MCP server authentication - Add authentication/authorization to all MCP tools before deployment
4. SQL injection vectors - Parameterize all database queries and validate all user inputs
High Priority:
5. Plugin security - Sandbox plugin execution and validate entry points
6. SSRF protection - Validate and restrict external URL connections
7. Race conditions - Fix PID file handling and concurrent access issues
The codebase has systemic security issues that require architectural changes, particularly around tenant isolation and input validation. The hook system and MCP server are the most exposed attack surfaces.