1. Home
  2. Computing & Technology
  3. Ruby
photo of Amanda & Michael Morin
Amanda and Michael's Ruby Blog

By Amanda & Michael Morin, About.com Guides to Ruby

Security Vulnerabilites in Ruby: What is Cross-Site Request Forgery?

Wednesday November 19, 2008

Cross-Site Request Forgery attacks are nothing new. In fact, websites have been vulnerable to this attack since the beginning of the World Wide Web. Whether they use a form-based login with a cookie or HTTP authentication with the Authorization header, any Website that implicitly authorizes all HTTP requests by its users is vulnerable. Although the vulnerability has always existed, it hadn't been formally classified until around the year 2000 and wasn't widely known until 2005. CSRF is also an easy vulnerability to overlook. Many websites are vulnerable and never even know it. Is your site one of them?

Comments

November 20, 2008 at 8:43 am
(1) Ujjwal Trivedi says:

Is there a way to identify CSRF vulnerabilities in our code and remove them? Does some existing tool/plugin help us with this and other security vulnerabilities?

November 20, 2008 at 8:26 pm
(2) ruby says:

This will be covered in more depth in a later article, but here it is in short.

Forms should be generated by the form helpers, never by hand. The form helpers will generate a hidden field that will prevent CSRF attacks.

RESTful resources should be used, as they preserve the idempotence (a concept discussed in a later article) of requests. In short, GET requests can’t be protected, so they shouldn’t be able to make changes to the site. POST requests should always be protected, anything that changes the state of the site or the user’s interaction with the site (logins, logouts, etc) should be a POST request and protected with the above hidden fields.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss
Community Forum
Explore Ruby
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Ruby

©2009 About.com, a part of The New York Times Company.

All rights reserved.