A browser can attach source-page information to an outbound request through the HTTP Referer header. That context can help with analytics, navigation flows, and abuse detection, but it can also expose more URL data than a destination needs.
An explicit Referrer-Policy gives a site control over this boundary. The main security objective is simple: send the minimum source context needed for legitimate behavior, especially when a request crosses to another origin.
Treat page URLs as potentially sensitive
Application URLs often carry identifiers and workflow state. Even when a team intends URLs to contain no secrets, routes can accumulate data over time through query parameters, path segments, redirects, or third-party integrations.
Consider a page such as:
https://portal.example/account/orders/48291?view=detailIf that page loads a resource from another origin, a permissive referrer configuration can disclose source information to that destination. The receiving service may then store it in access logs, analytics systems, tracing platforms, or vendor infrastructure.
The first control is architectural: credentials, reset tokens, session material, and other high-value secrets should not be placed in URLs. Referrer controls add another boundary; they are not a substitute for sound URL design.
Set a deliberate site-wide policy
A strong general-purpose starting point is:
Referrer-Policy: strict-origin-when-cross-originThis policy preserves useful detail for same-origin requests, sends only the origin on secure cross-origin requests, and avoids sending referrer data when navigating from HTTPS to HTTP.
Modern browsers commonly apply a restrictive default, but relying on an implicit browser default leaves application intent undocumented and can make behavior harder to audit across clients. An explicit response header states the site’s contract at the server boundary.
For applications that do not need referrer information at all, a stricter option is:
Referrer-Policy: no-referrerThis suppresses the Referer header for requests governed by the policy.
Select policy from actual data flows
Referrer configuration is not a contest to choose the shortest possible header. A policy must fit required navigation and integration behavior.
Common directives include:
| Directive | Same-origin request | Cross-origin request |
|---|---|---|
no-referrer |
sends nothing | sends nothing |
same-origin |
sends referrer | sends nothing |
origin |
sends origin | sends origin |
strict-origin |
sends origin | sends origin except HTTPS-to-HTTP transitions |
strict-origin-when-cross-origin |
can send full referrer | sends origin except HTTPS-to-HTTP transitions |
A full URL can include a path and query string. An origin contains the scheme, host, and port as applicable, without the path or query string.
Before changing policy, inventory features that consume referrer data. Examples include internal analytics, payment return flows, anti-abuse rules, affiliate attribution, and legacy navigation checks. Replace fragile dependencies where practical rather than retaining broad disclosure indefinitely.
Prefer the HTTP response header
Set the policy centrally at a trusted web server, reverse proxy, CDN, or application response layer:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Referrer-Policy: strict-origin-when-cross-originA central header is easier to review and apply consistently than scattered page-level configuration.
A document can also declare policy in HTML:
<meta name="referrer" content="strict-origin-when-cross-origin">This can be useful when HTTP header control is unavailable, but server-side configuration is usually a stronger operational baseline because it can be enforced across document responses from one boundary.
Do not use referrer data as an authorization control
The Referer header is request metadata, not proof of identity or permission. Clients outside a normal browser can omit or construct headers, and browser privacy controls can reduce the data sent.
Code such as this creates a weak security boundary:
if referer starts with trusted_site:
permit sensitive_actionAuthorization must depend on authenticated identity, server-side permissions, resource ownership, and other controls appropriate to the action.
Referrer checks can contribute to telemetry or narrow defense-in-depth logic, but they must not grant access that would otherwise be denied.
Keep CSRF protection independent
Cross-site request forgery defenses should not depend solely on a detailed referrer value. Use established controls such as anti-CSRF tokens, suitable SameSite cookie settings, and origin-aware request validation where appropriate.
A restrictive referrer policy can intentionally remove information that older CSRF logic expects. Security controls should be designed so that improving privacy at one boundary does not silently disable protection at another.
When deploying a stricter policy, test state-changing routes and authentication flows in the same browser environments used by the application.
Account for third-party resources
Pages routinely contact analytics providers, font hosts, media services, payment systems, support widgets, and other external origins. Each cross-origin request is a potential metadata boundary.
Map external destinations and classify the source context each one truly requires:
page
|-- same-origin API -> detailed source context may be useful
|-- payment provider -> origin may be sufficient
|-- image CDN -> origin may be sufficient
`-- unrelated external -> no source context may be neededA site-wide policy supplies a safe baseline. Where a specific integration has a justified requirement, scope any exception narrowly instead of relaxing the entire application.
Apply narrower rules to individual elements only when needed
HTML supports element-level referrer behavior for several request-producing elements. For example:
<a href="https://external.example/" referrerpolicy="no-referrer">
Open external service
</a>An image can use the same concept:
<img
src="https://images.example/banner.png"
referrerpolicy="no-referrer"
alt="Service banner"
>These controls are useful for a destination that needs stricter handling than the document baseline. Avoid a patchwork of permissive exceptions because it becomes difficult to audit as templates evolve.
Protect redirect chains
Navigation may pass through several origins before reaching its final destination. Redirect services, link trackers, authentication brokers, and marketing platforms can each receive request metadata.
Review redirect chains as complete flows rather than evaluating only the first and final URLs. A restrictive policy at the source reduces the data available to intermediate destinations as well.
Also keep sensitive values out of redirect URLs. Once data enters a URL, it can propagate into browser history, logs, screenshots, copied links, and systems unrelated to referrer handling.
Test browser-visible behavior
Validate the deployed response header and the resulting outbound requests. Browser developer tools can show request headers for same-origin and cross-origin traffic.
A compact test matrix should include:
- same-origin navigation;
- HTTPS navigation to another HTTPS origin;
- HTTPS navigation to an HTTP test endpoint in a controlled environment;
- cross-origin image or script requests;
- redirects through an external origin;
- pages with query parameters and nested paths;
- any element-level policy overrides.
Check the actual Referer value received by a controlled destination. Do not infer behavior only from the configured header string.
Automated browser tests can make this property regression-resistant. A test endpoint can record the referrer value and assert that cross-origin requests expose no more than the intended source context.
Deploy changes with observability
A stricter policy can affect systems that quietly depend on detailed referrer URLs. Before rollout, identify metrics tied to attribution, fraud controls, support workflows, and partner integrations.
Deploy in stages when the application has many external dependencies. Compare expected and observed behavior without logging sensitive source URLs merely for debugging.
Useful operational signals include failed partner callbacks, attribution changes, unexpected authorization errors caused by legacy referrer checks, and browser-test failures.
Keep the policy consistent across response paths
Security headers are easy to configure on the primary application response while missing error pages, alternate hostnames, static-site paths, or responses generated by an edge layer.
Check representative responses such as:
/
/login
/account
/404-test
/static/app.jsThe header matters most on documents that initiate navigation or subresource requests. Still, consistent edge configuration reduces surprises and simplifies auditing.
If multiple infrastructure layers can set Referrer-Policy, establish one authoritative configuration source. Conflicting headers or environment-specific overrides make the effective policy harder to reason about.
Use a deployment checklist
Before shipping a referrer policy, confirm these properties:
- Sensitive credentials and recovery material are absent from URLs.
- A deliberate
Referrer-Policyis sent on document responses. - Cross-origin disclosure is limited to the minimum required context.
- Authorization does not trust
Refereras proof of access. - CSRF defenses remain effective when referrer detail is reduced.
- Third-party destinations and redirect chains have been inventoried.
- Element-level exceptions are narrow and documented.
- Browser tests verify actual same-origin and cross-origin behavior.
- Error and alternate response paths receive the intended policy.
- Monitoring can detect integration regressions without collecting unnecessary URL data.
Referrer data sits at the intersection of browser navigation, privacy, and application security. A deliberate policy limits passive metadata exposure while preserving the context that legitimate features require. Combine that policy with clean URL design, independent authorization, robust CSRF defenses, controlled third-party integrations, and browser-level tests to keep source-page information inside its intended boundary.