public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Added extra words of caution for guarding against SQL-injection attacks

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@46 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Mon Dec 06 10:08:35 -0800 2004
commit  2575b3b065258162484ebbd2c809d5aa4ced56c7
tree    7ca3d64f0953e317d3226498ff7b219ebf09d8e1
parent  6cc961555d723e23a8a932398fe2aa2073cb8d6e
...
71
72
73
74
75
76
 
 
 
77
 
 
 
 
78
79
80
...
71
72
73
 
 
 
74
75
76
77
78
79
80
81
82
83
84
0
@@ -71,10 +71,14 @@
0
   # end
0
   # end
0
   #
0
- # The +authenticate_unsafely+ method inserts the parameters directly into the query and is thus susceptible to SQL-injection
0
- # attacks if the +user_name+ and +password+ parameters come directly from a HTTP request. The +authenticate_safely+ method, on
0
- # the other hand, will sanitize the +user_name+ and +password+ before inserting them in the query, which will ensure that
0
+ # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query and is thus susceptible to SQL-injection
0
+ # attacks if the <tt>user_name</tt> and +password+ parameters come directly from a HTTP request. The <tt>authenticate_safely</tt> method,
0
+ # on the other hand, will sanitize the <tt>user_name</tt> and +password+ before inserting them in the query, which will ensure that
0
   # an attacker can't escape the query and fake the login (or worse).
0
+ #
0
+ # Beware, that the approach used in <tt>authenticate_unsafely</tt> is basically just a wrapped call to sprintf. This means that you
0
+ # still have to quote when using %s or use %d instead. So find_first([ "firm_id = %s", firm_id ]) is _not_ safe while both
0
+ # find_first([ "firm_id = '%s'", firm_id ]) and find_first([ "firm_id = %d", firm_id ]) are.
0
   #
0
   # == Overwriting default accessors
0
   #

Comments

    No one has commented yet.