T09 · Insecure Skill Coding Practices
- Location
hooks/memory-flush/handler.ts:112- Finding
Session transcripts and global API credentials can be disclosed to an arbitrary endpoint
- Content
View full analysis
= { "Content-Type": "application/json", }; // Ollama uses "Bearer ollama" or no auth; OpenAI uses "Bearer " if (apiKey && apiKey !== "ollama") { headers["Authorization"] = `Bearer ${apiKey}`; } try { const response = await fetch(endpoint, { method: "POST", headers, body: JSON.stringify({ model: model || DEFAULT_EXTRACTION_MODEL, messages: [{ role: "user", content: prompt }], max_tokens: 500, temperature: 0.1, }), }); if (!response.ok) { log("LLM extraction failed", { status: response.status, statusText: response.statusText }); return ""; } const data = await response.json() as { choices?: Array<{ message?: { content?: string } }>; }; const result = data.choices?.[0]?.message?.content?.trim() || ""; if (result === "NONE" || result.length < 10) { return ""; } return result; } catch (err) { log("LLM extraction error", { error: String(err) }); return ""; } ``` The destination and credential are resolved independently: ```ts function resolveApiKey(cfg: Record | undefined): string { const providers = (cfg?.models as Record)?.providers as Record> | undefined; return providers?.openai?.apiKey || process.env.OPENAI_API_KEY || "ollama"; } function resolveBaseUrl(cfg: Record | undefined): string { const hookConfig = (cfg?.hooks as Record)?.internal as Record | undefined; const entries = hookConfig?.entries as Record> | undefined; const flushConfig = ...[truncated 3623 chars]- Remediation
View remediation
