Rails Rails 爆出严重安全漏洞,所有版本需马上升级!

blacktulip · 2013年01月09日 · 最后由 JeskTop 回复于 2013年01月09日 · 2762 次阅读


I'd like to announce that 3.2.11, 3.1.10, 3.0.19, and 2.3.15 have been released. These releases contain two extremely critical security fixes so please update IMMEDIATELY.

最近 Rails 爆菊有点频繁嘛...

还好我只是用 Ruby 而已...



Due to the way Active Record interprets parameters in combination with the way that JSON parameters are parsed, it is possible for an attacker to issue unexpected database queries with "IS NULL" or empty where clauses.  This issue does *not* let an attacker insert arbitrary values into an SQL query, however they can cause the query to check for NULL or eliminate a WHERE clause when most users wouldn't expect it. 

For example, a system has password reset with token functionality: 

    unless params[:token].nil? 
      user = User.find_by_token(params[:token]) 

An attacker can craft a request such that `params[:token]` will return `[nil]`.  The `[nil]` value will bypass the test for nil, but will still add an "IN ('xyz', NULL)" clause to the SQL query. 

Similarly, an attacker can craft a request such that `params[:token]` will return an empty hash.  An empty hash will eliminate the WHERE clause of the query, but can bypass the `nil?` check. 

Note that this impacts not only dynamic finders (`find_by_*`) but also relations (`User.where(:name => params[:name])`). 

有什么影响么...User.where([]) 这样会有影响,但其实后面还有分页…… 有人提出不同观点 https://github.com/rails/rails/issues/8831


#4 楼 @keating 如果有 User.where(:xxx => params[:xxx]).update_attributes(:a => b) 就完了

#7 楼 @kenshin54 几乎不会这样吧……

#6 楼 @leekelby 感觉场景有限 比如查找一个用户

u = User.find_by_name([nil])

只有在 name 确实有 null 值才会返回一个用户


好像问题比较严重,才升了 10 没几天,又升 11 了。。。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号