Forum: Ruby on Rails Rails 4: Should a HEAD request not be handled like a GET for CSRF protection?

Posted by Michiel Sikkes (Guest)
on 2013-01-23 13:40
(Received via mailing list)
I am running a Rails 4 app in semi-production and I constantly get
exceptions from crawler bots that use a HEAD HTTP method, which causes 
the
CSRF protection to kick in.

Shouldn't HEAD requests normally be handled like GET requests?

I am not sure if I'm just being stupid or that hit is a bug somewhere.

Michiel
Posted by Robert Walker (robert4723)
on 2013-01-23 20:23
Michiel Sikkes wrote in post #1093276:
> I am running a Rails 4 app in semi-production and I constantly get
> exceptions from crawler bots that use a HEAD HTTP method, which causes
> the
> CSRF protection to kick in.
>
> Shouldn't HEAD requests normally be handled like GET requests?

According to the Rails Guide it seems apparent that only GET request are 
assumed to be safe.

http://guides.rubyonrails.org/security.html#csrf-c...
---------------------------
3.1 CSRF Countermeasures
— First, as is required by the W3C, use GET and POST appropriately. 
Secondly, a security token in non-GET requests will protect your 
application from CSRF.
---------------------------

This document may be oversimplified, but judging by your question I'd 
say it works pretty much as described.
Posted by Jordon Bedwell (Guest)
on 2013-01-23 20:28
(Received via mailing list)
On Wed, Jan 23, 2013 at 1:23 PM, Robert Walker <lists@ruby-forum.com> 
wrote:
>
> http://guides.rubyonrails.org/security.html#csrf-c...
> ---------------------------
> 3.1 CSRF Countermeasures
>  First, as is required by the W3C, use GET and POST appropriately.
> Secondly, a security token in non-GET requests will protect your
> application from CSRF.
> ---------------------------
>
> This document may be oversimplified, but judging by your question I'd
> say it works pretty much as described.

HEAD requests should not be CSRF protected, sounds like a bug needs to
be filed to me.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.