Rails 2.1系でCSRFに関するバグ

By design rails 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.

http://weblog.rubyonrails.com/2008/11/18/potential-circumvention-of-csrf-protection-in-rails-2-1

ブラウザから送られてこないであろうコンテントタイプでリクエストがきた場合、CSRFトークンの検証は行わないように作ってあるが、text/plainも検証しないようになっちゃってるってことなのかな。

Rails 2.1系のリリースすべてと2.2-PREリリースが対象らしいです。

もうすぐリリースされる2.1.3と2.2.2では治ってるらしいので、出たらアップデートしてくださいねってことですが、暫定的な対処法として下記があげられています。

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.

http://weblog.rubyonrails.com/2008/11/18/potential-circumvention-of-csrf-protection-in-rails-2-1

Rails2.1系を使ってる人はがんばって対応してください。