T05 · Unauthorized Access and Privilege Escalation
- Location
mcp_server.py:216- Finding
Arbitrary Local SQLite Database Access and LLM Disclosure
- Content
View full analysis
str: collection = mem.get_chroma_collection() where_filter: dict = {"category": {"$in": ["visit", "feedback"]}} if customer_id: where_filter["customer_id"] = str(customer_id) results = collection.get(where=where_filter, limit=50) if not results or not results["ids"]: return "⚠️ 暂无拜访记录或丢单复盘。请先用 specq_log_visit 沉淀暗数据。" db_data = [] if db_path and db_query and os.path.exists(db_path): try: import sqlite3 conn = sqlite3.connect(db_path) conn.row_factory = sqlite3.Row rows = conn.execute(db_query).fetchall() db_data = [dict(r) for r in rows[:100]] conn.close() except Exception as e: _log.warning(f"本地数据库查询失败: {e}") records_text = json.dumps(records[:20], ensure_ascii=False, indent=2) extra_sections = "" if db_data: extra_sections += f"\n本地数据库数据:\n{json.dumps(db_data[:20], ensure_ascii=False, indent=2)}" user_prompt = f"暗数据记录:\n{records_text}\n{extra_sections}\n\n请提取结构化洞察(最多 {limit} 条):" try: result = await _ask_llm(system_prompt, user_prompt, max_tokens=2000) ``` ### Technical Analysis The MCP tool accepts a caller-controlled filesystem path and an arbitrary SQL statement. It opens any SQLite database readable by the server process and executes the supplied query without restricting the path, tables, columns, or permitted SQL operation. The resulting rows are serialized into `extra_s ...[truncated 1615 chars]- Remediation
View remediation
