T09 · Insecure Skill Coding Practices
- Location
src/perplexity_toolkit/verify.py:62- Finding
Automatic Citation Verification Permits Blind SSRF
- Content
View full analysis
Vulnerability Details
File Location:
src/perplexity_toolkit/verify.py:62-77
Related Call Path:src/perplexity_toolkit/utils/antidetect.py:213-216,src/perplexity_toolkit/search.py:392-396,src/perplexity_toolkit/commands/cli.py:492-496
Vulnerability Type: Server-Side Request Forgery (SSRF) through untrusted citation URLs
Risk Level: MediumComplete Code Snippets
Citation URLs are extracted from the Perplexity result page with only a string-prefix check:
python // Sources const seen = new Set(); r.sources = Array.from(main.querySelectorAll("a[href]")) .map(a => ({text: a.textContent.trim().substring(0, 200), href: a.href})) .filter(l => l.href.startsWith("http") && !l.href.includes("perplexity.ai") && l.text.length > 2) .filter(l => { if (seen.has(l.href)) return false; seen.add(l.href); return true; });Verification runs automatically unless explicitly disabled:
python result = _search_with_retry(query, mode, cfg, driver, wait_seconds, expand, new_tab) if verify and not result.get("error"): result = verify_result(result)The CLI enables verification by default:
python parser.set_defaults(verify=True) parser.add_argument("--verify", dest="verify", action="store_true", help="Verify sources and answer quality (default)") parser.add_argument("--no-verify", dest="verify", action="store_false", help="Skip source and answer-quality verification")The extracted URL is fetched directly without destination validation:
python def _readback_source(src: Dict, timeout: float) -> Dict: """Fetch bounded page content for a source without retaining the body.""" url = src.get("href", "") base = {"text": src.get("text", "")[:80], "href": url, "claim_support": "not_evaluated"} if not url or not url.startswith("http"): return {**base, "status": 0, "state": "invalid"} try: req = urllib.request.Request( u ...[truncated 3354 chars]- Remediation
View remediation
Remediation Suggestions
- Parse URLs with
urllib.parse.urlsplit()and permit only exacthttpandhttpsschemes. - Reject URLs containing credentials, malformed hosts, ambiguous numeric IP representations, or unsupported ports.
- Resolve the hostname before connecting and reject every address classified as loopback, private, link-local, multicast, reserved, or unspecified.
- Disable automatic redirects or validate every redirect target using the same policy before following it.
- Re-resolve and validate immediately before connection to reduce DNS-rebinding exposure.
- Apply outbound firewall or proxy controls so the process cannot reach localhost, private networks, link-local metadata services, or other sensitive ranges.
- Consider making citation readback opt-in rather than enabled by default, especially when citations originate from externally generated content.
- Preserve bounded response sizes and timeouts, but do not treat them as SSRF defenses.
- Add regression tests covering IPv4, IPv6, encoded IP forms, DNS names resolving to private addresses, and public-to-private redirect chains.
- Parse URLs with
