T05 · Unauthorized Access and Privilege Escalation
- Location
datapulse/core/entities.py:363- Finding
Implicit Local API Key Exfiltration Through a Caller-Controlled LLM Endpoint
- Content
View full analysis
str: key = env_name.upper().strip() if not key: return "" candidate_paths = [] configured = os.getenv("DATAPULSE_LOCAL_SECRET_FILE", "").strip() if configured: candidate_paths.append(Path(configured).expanduser()) else: candidate_paths.append(_DEFAULT_OBSIDIAN_SECRET_FILE) for path in candidate_paths: value = _read_secret_file(path).get(key) if value: return value return "" def get_secret(env_name: str, *, default: str = "", required: bool = False, required_for: str | None = None) -> str: env_defined = env_name in os.environ if env_defined: value = os.getenv(env_name, "").strip() else: value = (default or "").strip() if not value and not env_defined: value = _load_local_secret(env_name) if required and not value: raise ValueError(f"{required_for or env_name} is required") return value ``` The MCP tool exposes a caller-controlled LLM base URL: ```python @app.tool() async def extract_entities( url: str, mode: str = "fast", store_entities: bool = True, llm_api_key: str | None = None, llm_model: str = "gpt-4o-mini", llm_api_base: str = "https://api.openai.com/v1", ) -> str: return await _run_extract_entities( ...[truncated 3687 chars]- Remediation
View remediation
