No commit activity in last 3 years
No release in over 3 years
Extends Rails to be strict CSRF token protection
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 3.1
 Project Readme

What does this gem do?¶ ↑

This gem tries to help you detect CSRF vulnerabilities by making sure all requests that change the state of the application are verified.

Application state changes currently supported:

  • Database updates (via ActiveRecord).

This addresses to possible CSRF scenarios:

  1. You have a GET method that modifies database. Rails skips verification for GET methods and thus your action is ripe for an CSRF exploit.

  2. You had a POST action that wasn’t modifying the database, so you removed Rails CSRF protection on it. Later on someone added database access, making your action ripe for CSRF exploit.

In both cases this gem checks whether an action request verification occured. If not and database changes occured, it throws an exception.

This gem also modifies Rails verified_request? method to return false for GET requests. However, the behavior of allowing GET requests without verification (assuming they did not induce an application state change) is still permitted.

How does it tell whether a database query is read or write?¶ ↑

Database adapters tend to return a fixnum of rows affected for write queries. If return from the adapter is an enumerable (e.g. an array), it is considered read. Otherwise, it is considered write.

If you find an issue with this approach, please contact me.

License and Copyright¶ ↑

All of the code is copyrighted by Google and is released under MIT license.