# Fwd: \[Hacking\] Potential Circumvention of CSRF Protection in Rails 2.1

**URL:** <https://www.ruby-forum.com/t/fwd-hacking-potential-circumvention-of-csrf-protection-in-rails-2-1/153565>\
**Category:** ES\
**Created:** [November 18, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/fwd-hacking-potential-circumvention-of-csrf-protection-in-rails-2-1/153565 "2008-11-18T20:32:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel\_GonzSSSSlez\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d78d45/32.png) [@Manuel\_GonzSSSSlez\_S](https://www.ruby-forum.com/u/Manuel_GonzSSSSlez_S)\
**Post date:** [November 18, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/fwd-hacking-potential-circumvention-of-csrf-protection-in-rails-2-1/153565/1 "2008-11-18T20:32:02Z")

</div>

Sent to you by Manuel GonzÃ¡lez Noriega via Google Reader:

Potential Circumvention of CSRF Protection in Rails  
2.1[http://feeds.feedburner.com/~r/RidingRails/~3/457453697/potential-circumvention-of-csrf-protection-in-rails-2-1](http://feeds.feedburner.com/%7Er/RidingRails/%7E3/457453697/potential-circumvention-of-csrf-protection-in-rails-2-1)  
via Riding Rails - home [http://weblog.rubyonrails.com/](http://weblog.rubyonrails.com/) by michael on  
11/18/08

There is a bug in all 2.1.x versions of Ruby on Rails which affects the  
effectiveness of the CSRF protection given by protect\_from\_forgery.

By design rails does not does not perform token verification on requests  
with certain content types not typically generated by browsers.  
Unfortunately this list also included ‘text/plain’ which can be  
generated by  
browsers.  
Impact

Requests can be crafted which will circumvent the CSRF protection  
entirely.  
Rails does not parse the parameters provided with these requests, but  
that  
may not be enough to protect your application.  
Affected Versions

- All releases in the 2.1 series
- All 2.2 Pre Releases

Fixes

The upcoming 2.1.3 and 2.2.2 releases will contain a fix for this issue.  
Interim Workarounds

Users of 2.1.x releases are advised to insert the following code into a  
file  
in config/initializers/

Mime::Type.unverifiable\_types.delete(:text)

Users of Edge Rails after 2.2.1, should upgrade to the latest code in  
2-2-stable.

The patch for the 2.1.x series is available on  
github[http://github.com/rails/rails/commit/099a98e9b7108dae3e0f78b207e0a7dc5913bd1a](http://github.com/rails/rails/commit/099a98e9b7108dae3e0f78b207e0a7dc5913bd1a).  
This will also apply cleanly to 2.2 pre-releases prior to this  
changeset[http://github.com/rails/rails/commit/f1ad8b48aae3ee26613b3e77bc0056e120096846](http://github.com/rails/rails/commit/f1ad8b48aae3ee26613b3e77bc0056e120096846)released  
on Thursday November 13th at 11:19:53 2008  
CET. Users with edge-rails checkouts after that date, are advised to  
upgrade  
to the latest code in 2-2-stable.

Things you can do from here:

- Subscribe to Riding Rails -  
home[http://www.google.com/reader/view/feed%2Fhttp%3A%2F%2Ffeeds.feedburner.com%2FRidingRails?source=email](http://www.google.com/reader/view/feed%2Fhttp%3A%2F%2Ffeeds.feedburner.com%2FRidingRails?source=email)using  
_Google Reader_
- Get started using Google  
Reader[http://www.google.com/reader/?source=email](http://www.google.com/reader/?source=email)to easily keep up  
with  
_all your favorite sites_
