Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are websites requiring referer headers (and failing silently)?

I've been noticing a very quirky trend lately and I'm baffled by it. In the past month or two, I've begun to notice sites breaking without a referer header.

As background: you'll of course remember the archaic days where referer headers were misused to do a whole bunch of things from feature detection to some misguided appearance of security. There are still some legacy sites that depend on it, but for the most part refer headers have been relegated to shitty device detection.

Imagine my surprise when not one, but three modern websites are suddenly breaking without a referer.

  1. Codepen: pen previews and full page views just break (i.imgur.com/3abXqsC.png). But editor view works perfectly.

  2. Twitter: basically every interactive function breaks. If you try to tweet, retweet, favourite, etc. you get a generic no-descriptive error (i.imgur.com/E6tIKFo.png). If you try to update a setting, it just flat out refuses (403) (i.imgur.com/51e2d0M.png).

  3. Imgur: It just can't upload anything (i.imgur.com/xCWpkGX.png) and eventually gives up (i.imgur.com/iO2UlR6.png).

All three are modern websites. Codepen was already broken since I started using it so I'm not sure if it was always like that, but Twitter and Imgur used to work perfectly fine with no referer. In fact I had just noticed Imgur breaking.

Furthermore, all of them only generate non-descriptive error messages, if at all, which do not identify the problem at all. It took a lot of trial and error for me to figure it out the first two times, now I try referer headers as one of the first things. But wait! There's more! All it takes to un-bork them is to send a generic referer that's the root of the host (i.e. twitter.com, codepen.io, imgur.com). You don't even need to use actual URLs with directory paths!

One website, I can chalk it up to shitty code. But three, major, modern websites - especially when they used to work - is a huge head scratcher.

Has anybody else noticed this trend or know wtf is going on?

like image 317
referermadness Avatar asked Oct 31 '22 13:10

referermadness


1 Answers

While Referer headers don't "add security", they can be used to trim out attempts from browsers (that play by refer rules) which invoke the request. It's not making the site "secure" from any HTTP attempt, but it is a fair filter for browsers (running on behalf of, possibly unsuspecting, users) acting-as proxies.

Here are some possibilities:

  1. Might prevent hijacked (or phished) users, and/or other injection attacks on form POSTS (non-idempotent requests), which are not constrained to Same-Origin Policy.
  2. Some requests can leak a little bit of information, event with Same-Origin Policy.
  3. Limit 3rd-party use of embedded content such as iframes, videos/images, and other hotlinking.

That is, while it definitely should not be considered a last line of defence (eg. it should not replace proper authentication and CSRF tokens), it does help reduce some exposure of undesired access from browsers.

like image 61
user2864740 Avatar answered Dec 10 '22 20:12

user2864740