- Rails SQL injection vulnerability: hold your horses, here are the facts – Phusion Corporate BlogPhusion Corporate Blog
- Let Me Github That For You | Lands of Packets
- CVE - CVE-2012-5664 (under review)
User.find_by_name('foo', :select => 'id, name')
ã¨ããã¨ã
select id, name from users where name = 'foo';
ã£ã¦ãªãã®ã ãã:selectã®é¨åã¯ã¨ã¹ã±ã¼ãå¦çã¨ããã¦ããªãã®ã§ä»»æã®SQLãæ¸ãã¦ãã¾ããã¨ã¯ãããã®ã®ãããã¯å¤é¨ã®å ¥åãå ¥ããã¹ãã§ã¯ãªãã®ã§ãæ®éãããªãã¨ã¯ããªãã
User.find_by_name(params[:name])
ã¨ããã£ã¦ããã¨
http://example.com/foo?name[select]=id,name
ã§{'select' => 'id,name'}ã¨ãªãã®ã ãã©ããã·ã³ãã«ã§ã¯ãªãæååãã¼ã®ããã·ã¥ãªã®ã§å¤§ä¸å¤«ã
ã§ããAuthlogicã§ã¯
User.find_by_persistence_token(the_token)
ã¨ãã£ã¦ãã¦ãRailsã»ãã·ã§ã³ã«ããèªè¨¼ã¡ã½ãããå©ç¨ããã»ãã·ã§ã³ã¹ãã¢ã®è¨å®ãããã©ã«ãã®ã¯ããã¼ã§ããå ´åãã¯ããã¼ããthe_tokenãåå¾ãããã
ãã®å ´åãä»»æã®Rubyã®ãªãã¸ã§ã¯ããä¿åã§ãã¦ãã·ã³ãã«ãã¼ã®ããã·ã¥ãè¨å®ãããã¨ãã§ããã®ã§æ»æã§ãã¡ããããã ããSHA-1 HMACä»ããªã®ã§ãéµãã°ããªãã¨å¤§ä¸å¤«ã
ã§ãã$railsapp/config/initializers/secret_token.rbãããã©ã«ãã®ã¾ã¾ä½¿ãã¨éµããã£ã¡ãããã©ããGithubã¨ãã
ã¨ãã話ã¿ãã
Railså´ã¯æ¢ã«ä¿®æ£ãå ¥ãã¦ãã¦ã
find_by_xxxã®å¼æ°ã®æ°ãxxxã®æ°(xxx_and_yyyã¨ãã§ããã®ã§è¤æ°æå®å¯è½)以ä¸ã®å ´åã¯:selectã¨ãã®ãªãã·ã§ã³ãæå®ã§ããªãããã¨ããå¦çã«ãªã£ã¦ãããfind_by_xxx('xxxã®å¤', ãªãã·ã§ã³)ã¨ãªãã®ã§å¼æ°ã®æ°ãxxxã®æ°ãã大ãããªãããã
ã¾ããã©ã¡ããã¨ããã¨Authlogicã¨ã¢ããªå´ã®åé¡ãªæ°ã¯ãããã©ã