T09 · Insecure Skill Coding Practices
- Location
cf-img-gen.js:96- Finding
Arbitrary Ollama Endpoint Enables SSRF and Cleartext Prompt Disclosure
- Content
View full analysis
{ const bodyStr = typeof body === 'string' ? body : JSON.stringify(body); const parsedUrl = new URL(url); const isHttps = parsedUrl.protocol === 'https:'; const lib = isHttps ? https : http; const reqOptions = { hostname: parsedUrl.hostname, port: parsedUrl.port || (isHttps ? 443 : 80), path: parsedUrl.pathname + parsedUrl.search, method: options.method || 'POST', headers: { 'Content-Type': 'application/json', ...(options.headers || {}), 'Content-Length': Buffer.byteLength(bodyStr), }, }; const req = lib.request(reqOptions, (res) => { const chunks = []; res.on('data', c => chunks.push(c)); res.on('end', () => resolve({ status: res.statusCode, headers: res.headers, buffer: Buffer.concat(chunks) })); }); req.on('error', reject); req.setTimeout(options.timeout || 120000, () => req.destroy(new Error('Request timeout'))); req.write(bodyStr); req.end(); }); } ``` ```javascript async function enhancePromptOllama(prompt, ollamaOptions = {}) { const host = ollamaOptions.host || process.env.OLLAMA_HOST || OLLAMA_DEFAULT_HOST; const model = ollamaOptions.model || process.env.OLLAMA_MODEL || OLLAMA_DEFAULT_MODEL; const timeout = ollamaOptions.timeout || 30000; const systemPrompt = `You are an expert at writing detailed, vivid image generation prompts. Given a short user description, expand it into a rich, detailed prompt that will produce a high-quality AI-generated image. Focus on visual details: lighting, composition, style, mood, colors, textures, and atmosphere. Kee ...[truncated 3507 chars]- Remediation
View remediation
