Prevent server-side request forgery by constraining the destinations and request behavior a server-side fetch feature may use, enforcing the boundary at the actual connection, and limiting the workload's network reach and credentials. URL syntax validation alone does not establish permission to contact a destination.
What security boundary does a server-side URL fetch cross?
A server-side URL fetch crosses a permission boundary when input supplied by one actor causes a service to contact another system using the service's own network position and capabilities. A preview generator, document importer, webhook dispatcher or rendering worker may reach destinations unavailable to the person providing the input. The important question is which outbound interaction the feature is allowed to cause, not merely whether the submitted text is a valid URL.
OWASP's API guidance describes server-side request forgery as fetching a remote resource without adequate validation of a user-supplied destination. It recommends restricting destinations and protocols, isolating fetch functionality and avoiding unrestricted exposure of the fetched response. The practical review must include the component that makes the final request. An API may accept an import instruction while a background worker, proxy or external renderer performs the network activity later.
Inventory each fetch feature separately and name its business purpose. A fixed partner document feed and a public-web preview service have different destination requirements. Giving both the same unrestricted HTTP client configuration makes the more constrained feature inherit authority it does not need. Review only owned or explicitly authorized environments, using controlled endpoints and synthetic content for verification.
Define a destination contract before accepting a URL
A destination contract names the permitted scheme, destination class, host or partner identity, port, request method and redirect behavior. For known partners, prefer a configured destination identifier over unrestricted URL input. The application can map that identifier to reviewed connection details and credentials. For a feature that genuinely needs arbitrary public destinations, define public-network permission explicitly and exclude internal, local and platform-management destinations according to the environment's actual network model.
OWASP's prevention guidance separates known-destination and arbitrary-external-destination cases and recommends controls at application and network layers. It highlights redirect and name-resolution concerns. A policy checked only against the initial string can cease to describe the destination actually contacted. Parse with the supported URL and address libraries, normalize the relevant fields consistently, and make the same decision meaningful for the connection path.
Record the failure result a user and operator should receive. A rejected destination should not fall back to a more privileged worker or an unrestricted client. A permitted partner that changes its hosting should trigger review of the contract rather than a global relaxation. Assign exception ownership so a temporary business workaround does not become an unexplained permanent grant.
Compare fetch models by required authority
The comparison below is a design aid for defensive engineering. Choose the narrowest model that supports the feature, then test its permitted and denied behavior. A connector designed for one trusted partner should not be treated as an open fetch service simply because both operations retrieve an HTTP resource.
| Feature model | Destination contract | Useful containment |
|---|---|---|
| Known partner import | Configured partner identifier with reviewed request details | Partner-specific connector identity and limited egress |
| Public document import | Permitted public destinations with explicit response limits | Isolated fetch worker and final-destination enforcement |
| Webhook delivery | Registered and verified destination with defined payload behavior | Bounded retries, destination review and scoped sender identity |
| Browser-based preview | Reviewed navigation and subresource behavior | Separate rendering workload with constrained reach and retained state |
Enforce the destination that is actually contacted
Treat parsing, name resolution, redirection and connection establishment as one policy path. The final destination matters even when the original hostname was permitted. Inspect the deployed client's behavior, including proxy configuration and how name resolution is performed. If a controlled egress component makes the final connection, give that component responsibility for enforcing the destination contract instead of assuming an earlier application check controls every later decision.
Make redirect handling explicit. The Fetch standard, for example, defines separate redirect behavior and an algorithm that processes the next location. This illustrates why a fetch is not always one connection to the original input. A feature may reject redirects entirely, or permit only reviewed transitions with the destination decision repeated. Document the actual client's behavior; different HTTP libraries and rendering services do not necessarily share the same defaults.
Define the request independently of arbitrary user input. A partner import may require one fixed method and a dedicated credential, while a public preview should not inherit a user's application authorization header or a broad service credential. Bound response size, duration, acceptable content and downstream parsing. Those limits help make the fetch a defined operation instead of a generic tunnel whose response is copied directly back to the requester.
Limit the worker's network reach and identity
Place the fetch workload where its available connectivity matches the feature's purpose. A public-content worker usually does not need broad access to application databases, administrative services or internal control interfaces. Separate its identity and runtime configuration from the application component that owns sensitive business operations. A compromised or misdirected fetch should not automatically inherit that component's full authority.
Kubernetes NetworkPolicy provides one example of network containment: an egress-isolated workload receives the permissions defined by its applicable policies, subject to a supporting network implementation. The documentation notes that denying all egress also blocks DNS unless separately allowed. Verify the actual cluster and traffic path rather than treating the presence of a policy object as proof that the worker's connections are constrained. Network-level permission also does not express every HTTP-level destination requirement.
Review cloud identity and metadata separately. AWS documents that IMDSv2 uses a session token for instance metadata requests and that instances can require valid tokens. Its IAM guidance recommends permissions limited to required actions, resources and conditions. These are additional containment decisions. Metadata protection does not replace the application's destination policy, and a narrowly configured fetch feature does not excuse an unnecessarily powerful workload role.
Fictional worked example: a public document importer
This fictional defensive example concerns Cove Library, an invented application that imports public documents into a synthetic workspace. The owner approves an isolated test environment and several controlled endpoints. One endpoint represents an allowed public document source, another represents a destination excluded by the feature's policy, and a third returns a redirect to a controlled excluded destination. No unrelated service, customer data or cloud credentials are contacted.
The feature's contract permits a limited document-fetch operation over HTTPS. The application accepts an import request, creates a job and lets a dedicated worker perform the fetch. The worker has no business database credentials. It can publish a validated result through a narrow queue and storage path owned by the importer. Outbound requests go through a controlled egress service that applies the reviewed destination decision to the connection it actually opens.
The team writes expected outcomes before running checks. The allowed synthetic document must import successfully within the chosen size and duration limits. The excluded destination must produce a clear destination-rejected result without a connection from the fetch service. The redirect case must follow the feature's reviewed rule; in this example, redirects are rejected. A slow source and an oversized synthetic response must end as bounded failures rather than consuming the worker indefinitely.
A configuration review discovers an alternate retry client that does not use the egress service. The hypothetical defect is corrected by making retries use the same destination and request contract. The team then checks the ordinary import path, the timeout retry and a worker restart. It does not demonstrate the boundary by contacting a real metadata endpoint. A controlled excluded endpoint and network observations in the owned environment establish whether the relevant connection was attempted.
The operator receives a job identifier, destination-decision reference, policy version, result class and timing. The normal log contains neither the document body nor credentials. Validated content is handled through the application's ordinary storage policy. If a source later requires a redirect or a partner credential, the owner reviews a feature-specific change instead of granting arbitrary destinations and headers to every importer. The example ends with evidence for these checked paths and a clear list of renderer and supplier behaviors that were not part of the review.
Verify the full fetch path in an authorized environment
A useful verification checks the deployed route from accepted input to the final request and subsequent processing. Include the actual worker, proxy, client, resolver configuration and retry path. A unit test of a URL parser can establish parser behavior, but it cannot establish what a different production worker contacts. Use controlled endpoints that make allowed and denied behavior observable without exposing secrets or probing unrelated infrastructure.
Record both success and rejection. For a permitted import, show that the intended synthetic content reaches the expected workspace. For a rejected destination, show the correct error classification and the absence of the forbidden connection through the observed path. If the feature queues work, inspect the job outcome as well as the initial API response. A successful queue operation says that work was accepted, not that the fetch contract was enforced.
- Inventory direct fetches, workers, retry clients, proxies and rendering services.
- Name the permitted scheme, destination class, port, method, redirects and request headers.
- Verify the policy applies to the destination actually connected to after resolution and any approved transitions.
- Check allowed and excluded controlled endpoints using only owned or authorized fixtures.
- Verify size, timeout, content-validation and retry limits with synthetic responses.
- Inspect workload identity, outbound network reach and platform metadata configuration separately.
- Confirm rejected jobs do not fall back to an unrestricted client or return raw sensitive responses.
- Record the runtime configuration, application revision, observed connections and remaining coverage limits.
Make failures useful without exposing fetched material
Distinguish a destination rejection, connection failure, remote timeout and content-validation failure in the internal result model. The operator needs enough context to choose a response, while the user-facing message should reveal only what the product requires. A detailed network error copied into a public response can disclose internal information unrelated to the import task.
Define retry behavior around the cause. A temporary source outage may justify a bounded retry; a destination rejected by policy should not be retried through a different, more permissive route. Keep a stable job identity and evidence of which policy version governed the attempt. If a long-lived queue can execute under updated rules, decide whether jobs revalidate at execution and how an operator sees that change.
Monitor exceptions as maintained grants. Give a partner change or temporary destination addition an owner and review point. When the feature no longer needs the exception, remove it through the normal change process. Operational convenience is easier to sustain when the destination contract remains explainable.
Keep the conclusion proportional to the checked boundary
Destination controls, network containment, workload identity and response limits address related risks through different mechanisms. None should be described as proof that SSRF is impossible everywhere in an application. A passed parser test does not cover redirects or an alternate client. A network policy does not determine whether trusted content is safe to parse. A metadata setting does not define the entire private network boundary.
Start with one fetch feature of meaningful consequence. Write its business contract, trace the final connection, reduce the worker's unnecessary authority and verify the agreed allowed and denied cases. Record the runtime and evidence with the contract. Review again when a client library, worker path, proxy, hosting platform or destination requirement changes. The next step is a precise engineering review, not a wider unapproved investigation of everything the server might reach.
Frequently asked questions
Is URL validation enough to prevent SSRF?
URL validation alone is not enough to establish an SSRF boundary. The application must enforce permission for the destination actually contacted, including the relevant resolution and redirect behavior, and constrain the workload's network reach and credentials.
Does requiring AWS IMDSv2 eliminate SSRF risk?
Requiring AWS IMDSv2 adds protection to instance metadata access, but it does not eliminate SSRF risk across an application. Other internal services and permitted outbound operations remain separate boundaries. Review destination controls, workload egress and identity permissions together.
How can a team verify SSRF defenses without contacting sensitive services?
A team can verify SSRF defenses with controlled allowed and excluded endpoints in an owned or authorized environment. Observe the final connections, job outcomes and rejection behavior using synthetic content. Real credentials or unrelated infrastructure are unnecessary for that defensive check.
BLACKOPS Software. A URL input is a network permission decision. Updated 2026-10-03.
https://blackopssoftware.com/en/articles/ssrf-egress-boundaries/An engineering guide, not a certification or assessment of your system. Examples are illustrative; apply them only to systems you own or are authorized to assess. Primary references are linked alongside the relevant sections.
Trust boundary worksheet
Connect an actor, a protected asset and a trust decision to an abuse scenario, a control and a verification owner.
Use this toolRelated practice
Explore the scope and deliverables of the services connected to this guide.


