Upload Safety, SSRF, and Citation Rendering

Validate file size, type, signatures, archive expansion, and parser behavior; isolate risky parsers. If users submit URLs, block loopback/private/link-local/metadata destinations, restrict schemes and redirects, and revalidate resolved hosts to defend against SSRF. Render plain model text as text and sanitize permitted rich content. Validate citation URLs from trusted metadata; never execute extracted code.

Note

Never fetch arbitrary model-suggested URLs from a privileged backend without network and destination controls.

Implementation example
function validateUrl(raw) {
 const url=new URL(raw);
 if(!["https:","http:"].includes(url.protocol)) throw Error("Bad scheme");
 if(isPrivateOrBlockedHost(url.hostname)) throw Error("Blocked host");
 return url;
}
💡 A real SSRF defense must handle DNS resolution, redirects, IP literals, and rebinding.
Key Takeaways
  • Inspect the relevant pipeline stage instead of guessing.
  • Preserve source provenance, versions, and access scope.
  • Measure quality on representative queries.
Knowledge Check

What is SSRF protection intended to prevent?