What is the Referer header?
RefererThe Referer HTTP request header (famously misspelled in the original RFC 1945 standard, a misspelling that persists in technical specifications today) is a mechanism utilized by web browsers to inform a destination server about the origin of a request. When a user clicks a link, or when a browser fetches a subresource like an image or a script, the browser automatically attaches the URL of the current page to the outgoing request via this header.
While invaluable for analytics, logging, and application logic, the unrestrained transmission of this data presents severe privacy and security risks.
What data leaks via Referer
The danger of the Referer header lies in the sheer volume of context embedded within modern URLs. A default browser behavior might transmit the complete, absolute URL, which frequently leaks highly sensitive information to third parties.
Common data leaked includes:
- Full Paths: Internal application routing structures and non-public endpoints.
- Query Parameters: Search terms, filtering criteria, and campaign tracking identifiers.
- Session Tokens: Password reset tokens, authorization codes (e.g., in OAuth flows), and session identifiers inadvertently passed in the URL.
- Personally Identifiable Information (PII): Email addresses or usernames exposed in routing paths or query strings.
All 8 policy values explained
The Referrer-Policy HTTP response header was introduced to grant developers granular control over the browser's referrer generation algorithm. It supports eight distinct directives.
no-referrer: The safest, most restrictive policy. The browser entirely omits theRefererheader for all requests.no-referrer-when-downgrade: (Legacy default). Sends the full URL unless navigating from HTTPS to HTTP, in which case it sends nothing.origin: Strips the path and query string, sending only the scheme, host, and port (e.g.,https://example.com/) for all requests.origin-when-cross-origin: Sends the full URL for same-origin requests, but reduces it to the origin for cross-origin requests.same-origin: Sends the full URL for same-origin requests, but completely omits the header for all cross-origin requests.strict-origin: Sends only the origin, but prevents downgrades (HTTPS to HTTP sends nothing).strict-origin-when-cross-origin: The modern recommended default. Sends full URL same-origin, origin only cross-origin, and nothing on downgrade.unsafe-url: Extremely dangerous. Sends the full URL (path and query) to every destination, regardless of origin or TLS encryption.
strict-origin-when-cross-origin: the recommended default
For the vast majority of modern web applications, strict-origin-when-cross-origin provides the optimal balance between functional analytics and rigorous user privacy.
This policy ensures that internal navigation maintains full context (useful for internal tracking and debugging), while outbound links and third-party resource requests only receive the domain origin. Furthermore, it strictly enforces transport security by dropping the referrer entirely if the user navigates to an insecure HTTP site.
GDPR implications: leaking authenticated URLs
Regulatory frameworks like the General Data Protection Regulation (GDPR) drastically elevate the importance of the Referrer-Policy header.
Under GDPR Article 5 (Integrity and Confidentiality), organizations are mandated to process personal data securely. If an authenticated dashboard URL contains PII (e.g., https://portal.com/user/[email protected]/settings), and the application lacks a restrictive Referrer-Policy, navigating to an external site or loading a third-party tracking pixel will leak that PII in the Referer header. This constitutes an unauthorized data disclosure and a direct violation of compliance requirements.
Setting Referrer-Policy
The policy can be implemented at multiple levels within the architecture.
- HTTP Header: The most robust method, enforced globally by the web server or reverse proxy.
- HTML Meta Tag: Useful for static sites or when server access is restricted (
<meta name="referrer" content="strict-origin-when-cross-origin">). - Element Attribute: The
referrerpolicyattribute can be applied to individual anchor tags (<a>), images (<img>), or scripts (<script>), allowing developers to override the global policy for specific, high-risk outbound links.
Callout: analytics tools and full referrer data
Important
Marketing and analytics teams frequently request the unsafe-url policy to maximize attribution data. This is a massive security compromise. Analytics tools should be configured to parse origin data or utilize dedicated, secure tracking parameters rather than compromising the entire application's privacy posture.
Impact on analytics
Deploying a restrictive policy like strict-origin-when-cross-origin will alter inbound analytics data. Downstream sites will accurately register the source domain (e.g., google.com or facebook.com), but they will lose visibility into the specific path or search query that drove the traffic.
However, standard UTM parameters (?utm_source=...) appended to the destination URL remain entirely unaffected by the Referrer-Policy, ensuring robust campaign attribution can persist without relying on fragile and insecure Referer leakage.
Server configuration examples
Enforcing the policy via the web server ensures consistent coverage across the application infrastructure.
Nginx:
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
Apache:
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Next.js (next.config.js):
module.exports = {
async headers() {
return [
{
source: '/(.*)',
headers: [
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
],
},
];
},
};
Testing what third parties actually receive
Validating your configuration requires inspecting the outbound requests generated by the browser.
Using the Network tab in browser Developer Tools, you can filter for specific subresource requests (e.g., a third-party analytics script or an outbound image). Inspecting the Request Headers for that specific fetch will accurately reveal the exact value of the Referer header that the browser transmitted, confirming whether your policy is effectively sanitizing the data.
How CyberFurl Helps
Automated monitoring. Zero manual work.
CyberFurl scans your web properties for missing or overly permissive Referrer-Policy headers — flagging the dangerous unsafe-url value that sends full URLs including query parameters (which often contain session tokens, user IDs, or PII) to third-party analytics and ad networks. This is particularly important for GDPR compliance: leaking authenticated URLs to external services constitutes data processing without a lawful basis under Article 5.
