Re: Can Referer be forged via CSRF over HTTP, or on recent browsers?
Date: April 14, 2010 01:18AM
Thanks for your responses, everyone!
PaPPy, sorry that my question wasn't clear. A quick clarification: I'm not asking whether a malicious user can send a request with a forged Referer: header; of course a malicious user can include anything in their headers that they want, as they control the client. That's not the question.
In Question 1, I'm asking whether malicious site www.evil.com can mount a CSRF attack against www.good.com, if www.good.com checks that all requests include a Referer: header that refers to some URL on www.good.com, and if we also assume that www.good.com uses only HTTPS (i.e., does not serve anything via unencrypted HTTP). That's Question 1. In other words, is checking the Referer header a reliable defense against CSRF, if you use only HTTPS?
Question 2 is a variant, where now www.good.com might serve some content via HTTP, but we assume that the client's browser is fairly recent and up-to-date. I don't know exactly what I mean by recent and up-to-date, so perhaps I should frame Question 2 differently. What's the most recent browser version/plugin version such that www.evil.com can initiate a CSRF attack on www.good.com and arrange to forge the Referer header so it includes good.com in the Referer? And, how widely used is that browser/plugin? (what is its market share? what fraction of users will be susceptible?) That's Question 2. In other words, is checking the Referer header a reliable defense against CSRF, if you somehow know that all your users will be using relatively modern browsers?
PaPPy: Recall that in a CSRF attack, the user visits some site www.evil.com. Evil.com is malicious, and wants to attack the user. The user is not malicious; the user is victimized by this attack. Evil.com is trying to fool good.com into thinking that the user wanted good.com to take some action, when the user did not actually authorize or intend for that to happen.
Barbarianbob: Clever -- I like it. That would be a good attack to check for. Thanks for the idea. But let's assume that the site parses the Referer header correctly, and checks for its own domain name in the hostname portion of the URL, so your attack will not work. Are there any other attacks, assuming www.good.com codes up the Referer check properly?