Course contentsShow
← Software Engineering
Lesson 1075 of 1,93332. Security EngineeringFree lesson

Referrer-Policy and Information Leakage

Controlling what referrer information is sent with requests to prevent unintended data disclosure.

Referrer-Policy and Information Leakage

What you'll learn: How to control what referrer information browsers send with requests to protect sensitive data from leaking through URLs.


The Problem: Leaky Referrers

When a user clicks a link from your site to another, browsers typically send a Referer header (yes, the misspelling is historical) that tells the destination where the user came from. This sounds innocent, but URLs often contain sensitive information:

  • Session tokens: https://yoursite.com/dashboard?token=abc123
  • Search queries: https://yoursite.com/search?q=confidential-project-name
  • User identifiers: https://yoursite.com/user/12345/private-documents

If your site links to external resources, you're potentially handing that sensitive data to third parties.

What Is Referrer-Policy?

The Referrer-Policy HTTP header (or corresponding meta tag) lets you control how much referrer information browsers include in outgoing requests. Think of it like choosing what return address to write on an envelope—you can share your full address, just your city, or nothing at all.

Common policies:

Referrer-Policy: no-referrer

Sends no referrer at all (most private, but breaks some analytics).

Referrer-Policy: strict-origin-when-cross-origin

Sends full URL for same-origin requests, only the origin (domain) for cross-origin requests (recommended default).

Referrer-Policy: no-referrer-when-downgrade

Sends full URL unless going from HTTPS to HTTP (old browser default, risky).

Why It Matters

Without proper referrer control, you might leak:

  • Authentication tokens in URLs to ad networks
  • Private document paths to CDNs
  • Internal structure and user IDs to analytics providers

Key Takeaway: Use the Referrer-Policy header to limit what information browsers send when users navigate away from your site, preventing unintended disclosure of sensitive data embedded in URLs. Set it to strict-origin-when-cross-origin or no-referrer for sensitive pages.