3 ms·
SQL injections are a bright spot in Rails' security, actually: to cause them with ActiveRecord, you have to go out of your way to write insecure code. Safe by
by patio11 17y ago
SQL injections are a bright spot in Rails' security, actually: to cause them with ActiveRecord, you have to go out of your way to write insecure code.
Safe by default if you use the easiest way to write code:
User.find params[:id]
User.find_by_favorite_fruit(fruit)
Safe by default in the natural Rails idiom:
User.find(:all, :conditions => ["favorite_fruit = ?", fruit])
To get compromised you have to ask for it:
User.find(:all, :conditions => "favorite_fruit = '#{homerolled_buggy_sql_stripping_regexp_i_copied_from_some_dot_net_guys_blog(fruit)}'")
- tptacek 17y agoRails apps wind up with SQL injection like every other application, patio11. All it takes is someone (a) doing a join that AR doesn't support directly and (b) using it to drive a table with sortable columns, pagination, or selectable column names. This isn't "security theater". When you lose your users table, you don't want all your users to lose their GMail passwords. So you hash them. Why are we even debating this?
- jacquesm 17y agoRails has had SQL injection vulnerabilities before: http://www.rorsecurity.info/2008/09/08/sql-injection-issue-in-limit-and-offset-parameter/ http://www.rorsecurity.info/2008/09/08/sql-injection-issue-i... No need to make a bad situation worse in my opinion, especially if the cost is just about '0'. I see password hashing as just another layer of defense, sure if you have the hashes and infinite time you can do more damage but it would certainly help as a deterrent. Hashed passwords are a secondary strategy, assuming that you have already been compromised how do you contain the damage. If the reddit guys had hashed their passwords instead of storing them in plaintext the fall-out would have been a lot less severe than it was.