T09 · Insecure Skill Coding Practices
- Location
scripts/process_media.py:868- Finding
Automatic Disclosure of Transcripts, Local Paths, and API Credentials to an Unrestricted LLM Endpoint
- Content
View full analysis
bool: return bool(LLM_BASE_URL and LLM_API_KEY and LLM_MODEL) def normalize_llm_endpoint(base_url: str) -> str: base_url = base_url.rstrip("/") if base_url.endswith("/chat/completions"): return base_url return f"{base_url}/chat/completions" ``` ```python def call_openai_compatible_llm(messages: list[dict[str, str]]) -> str: url = normalize_llm_endpoint(LLM_BASE_URL) payload = { "model": LLM_MODEL, "messages": messages, "temperature": 0.2, } body = json.dumps(payload, ensure_ascii=False).encode("utf-8") request = Request( url, data=body, headers={ "Content-Type": "application/json", "Authorization": f"Bearer {LLM_API_KEY}", }, method="POST", ) try: with urlopen(request, timeout=LLM_TIMEOUT) as response: response_text = response.read().decode("utf-8", errors="ignore") except HTTPError as exc: raise RuntimeError(f"LLM request failed: {exc.code} {exc.reason}") from exc except URLError as exc: raise RuntimeError(f"LLM connection failed: {exc.reason}") from exc response_data = json.loads(response_text) choices = response_data.get("choices", []) if not choices: raise RuntimeError("The LLM response contains no choices") message = choices[0].get("message", {}) content = message.get("content" ...[truncated 3778 chars]- Remediation
View remediation
