Why it matters
- When a visitor follows a link, or the page loads a file from another site, the browser sends a
Refererheader with the address of the page it came from. An address can say more than it should: MDN warns of internal addresses, and of parameters that hold private data. - A referrer policy says how much of the address to send. Current browsers default to
strict-origin-when-cross-origin: the full address within your site, the origin alone to other sites, and nothing from HTTPS to HTTP. That is why this rule is information, and never costs the page points. - Before a change to the standard in November 2020, the default was
no-referrer-when-downgrade, which sends other sites the full address. Stating the policy covers browsers from before the change, and says it is a choice.
Example
<meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="utf-8" /> <meta name="referrer" content="strict-origin-when-cross-origin" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
How to fix
Send the policy OWASP recommends, which is also the browsers' default:
http
Referrer-Policy: strict-origin-when-cross-origin- Apache (mod_headers):
Header always set Referrer-Policy "strict-origin-when-cross-origin" - nginx:
add_header Referrer-Policy strict-origin-when-cross-origin always; - Cloudflare: a Response Header Transform Rule that sets the header.
- Without access to the server, set it in
<head>:<meta name="referrer" content="strict-origin-when-cross-origin" />, with a single value. - If your addresses hold private data, choose a stricter policy:
same-originsends nothing to other sites, andno-referrersends nothing at all.
How we detect
- The rule applies to HTML pages that answer 2xx on a public site. Local development hosts, such as
localhost, private addresses and names ending in.test, are left out, as for the HTTPS rule. - We read the
Referrer-Policyheaders as browsers do: their values split at commas, and the last one browsers know wins, so a new policy can fall back on an older one. A value made of anything but letters and hyphens makes the header invalid. Policies are read whatever their case, as Chromium reads them. - A
<meta name="referrer">counts anywhere in the page, with a single value in any case, the old values HTML still accepts included:never,default,alwaysandorigin-when-crossorigin. - A
referrerpolicyattribute, orrel="noreferrer", sets the policy of one link or file, not of the page, so it does not count. - The finding is information: it is never deducted from the score.