T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- src/chat/manager.rs:237
- Finding
- Unauthenticated Remote Launch of Permission-Bypassed Claude Code Agents<![CDATA[ ## Vulnerability Details **File Location**: `src/main.rs:119-123`, `src/api/routes.rs:430-456`, `src/api/chat_handlers.rs:20-34`, `src/chat/manager.rs:237-275`, `src/chat/manager.rs:360-406` **Vulnerability Type**: Missing authentication combined with unrestricted agent execution **Risk Level**: Critical ### Vulnerable Code ```rust // src/main.rs:119-123 let addr = SocketAddr::from(([0, 0, 0, 0], config.server_port)); tracing::info!("Server listening on {}", addr); let listener = tokio::net::TcpListener::bind(addr).await?; axum::serve(listener, app).await?; ``` ```rust // src/api/routes.rs:430-456 .route( "/api/chat/sessions", get(chat_handlers::list_sessions).post(chat_handlers::create_session), ) .route( "/api/chat/sessions/{id}", get(chat_handlers::get_session).delete(chat_handlers::delete_session), ) .route( "/api/chat/sessions/{id}/stream", get(chat_handlers::stream_events), ) .route( "/api/chat/sessions/{id}/messages", get(chat_handlers::list_messages).post(chat_handlers::send_message), ) .route( "/api/chat/sessions/{id}/interrupt", post(chat_handlers::interrupt_session), ) ``` ```rust // src/chat/manager.rs:237-275 pub fn build_options( &self, cwd: &str, model: &str, system_prompt: &str, resume_id: Option<&str>, ) -> ClaudeCodeOptions { let mcp_path = self.config.mcp_server_path.to_string_lossy().to_string(); let mut env = HashMap::new(); env.insert("NEO4J_URI".into(), self.config.neo4j_uri.clone()); env.insert("NEO4J_USER".into(), self.config.neo4j_user.clone()); env.insert("NEO4J_PASSWORD".into(), self.config.neo4j_password.clone()); env.insert( "MEILISEARCH_URL".into(), self.config.meilisearch_url.clone(), ); env.insert( "MEILISEARCH_KEY".into(), self.config.meilisearch_key.clone(), ); let mcp_config = McpServerConfig::Stdio { command: mcp_path, args: None, env: Some(env), }; ...[truncated 2643 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require strong authentication for every chat and administrative endpoint. 2. Enforce per-user authorization and session ownership checks. 3. Replace `PermissionMode::BypassPermissions` with a restrictive permission mode. 4. Canonicalize `cwd` and reject any path outside an explicitly configured workspace root. 5. Bind to `127.0.0.1` by default unless an authenticated reverse proxy is configured. 6. Run each agent in an isolated sandbox with: - A read-only filesystem where possible. - A dedicated unprivileged user. - No host home-directory access. - Restricted outbound network access. - Resource and execution limits. 7. Maintain an allowlist of permissible MCP tools and require approval for destructive operations. 8. Add security tests proving that unauthenticated requests and out-of-workspace paths are rejected. ]]>
