T09 · Insecure Skill Coding Practices
- Location
cite_check.py:37- Finding
Unrestricted Citation Fetching Enables Server-Side Request Forgery
- Content
View full analysis
\"')\]]+", re.IGNORECASE) ``` `cite_check.py:91-110` requests the supplied URL and follows redirects without validating the destination: ```python def check_url(client: httpx.Client, url: str) -> Result: """Resolve a URL. HEAD first; fall back to GET when HEAD is unsupported. We distinguish 'resolved' (the URL is real, status < 400) from a login or paywall soft-200 only at a coarse level here; phase 2 handles content. """ try: r = client.head(url, follow_redirects=True, timeout=12) if r.status_code in (403, 405, 501) or r.status_code >= 500: # Many servers refuse HEAD; retry with a streamed GET (no full body). with client.stream("GET", url, follow_redirects=True, timeout=15) as g: code = g.status_code else: code = r.status_code except httpx.HTTPError as e: return Result("url", url, False, "DEAD", f"{type(e).__name__}: {e}") if code < 400: return Result("url", url, True, "OK", f"HTTP {code}") return Result("url", url, False, "DEAD", f"HTTP {code}") ``` `claim_check.py:161-185` performs a full GET and processes the response body: ```python url = claim.ref try: r = client.get(url, follow_redirects=True, timeout=25, headers={"User-Agent": cc.UA}) except httpx.HTTPError as e: return None, f"fetch failed: {type(e).__name__}" if r.status_code >= 400: return None, f"HTTP {r.status_code}" ctype = r.headers.get("content-type", "") if "pdf" in ctype or url.lower().endswith(".pdf"): try: import fitz # p ...[truncated 3519 chars]- Remediation
View remediation
