Give URL fetching its own service contract
Preview generators and import services need more than a well-formed URL.
Parsing does not decide permission
A service that retrieves a user-supplied URL makes a network request with the server’s connectivity. The application needs to decide which destinations and behaviors are allowed, not merely whether the string can be parsed.
OWASP’s SSRF prevention guidance covers application and network controls, including allowlisting where appropriate and careful handling of redirects and name resolution. A single check at the text-input boundary cannot explain the complete behavior of a fetch operation.
Give the fetcher a contract
Our proposed service contract names the permitted schemes, destination policy, redirect behavior, response size, timeout and content handling. It also specifies whether callers may supply headers. Each option expands the behavior that the service must safely support.
Keep the fetcher’s identity and network access limited to its purpose. Review where retrieved bytes go next: a document parser, thumbnailer or indexing pipeline creates a second boundary with its own assumptions.
Observe decisions without retaining secrets
Record the request identifier, policy outcome and a suitably minimized destination description. Avoid treating complete URLs as harmless log fields; they may contain access-bearing query parameters. The operational record should explain why a fetch was allowed or rejected without becoming a second store of sensitive material.