T09 · Insecure Skill Coding Practices
- Location
scripts/miner.py:425- Finding
Unsanitized search results can enable indirect prompt injection and Markdown output manipulation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/miner.py:185-197andscripts/miner.py:425-446
Vulnerability Type: Untrusted external content rendered without sanitization
Risk Level: MediumVulnerable Code
Search-result fields are accepted directly from SearXNG:
python for item in data.get("results", []): combined_text = f"{item.get('title', '')} {item.get('content', '')}" results.append({ "company": _extract_company(item.get("title", "Unknown")), "title": item.get("title", ""), "url": item.get("url", ""), "snippet": item.get("content", ""), "source": cat, "stage": _extract_stage(combined_text), "amount": _extract_amount(combined_text), "signal_score": _compute_signal_score(combined_text), "region": _infer_region(combined_text), })The externally controlled values are subsequently placed into Markdown output:
python for i, lead in enumerate(leads, 1): lines.append(f"### {i}. {lead['company']}") lines.append(f"- **Stage:** {lead.get('stage') or 'N/A'}") lines.append(f"- **Region:** {lead.get('region', 'GLOBAL')}") lines.append(f"- **Signal Score:** {lead.get('signal_score', 0)}/100") lines.append(f"- **Source:** {lead.get('source', 'N/A')}") if lead.get("url"): lines.append(f"- **URL:** {lead['url']}") if lead.get("snippet"): lines.append(f"- **Snippet:** {lead['snippet']}") lines.append("")Technical Analysis
Search-result titles, URLs, and snippets originate from websites indexed by SearXNG and must therefore be treated as attacker-controlled input. The implementation copies these values into Markdown without escaping Markdown control characters, validating URL schemes, delimiting retrieved content, or neutralizing instruction-like text.
An attacker who can cause crafted content to appear in relevant search result ...[truncated 1569 chars]
- Remediation
View remediation
Remediation Suggestions
- Treat every SearXNG field as untrusted external data.
- Escape Markdown metacharacters in company names, snippets, stages, sources, and other text fields before rendering.
- Validate URLs with
urllib.parse.urlsplit()and permit only explicitly supported schemes such ashttpsand, if necessary,http. - Render retrieved snippets inside clearly labeled quoted or fenced data blocks and state that their contents are untrusted source material, not executable instructions.
- Apply length limits and remove control characters from all retrieved fields.
- Where output is consumed by another agent, pass records as structured JSON and enforce a policy that instructions contained in retrieved fields must never be followed.
- Consider retaining both raw and sanitized fields internally so output encoding is applied specifically for each target format.
