T09 · Insecure Skill Coding Practices
- Location
backend/agent.py:45- Finding
Unrestricted Server-Side URL Fetching Enables SSRF
- Content
View full analysis
str: """Fetch a webpage and convert HTML to markdown.""" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " "AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/120.0.0.0 Safari/537.36" } try: resp = httpx.get(url, headers=headers, timeout=timeout, follow_redirects=True) resp.raise_for_status() return markdownify(resp.text) except Exception as e: return f"[Error fetching {url}] {e!s}" ``` The untrusted URL reaches the fetch function through: ```python for r in results.get("results", []): url = r["url"] title = r.get("title", url) content = fetch_webpage_content(url) texts.append(f"## {title}\n**URL:** {url}\n\n{content}\n---") ``` ### Technical Analysis The application fetches URLs returned by Tavily without validating the URL scheme, hostname, port, resolved IP address, or redirect destinations. The use of `follow_redirects=True` also permits an initially public URL to redirect to an internal destination. Because search results are external and potentially attacker-influenced, they cannot be treated as trusted destinations. A malicious or compromised indexed page could return or redirect to: - Loopback services such as `127.0.0.1` - Private-network addresses - Link-local and cloud metadata endpoints - Internal administrative services - IPv6 loopback, private, or mapped-address variants The fetched response is returned to the research agent, so internal response data can enter the LLM context and potentially be incorporated into the generated report. # ...[truncated 1269 chars]- Remediation
View remediation
