I Miss Referer
Tags: http, referer
Published: 2021-04-26 12:15:20

---
title: I Miss Referer
published: true
date: 2021-04-25 22:42:00 UTC
tags: [http, referer]
canonical_url: https://kevincox.ca/2021/04/25/rip-referer/
---

<main><h2 id="what-is-referer"><a href="https://kevincox.ca/2021/04/25/rip-referer/#what-is-referer">What is Referer?</a></h2>

<p>The HTTP <code>Referer</code> [<a href="https://en.wikipedia.org/wiki/HTTP_referer">sic</a>] header has a couple of uses.</p>

<ul>
  <li>For top-level navigation it contains previous URL the user was on.</li>
  <li>For in-page requests it contains the URL of the page that the request originated from.</li>
</ul>

<p>See <a href="https://tools.ietf.org/html/rfc7231#section-5.5.2">the spec</a> for more info.</p>

<h2 id="what-is-happening-to-it"><a href="https://kevincox.ca/2021/04/25/rip-referer/#what-is-happening-to-it">What is Happening to it?</a></h2>

<p>Most <a href="https://github.com/privacycg/proposals/issues/13">modern browsers have changed the default</a> <code>Referrer-Policy</code> (spelled correctly) to <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy#strict-origin-when-cross-origin"><code>strict-origin-when-cross-origin</code></a>. This means that for cross-origin scenarios only the referring origin will be sent. For example if you follow a link on <code>https://<b>source.example</b>/123</code> to <code>https://<b>destination.example</b></code> the browser will send <code>Referer: https://source.example</code>.</p>

<p><strong>This is a good thing</strong> with <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Referer_header:_privacy_and_security_concerns">very legitimate reasons</a> however as the owner of a small personal website I will miss the full utility of this header.</p>

<h2 id="what-are-the-advantages-of-sending-a-full-referer"><a href="https://kevincox.ca/2021/04/25/rip-referer/#what-are-the-advantages-of-sending-a-full-referer">What are the Advantages of Sending a Full Referer?</a></h2>

<p>The main advantage is that as a website operator I can see what websites are sending traffic my way. Especially as my website content often contains personal opinions it is always interesting to see what people have to say. It also satisfies my curiosity to the number of people that come from a particular site.</p>

<h2 id="why-did-the-default-need-to-be-changed"><a href="https://kevincox.ca/2021/04/25/rip-referer/#why-did-the-default-need-to-be-changed">Why Did the Default Need to be Changed?</a></h2>

<p>From my point of view, the primary reason to change the default is to avoid leaking sensitive URLs. Although putting sensitive information in URLs should be avoided it is commonly done. For example Google Docs puts the document ID in the URL (ex: <code>https://docs.google.com/document/d/<b>1ScJODuif5gNW_khf_LCWZG7OKZD7AtUHjzRcxAhieNw</b>/edit</code>). They also offer an access option “Anyone with the link” which allows anyone who knows the URL to access the document. This scheme is reasonably private because Google Docs’ URLs are securely random. Unless you give someone the URL it is effectively impossible to guess it. However it would be bad if following a link in a document or a comment shared the document URL with the linked site! Google was aware of this issue and doesn’t send <code>Referer</code>s from <code>https://docs.google.com</code> but it is easy to imagine a website forgetting to set an appropriate <code>Referrer-Policy</code> and is bitten by the default behaviour. This is one example where the web is insecure by default!</p>

<p>The <code>Referer</code> header can also be used for tracking. Personally I think this is less important but as browsers are starting to crack down on tracking surfaces closing the last leaks will become more and more important.</p>

<p><a href="https://developer.mozilla.org/en-US/docs/Web/Security/Referer_header:_privacy_and_security_concerns">If you didn’t read it the first time, I’ll again link Mozilla’s list of problems with <code>Referer</code>.</a></p>

<h2 id="are-there-any-alternatives"><a href="https://kevincox.ca/2021/04/25/rip-referer/#are-there-any-alternatives">Are There Any Alternatives?</a></h2>

<h3 id="linkbacks"><a href="https://kevincox.ca/2021/04/25/rip-referer/#linkbacks">Linkbacks</a></h3>

<p><a href="https://en.wikipedia.org/wiki/Linkback">Linkback</a> is a general term for protocols notifying a site when it has been linked to. My site supports both <a href="https://en.wikipedia.org/wiki/Pingback">Pingback</a>s and <a href="https://www.w3.org/TR/2017/REC-webmention-20170112/">Webmention</a>s. In fact this is where the comments and mentions below the post come from! If you link to one of my posts and notify my site a link back to your site should eventually appear below the post (subject to moderation).</p>

<p>The major downside to these approaches is that it requires the linking site and linked site to both support a specific protocol and requires the linking site to actively send notifications. Additionally Linkbacks provide no volume information, however paired with the origin information from the <code>Referer</code> header volume can be tracked. (You won’t be able to tell different pages on the same origin apart though.)</p>

<h3 id="web-crawlers"><a href="https://kevincox.ca/2021/04/25/rip-referer/#web-crawlers">Web Crawlers</a></h3>

<p>The next option to find linking sites is asking a web crawler. While most search engines don’t provide a feature for finding which sites link to a specific site they do usually have this information from crawling the web. For example <a href="https://search.google.com/search-console/links">Google</a>, <a href="https://www.bing.com/webmasters/backlinks">Bing</a> and <a href="https://webmaster.yandex.ru">Yandex</a> will provide you with reports on incoming links for no charge. There are other crawlers, mostly aimed at SEO optimization that can give you some of this info as well.</p>

<p>It’s a shame that we need to rely on these massive companies to do us favours, but it isn’t feasible for the average person to crawl the web. Furthermore web crawling is always incomplete and has a significant update delay. Like linkbacks this also doesn’t provide volume information.</p>

<h3 id="possible-future-standards"><a href="https://kevincox.ca/2021/04/25/rip-referer/#possible-future-standards">Possible Future Standards???</a></h3>

<p>I wonder if there could be a way to help independent websites link the web together while preserving user privacy. I had a couple of ideas but none of them seem satisfactory.</p>

<ol>
  <li>Hash the full referrer (maybe with salt?) and pass it in a <code>Referrer-Hash</code> header. This would allow operators to separate the traffic from known referrers. This solves the security issue but provides only minimal privacy benefits. However it still requires some crawling to find the exact referrer URL if it is unknown.</li>
  <li>Aggregate end-of-day reports. If the user could pass the referral information to a trusted third party that party could forward it to the linked website. Possibly something like Tor could be used instead of a trusted party. This separates the link information from the user which has nice privacy benefits. However the trusted third party would need to have access to at least the domain name. (The other information could possibly be encrypted with the website’s TLS certificate.) This also provides some volume information which is nice.
    <ul>
      <li>This would still have to be opt-in or hashed to avoid leaking sensitive URLs.</li>
    </ul>
  </li>
</ol>

<p>I’m not sure if it is really possible to accomplish. Ideally this would be done in browsers so that it works for every site, but it is very difficult to send this information from a browser without enabling tracking. So I guess the best options right now are:</p>

<ul>
  <li>Support sending Pingbacks and Webmentions. You probably also want to support receiving them, but you should be careful about showing them on your site automatically as they are a spam vector.</li>
  <li>If your site doesn’t contain sensitive values in the URLs consider relaxing your <code>Referrer-Policy</code>. However I suspect that browsers will start disabling the more relaxed policies soon to prevent tracking.</li>
</ul>

<p>Let me know if you have other ideas.</p>