Join our Newsletter — 33% off our NHI Course
Home› Guides› Referrer-Policy Header Guide: Stopping Token and URL Leakage…
Guide Web & API Security

Referrer-Policy Header Guide: Stopping Token and URL Leakage Through the Referer

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 15 min read
On this page

Every time a page loads an image, script or iframe, or a user follows a link, the browser can tell the destination which URL the request came from, and if that URL holds a reset token, an authorisation code or a customer ID, the destination now has it too. The Referer request header and the Referrer-Policy response header that controls it are small, but they decide whether sensitive URLs stay inside your origin. This guide is written as a policy you can adopt: a recommended site-wide value, rules for sensitive pages, per-element overrides and a test plan. It is for web developers, AppSec engineers and platform teams who own response headers. For the wider header set (CSP, HSTS, framing and cross-origin isolation) see the Security Headers Guide; this page goes deep on the referrer only.

Key takeaways

  • The Referer header can carry reset tokens, authorisation codes and customer IDs to other origins; the Referrer-Policy response header controls what is sent.
  • Set strict-origin-when-cross-origin as the site-wide default, the value the current W3C Editor's Draft names, and list any looser exception with a reason and an expiry date.
  • A policy value is a mitigation, not a fix: keep tokens and personal data out of URLs, as OWASP ASVS 5.0 V14.2.1 requires, so nothing sensitive can leak through any header.
  • RFC 9700 names authorisation codes and the state parameter as the most serious values exposed through Referer, so OAuth and OIDC redirect endpoints need the tightest policy.
  • Test the header at the CDN, load balancer or web server, and review the standard at least yearly and whenever browser defaults change.

How to use this template

Sections 1 to 6 are written so you can copy them into an engineering standard, replacing [Organisation] and the bracketed values. Section 3 sets the default every application inherits. Section 4 is the part that actually prevents token leakage, because a Referrer-Policy value is a mitigation, not a fix: a token that never appears in a URL cannot leak through any header. The closing implementation guidance gives a rollout order, a test plan and the metrics to report.

  • Owner: [AppSec lead] owns the standard; [platform or edge team] owns the header configuration at the CDN, load balancer or web server.
  • Review cycle: review at least yearly and whenever browser defaults or the W3C specification change. The W3C Referrer Policy document is still being edited: the Editor's Draft dated 20 March 2026 sets the default to strict-origin-when-cross-origin, while the older 2017 Candidate Recommendation still names no-referrer-when-downgrade (checked November 2026).
  • Exceptions: any page that needs a looser value than the default is listed in an exceptions register with a business reason and an expiry date.

1. Purpose

This standard ensures that [Organisation] web applications do not disclose sensitive URL paths, query strings or tokens to other origins through the Referer header, while keeping the referrer information that analytics, logging and CSRF defences legitimately need. It supports OWASP ASVS 5.0 requirement V3.4.5 (set a referrer policy to prevent leakage of technically sensitive data to third parties) and V14.2.1 (sensitive data such as API keys and session tokens must not be sent in the URL or query string).

Why it matters: RFC 9110 section 10.1.3 notes that the Referer field can reveal browsing history and confidential resource names, and RFC 9700 (the OAuth 2.0 Security Best Current Practice) devotes section 4.2 to credential leakage through Referer headers, naming authorisation codes and the state parameter as the most serious values exposed.

2. Scope

  • In scope: every HTML response served by [Organisation] on any domain or subdomain, including marketing sites, customer portals, admin consoles, single page applications, OAuth and OIDC redirect endpoints, embedded widgets and email landing pages.
  • Also in scope: stylesheets served from [Organisation] domains, because external CSS uses its own response's referrer policy, not the page's (MDN).
  • Also in scope: URL design for links that carry state: password reset, email verification, magic links, invitation links, signed download URLs and pagination or search URLs that include personal data.
  • Out of scope: server-to-server API calls that are not made by a browser (they send no Referer unless code adds one), and native mobile apps, which follow their own HTTP stack.

The browser decides what to send from three facts: whether the request is same-origin or cross-origin, whether it moves from HTTPS to HTTP (a downgrade), and the policy in force. Before anything is sent, the referrer URL is stripped of its fragment, username and password (W3C Referrer Policy). "Origin" below means scheme, host and port, for example https://app.example.com/.

Policy valueSame-origin requestCross-origin HTTPS to HTTPSHTTPS to HTTPTypical use
no-referrerNothingNothingNothingHighly sensitive pages: reset, OAuth callback, payment, admin
same-originFull URLNothingNothingInternal apps that need same-site analytics but share nothing outside
strict-originOrigin onlyOrigin onlyNothingSites that never need paths, even internally
strict-origin-when-cross-originFull URLOrigin onlyNothingRecommended site-wide default; current browser default
originOrigin onlyOrigin onlyOrigin onlyRarely justified: leaks the origin over plain HTTP
origin-when-cross-originFull URLOrigin onlyOrigin onlyAvoid: no downgrade protection
no-referrer-when-downgradeFull URLFull URLNothingAvoid: the old browser default, sends full paths and queries to every HTTPS third party
unsafe-urlFull URLFull URLFull URLProhibited: MDN warns it leaks HTTPS URLs to insecure origins

Browser default: since Chrome 85 (stable August 2020) a page with no policy, or an invalid one, gets strict-origin-when-cross-origin; MDN describes this as the default across browsers and notes the earlier default was no-referrer-when-downgrade. Relying on the default is still not acceptable under this standard. OWASP's HTTP Headers Cheat Sheet recommends setting Referrer-Policy: strict-origin-when-cross-origin explicitly, because defaults differ by browser version, enterprise policy and user configuration.

Standard rule 3.1: every HTML response carries Referrer-Policy: strict-origin-when-cross-origin as a minimum. Applications may choose a stricter value (same-origin, strict-origin, no-referrer). A looser value (origin, origin-when-cross-origin, no-referrer-when-downgrade, unsafe-url) requires an approved exception.

Standard rule 3.2: sensitive pages listed in section 4 carry Referrer-Policy: no-referrer.

Fallback syntax: the header accepts a comma-separated list. Unknown tokens are ignored and the last recognised token wins, so Referrer-Policy: no-referrer, strict-origin-when-cross-origin means "use the second if supported, otherwise the first". Fallback lists work only in the header, not in the referrerpolicy attribute.

Side effect on Origin: the policy also influences the Origin header. MDN notes that for some non-GET requests under no-referrer, same-origin (cross-origin case) or a strict downgrade, the browser may send Origin: null. Check this before applying no-referrer to pages that submit cross-origin forms or rely on Origin checks; see the CSRF Prevention Guide.

4. Handling sensitive URLs and tokens

Referrer-Policy limits one leak path. URLs also end up in browser history, proxy and CDN logs, server access logs, analytics tools, screenshots and shared links. The rules below remove the secret from the URL first and use the header as defence in depth.

  1. Rule 4.1, no bearer secrets in URLs: session IDs, API keys, access tokens and refresh tokens are never placed in a path or query string. Send them in the Authorization header, a cookie with the right attributes (see the Cookie Security Guide) or a POST body. This is ASVS V14.2.1.
  2. Rule 4.2, one-time links are single use and short lived: where a token must travel in a link (password reset, email verification, magic link, invitation), it is random, bound to one purpose, invalidated on first use and expires quickly. MDN recommends single-use reset URLs or combining them with a user token. See the Magic Links and Email OTP Security Guide.
  3. Rule 4.3, exchange then redirect: the landing endpoint for a one-time link validates the token, sets server-side state, then issues a redirect to a clean URL with no token. The page the user sees, and any third-party resource it loads, never has the token in its address.
  4. Rule 4.4, no third-party content on sensitive pages: reset, login, OAuth callback, payment and account recovery pages load no third-party scripts, pixels, fonts or widgets and contain no external links. RFC 9700 section 4.2.4 says the page rendered after the authorisation response should not include third-party resources or links to external sites. A strict Content-Security-Policy enforces this; see the Content Security Policy Guide.
  5. Rule 4.5, no-referrer on sensitive pages: the pages in rule 4.4 also send Referrer-Policy: no-referrer, the example RFC 9700 gives.
  6. Rule 4.6, OAuth and OIDC flows: clients use the authorisation code flow with PKCE, never the implicit grant (RFC 9700 section 2.1.2 says clients should not use response type token). Authorisation codes are single use, state is invalidated after first use, and form_post response mode is preferred where supported so the code does not sit in a URL. Migration detail is in the OAuth Implicit Flow Migration guide and the OAuth 2.0 Security Best Current Practice (RFC 9700) Guide.
  7. Rule 4.7, personal data in query strings: search terms, email addresses, account numbers and health or financial identifiers are sent by POST or held server side, not placed in query strings that same-origin referrers and logs will record.
Sensitive URL typeLeak path through RefererPrimary fixHeader backstop
Password reset or email verification linkFooter link or analytics pixel on the landing pageSingle use, short expiry, exchange then redirectno-referrer on the landing page
OAuth authorisation code and state in callback URLThird-party resource on the redirect page (RFC 9700 section 4.2)Code flow with PKCE, single-use code, form_postno-referrer on the callback
Access token in URL fragment (implicit grant)Browser implementation issues noted by RFC 9700; history and logsRetire the implicit grantFragments are stripped from Referer, but do not rely on it
Signed or pre-signed download URLDocument links or embedded resources opened from itShort validity, scoped to one object, issue on demandno-referrer on pages that display the link
Session ID or API key in query stringAny cross-origin request under a loose policy, plus all same-origin requestsMove to header or cookieNot sufficient: same-origin requests still carry the full URL

5. Per-element overrides

The policy can be set in several places. When more than one applies, the more specific one is used for that request, so element-level settings can tighten or loosen the page policy.

  • HTTP header: Referrer-Policy on the response. Preferred: set centrally and visible in scans.
  • Meta element: <meta name="referrer" content="no-referrer"> sets a document-wide policy where headers cannot be changed (for example static hosting). Note the hyphen: MDN points out that the meta value is written no-referrer, while the link relation is written noreferrer.
  • referrerpolicy attribute: on a, area, img, iframe, script and link, for example <img src="https://pixel.example/p.gif" referrerpolicy="no-referrer">. Use it to strip the referrer from a specific third-party resource on an otherwise normal page. The attribute takes one value only.
  • rel="noreferrer": on a, area and link. It sends no referrer for that navigation and, for links that open new windows, also stops the new page reaching back through window.opener.
  • Stylesheets: requests made from an external stylesheet use that stylesheet's own response policy (default strict-origin-when-cross-origin) unless its response carries a Referrer-Policy header; inline style elements use the document's policy. Set the header on CSS responses too.

Standard rule 5.1: a referrerpolicy attribute or meta element may make a request stricter than the page header without approval. Any element-level value looser than the site default (for example referrerpolicy="unsafe-url" to satisfy a partner's tracking) needs an exception, because it silently undoes the header for that request. Code review and linting flag these attributes.

6. Testing and monitoring

  1. Header presence: automated checks on every deployment confirm each HTML and CSS response carries a Referrer-Policy header with an approved value. Include this in the header baseline scan described in the Security Headers Guide.
  2. Effective policy: in browser developer tools, inspect outgoing requests from sensitive pages and confirm no Referer is sent to other origins, and that cross-origin requests from normal pages carry only the origin. Chrome's guidance also suggests reading document.referrer on a test receiving page.
  3. URL secret scanning: search access logs, CDN logs and analytics exports for token-like query parameters (names such as token, code, key, session, sig, reset) and high-entropy values.
  4. Third-party inventory: list every third-party request made by sensitive pages. The target is zero.
  5. Override audit: grep templates and front-end code for referrerpolicy, rel="noreferrer", rel="noopener" and meta name="referrer" values looser than the default.
  6. Breakage watch: after tightening, watch for failed cross-origin form posts, Origin checks rejecting null and analytics or affiliate reports losing path data. Chrome's guidance recommends Origin and Sec-Fetch-Site headers instead of full referrers for CSRF checks and logging.

Implementation guidance

Rollout order. The header is low risk, but tightening it can break code that reads the referrer path, so roll out in rings.

  1. Inventory: scan all public and internal hostnames for the current Referrer-Policy value and record which pages carry tokens in URLs (log search, step 3 above).
  2. Fix the URLs first: move session IDs and API keys out of query strings, make reset and magic links single use with exchange then redirect, and retire implicit grant clients. This removes the real exposure.
  3. Set the default at the edge: add Referrer-Policy: strict-origin-when-cross-origin at the CDN, load balancer or web server for all responses, starting with a pilot hostname, then internal apps, then customer-facing sites.
  4. Tighten sensitive pages: apply no-referrer and remove third-party content on reset, login, OAuth callback, payment and admin pages. Test cross-origin form posts and Origin validation on each.
  5. Roll back safely: header changes are configuration, so keep the previous value in version control and revert per route. Do not roll back the URL fixes in step 2.
  6. Lock it in: add header checks to CI and the external attack surface scan, add the lint rule for loose overrides and add "no secrets in URLs" to code review guidance.

Small and large organisations. A small team with one site can set the header in the web server or hosting platform and spend its effort on rule 4.2. A large estate should set the default centrally at the edge so new applications inherit it, keep the exceptions register short, and measure coverage per hostname.

Metrics to report.

  • Percentage of hostnames and HTML responses with an approved Referrer-Policy value (target 100%).
  • Number of sensitive pages making any third-party request (target 0).
  • Count of token-like parameters found in access or analytics logs per month, trending to zero.
  • Number of open referrer exceptions, and how many are past expiry.
  • OAuth clients still using the implicit grant (target 0).

Common failure patterns

  • Trusting the browser default: teams assume strict-origin-when-cross-origin protects them, but same-origin requests still carry the full URL, so a token in the query string is still written to the site's own logs and analytics.
  • Analytics on the reset page: a tag manager injected globally adds third-party pixels to the reset or callback page, which is exactly the leak path RFC 9700 and MDN describe.
  • Loosening for a partner: unsafe-url or no-referrer-when-downgrade is set site-wide to keep an affiliate report working, exposing every path and query to every third party.
  • Header set twice with different values: the application and the CDN both add Referrer-Policy; browsers treat the result as a list and the last recognised value wins, which may be the looser one.
  • Breaking CSRF checks: no-referrer is applied to pages that post cross-origin forms, the browser sends Origin: null, and the server either rejects legitimate requests or someone disables the Origin check to fix it.

Framework mapping

FrameworkReferenceHow this standard supports it
OWASP ASVS 5.0V3.4.5Referrer policy set to prevent leakage to third parties (section 3)
OWASP ASVS 5.0V14.2.1No sensitive data in URLs or query strings (section 4)
OWASP ASVS 5.0V10.6.1Implicit flow response types not used by the OpenID Provider (rule 4.6)
NIST SP 800-53 Rev. 5CM-6 Configuration SettingsHeader value set as a mandatory configuration baseline
NIST SP 800-53 Rev. 5SC-8 Transmission Confidentiality and IntegrityLimits disclosure of URL data in transit to other parties
NIST CSF 2.0PR.DS-02, PR.PS-01Data-in-transit protection and configuration management
CAPECCAPEC-593 Session HijackingSession identifiers in URLs are a route to hijacking
MITRE ATT&CK v20T1550.001 Application Access TokenLeaked tokens and codes can be replayed against APIs

Practitioner checklist

  • Set Referrer-Policy: strict-origin-when-cross-origin explicitly on every HTML and CSS response.
  • Set Referrer-Policy: no-referrer on reset, login, OAuth callback, payment and admin pages.
  • Remove all third-party scripts, pixels and external links from those sensitive pages.
  • Move session IDs, API keys and access tokens out of URLs into headers, cookies or POST bodies.
  • Make reset, verification and magic links single use and short lived, and redirect to a clean URL after validation.
  • Retire implicit grant clients and use the code flow with PKCE, single-use codes and form_post where supported.
  • Ban unsafe-url and no-referrer-when-downgrade without an approved, expiring exception.
  • Scan logs and analytics monthly for token-like query parameters.
  • Test Origin-based CSRF checks after applying no-referrer to pages that post forms.

Standards and references

Related NHI Mgmt Group resources: Security Headers Guide · Content Security Policy Guide · Cookie Security Guide · OAuth 2.0 Security Best Current Practice (RFC 9700) Guide · Permissions Policy, COOP, COEP and CORP Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.