Vulnerabilities > CVE-2016-2098 - Improper Input Validation vulnerability in multiple products

047910
CVSS 7.3 - HIGH
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
NONE
Confidentiality impact
LOW
Integrity impact
LOW
Availability impact
LOW
network
low complexity
debian
rubyonrails
CWE-20
nessus
exploit available
metasploit

Summary

Action Pack in Ruby on Rails before 3.2.22.2, 4.x before 4.1.14.2, and 4.2.x before 4.2.5.2 allows remote attackers to execute arbitrary Ruby code by leveraging an application's unrestricted use of the render method.

Vulnerable Configurations

Part Description Count
OS
Debian
1
Application
Rubyonrails
251

Common Weakness Enumeration (CWE)

Common Attack Pattern Enumeration and Classification (CAPEC)

  • Buffer Overflow via Environment Variables
    This attack pattern involves causing a buffer overflow through manipulation of environment variables. Once the attacker finds that they can modify an environment variable, they may try to overflow associated buffers. This attack leverages implicit trust often placed in environment variables.
  • Server Side Include (SSI) Injection
    An attacker can use Server Side Include (SSI) Injection to send code to a web application that then gets executed by the web server. Doing so enables the attacker to achieve similar results to Cross Site Scripting, viz., arbitrary code execution and information disclosure, albeit on a more limited scale, since the SSI directives are nowhere near as powerful as a full-fledged scripting language. Nonetheless, the attacker can conveniently gain access to sensitive files, such as password files, and execute shell commands.
  • Cross Zone Scripting
    An attacker is able to cause a victim to load content into their web-browser that bypasses security zone controls and gain access to increased privileges to execute scripting code or other web objects such as unsigned ActiveX controls or applets. This is a privilege elevation attack targeted at zone-based web-browser security. In a zone-based model, pages belong to one of a set of zones corresponding to the level of privilege assigned to that page. Pages in an untrusted zone would have a lesser level of access to the system and/or be restricted in the types of executable content it was allowed to invoke. In a cross-zone scripting attack, a page that should be assigned to a less privileged zone is granted the privileges of a more trusted zone. This can be accomplished by exploiting bugs in the browser, exploiting incorrect configuration in the zone controls, through a cross-site scripting attack that causes the attackers' content to be treated as coming from a more trusted page, or by leveraging some piece of system functionality that is accessible from both the trusted and less trusted zone. This attack differs from "Restful Privilege Escalation" in that the latter correlates to the inadequate securing of RESTful access methods (such as HTTP DELETE) on the server, while cross-zone scripting attacks the concept of security zones as implemented by a browser.
  • Cross Site Scripting through Log Files
    An attacker may leverage a system weakness where logs are susceptible to log injection to insert scripts into the system's logs. If these logs are later viewed by an administrator through a thin administrative interface and the log data is not properly HTML encoded before being written to the page, the attackers' scripts stored in the log will be executed in the administrative interface with potentially serious consequences. This attack pattern is really a combination of two other attack patterns: log injection and stored cross site scripting.
  • Command Line Execution through SQL Injection
    An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.

Exploit-Db

descriptionRuby on Rails ActionPack Inline ERB Code Execution. CVE-2016-2098. Remote exploit for ruby platform
fileexploits/ruby/remote/40086.rb
idEDB-ID:40086
last seen2016-07-11
modified2016-07-11
platformruby
port80
published2016-07-11
reportermetasploit
sourcehttps://www.exploit-db.com/download/40086/
titleRuby on Rails ActionPack Inline ERB Code Execution
typeremote

Metasploit

descriptionThis module exploits a remote code execution vulnerability in the inline request processor of the Ruby on Rails ActionPack component. This vulnerability allows an attacker to process ERB to the inline JSON processor, which is then rendered, permitting full RCE within the runtime, without logging an error condition.
idMSF:EXPLOIT/MULTI/HTTP/RAILS_ACTIONPACK_INLINE_EXEC
last seen2020-06-09
modified2017-07-24
published2016-06-28
referenceshttps://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2098
reporterRapid7
sourcehttps://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/multi/http/rails_actionpack_inline_exec.rb
titleRuby on Rails ActionPack Inline ERB Code Execution

Nessus

  • NASL familyDebian Local Security Checks
    NASL idDEBIAN_DSA-3509.NASL
    descriptionTwo vulnerabilities have been discovered in Rails, a web application framework written in Ruby. Both vulnerabilities affect Action Pack, which handles the web requests for Rails. - CVE-2016-2097 Crafted requests to Action View, one of the components of Action Pack, might result in rendering files from arbitrary locations, including files beyond the application
    last seen2020-06-01
    modified2020-06-02
    plugin id89791
    published2016-03-10
    reporterThis script is Copyright (C) 2016-2018 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/89791
    titleDebian DSA-3509-1 : rails - security update
  • NASL familySuSE Local Security Checks
    NASL idOPENSUSE-2016-352.NASL
    descriptionThis update for rubygem-actionview-4_2 fixes the following issues : - CVE-2016-2098: rubygem-actionpack: Possible remote code execution vulnerability in Action Pack (boo#968849)
    last seen2020-06-05
    modified2016-03-17
    plugin id89977
    published2016-03-17
    reporterThis script is Copyright (C) 2016-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/89977
    titleopenSUSE Security Update : rubygem-actionview-4_2 (openSUSE-2016-352)
  • NASL familyDebian Local Security Checks
    NASL idDEBIAN_DLA-604.NASL
    descriptionMultiple vulnerabilities have been discovered in ruby-actionpack-3.2, a web-flow and rendering framework and part of Rails : CVE-2015-7576 A flaw was found in the way the Action Controller component compared user names and passwords when performing HTTP basic authentication. Time taken to compare strings could differ depending on input, possibly allowing a remote attacker to determine valid user names and passwords using a timing attack. CVE-2016-0751 A flaw was found in the way the Action Pack component performed MIME type lookups. Since queries were cached in a global cache of MIME types, an attacker could use this flaw to grow the cache indefinitely, potentially resulting in a denial of service. CVE-2016-0752 A directory traversal flaw was found in the way the Action View component searched for templates for rendering. If an application passed untrusted input to the
    last seen2020-03-17
    modified2016-08-29
    plugin id93132
    published2016-08-29
    reporterThis script is Copyright (C) 2016-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/93132
    titleDebian DLA-604-1 : ruby-actionpack-3.2 security update
  • NASL familyFreeBSD Local Security Checks
    NASL idFREEBSD_PKG_5A016DD08AA8490EA59655F4CC17E4EF.NASL
    descriptionRuby on Rails blog : Rails 4.2.5.2, 4.1.14.2, and 3.2.22.2 have been released! These contain the following important security fixes, and it is recommended that users upgrade as soon as possible.
    last seen2020-06-01
    modified2020-06-02
    plugin id89708
    published2016-03-07
    reporterThis script is Copyright (C) 2016-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/89708
    titleFreeBSD : rails -- multiple vulnerabilities (5a016dd0-8aa8-490e-a596-55f4cc17e4ef)
  • NASL familySuSE Local Security Checks
    NASL idOPENSUSE-2016-369.NASL
    descriptionThis update for rubygem-actionpack-3_2 fixes the following issues : - CVE-2016-2097: rubygem-actionview: Possible Information Leak Vulnerability in Action View. (boo#968850) - CVE-2016-2098: rubygem-actionpack: Possible remote code execution vulnerability in Action Pack (boo#968849)
    last seen2020-06-05
    modified2016-03-21
    plugin id90061
    published2016-03-21
    reporterThis script is Copyright (C) 2016-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/90061
    titleopenSUSE Security Update : rubygem-actionpack-3_2 (openSUSE-2016-369)
  • NASL familyFedora Local Security Checks
    NASL idFEDORA_2016-3954061E32.NASL
    description - Fix rails-html-sanitizer v1.0.3 compatibility. * Fix code injection vulnerability (CVE-2016-2098). Note that Tenable Network Security has extracted the preceding description block directly from the Fedora security advisory. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues.
    last seen2020-06-05
    modified2016-03-18
    plugin id90013
    published2016-03-18
    reporterThis script is Copyright (C) 2016-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/90013
    titleFedora 22 : rubygem-actionpack-4.2.0-4.fc22 / rubygem-actionview-4.2.0-5.fc22 (2016-3954061e32)
  • NASL familyFedora Local Security Checks
    NASL idFEDORA_2016-F6AF14570F.NASL
    description - Fix rails-html-sanitizer v1.0.3 compatibility. * Fix code injection vulnerability (CVE-2016-2098). Note that Tenable Network Security has extracted the preceding description block directly from the Fedora security advisory. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues.
    last seen2020-06-05
    modified2016-03-18
    plugin id90016
    published2016-03-18
    reporterThis script is Copyright (C) 2016-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/90016
    titleFedora 23 : rubygem-actionpack-4.2.3-5.fc23 / rubygem-actionview-4.2.3-5.fc23 (2016-f6af14570f)

Packetstorm

data sourcehttps://packetstormsecurity.com/files/download/137834/rails_actionpack_inline_exec.rb.txt
idPACKETSTORM:137834
last seen2016-12-05
published2016-07-09
reporterRageLtMan
sourcehttps://packetstormsecurity.com/files/137834/Ruby-On-Rails-ActionPack-Inline-ERB-Code-Execution.html
titleRuby On Rails ActionPack Inline ERB Code Execution

Redhat

rpms
  • ror40-rubygem-actionpack-1:4.0.2-7.el6
  • ror40-rubygem-actionpack-1:4.0.2-7.el7
  • ror40-rubygem-actionpack-doc-1:4.0.2-7.el6
  • ror40-rubygem-actionpack-doc-1:4.0.2-7.el7
  • ror40-rubygem-activerecord-1:4.0.2-6.el6
  • ror40-rubygem-activerecord-1:4.0.2-6.el7
  • ror40-rubygem-activerecord-doc-1:4.0.2-6.el6
  • ror40-rubygem-activerecord-doc-1:4.0.2-6.el7
  • ror40-rubygem-activesupport-1:4.0.2-4.el6
  • ror40-rubygem-activesupport-1:4.0.2-4.el7
  • ruby193-rubygem-actionpack-1:3.2.8-16.el6
  • ruby193-rubygem-actionpack-1:3.2.8-16.el7
  • ruby193-rubygem-actionpack-doc-1:3.2.8-16.el6
  • ruby193-rubygem-actionpack-doc-1:3.2.8-16.el7
  • ruby193-rubygem-activerecord-1:3.2.8-11.el6
  • ruby193-rubygem-activerecord-1:3.2.8-11.el7
  • ruby193-rubygem-activerecord-doc-1:3.2.8-11.el6
  • ruby193-rubygem-activerecord-doc-1:3.2.8-11.el7
  • ruby193-rubygem-activesupport-1:3.2.8-6.el6
  • ruby193-rubygem-activesupport-1:3.2.8-6.el7
  • rh-ror41-rubygem-actionpack-1:4.1.5-4.el6
  • rh-ror41-rubygem-actionpack-1:4.1.5-4.el7
  • rh-ror41-rubygem-actionpack-doc-1:4.1.5-4.el6
  • rh-ror41-rubygem-actionpack-doc-1:4.1.5-4.el7
  • rh-ror41-rubygem-actionview-0:4.1.5-5.el6
  • rh-ror41-rubygem-actionview-0:4.1.5-5.el7
  • rh-ror41-rubygem-actionview-doc-0:4.1.5-5.el6
  • rh-ror41-rubygem-actionview-doc-0:4.1.5-5.el7

Seebug

bulletinFamilyexploit
description### 漏洞应用 测试环境: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>```时,代 码会将 ```“<%= `id` %>”```做为模板 :inline 渲染的方式将传入的字符串作为模 板内容进行渲染,因为在 Rails 模板引擎中,<%= [string_here] %> 表示将 [string_here] 作为 Ruby 代码进行执行并将结果进行返回,所以最终访问页 面会返回系统执行 id 命令后的结果: ![](https://images.seebug.org/1458207056858) ### 漏洞影响 从 zoomeye.org 上搜索使用了 Rails 框架的站点: ![](https://images.seebug.org/1458208074257) 全球大约有 4w 多个使用了 Rails 的站点可能受到该漏洞的影响。 同时也可以在 Github 上搜索 “render :inline =>”来查看潜在受到影响 的项目: ![](https://images.seebug.org/1458208135946) 可以看到也有大量的项目符合这样的代码写法,可能受到该漏洞的影响。 ### 相关链接: [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
idSSV:91073
last seen2017-11-19
modified2016-03-17
published2016-03-17
reporterRoot
titleRuby on Rails Action Pack远程代码执行漏洞

References