Rapid7 Vulnerability & Exploit Database

Ruby on Rails Dynamic Render File Upload Remote Code Execution

Back to Search

Ruby on Rails Dynamic Render File Upload Remote Code Execution

Disclosed
10/16/2016
Created
05/30/2018

Description

This module exploits a remote code execution vulnerability in the explicit render method when leveraging user parameters. This module has been tested across multiple versions of Ruby on Rails. The technique used by this module requires the specified endpoint to be using dynamic render paths, such as the following example: def show render params[:id] end Also, the vulnerable target will need a POST endpoint for the TempFile upload, this can literally be any endpoint. This module doesnt use the log inclusion method of exploitation due to it not being universal enough. Instead, a new code injection technique was found and used whereby an attacker can upload temporary image files against any POST endpoint and use them for the inclusion attack. Finally, you only get one shot at this if you are testing with the builtin rails server, use caution.

Author(s)

  • mr_me <mr_me@offensive-security.com>
  • John Poulin (forced-request)

Platform

BSD,Linux

Architectures

x86

Development

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/multi/http/rails_dynamic_render_code_exec
msf exploit(rails_dynamic_render_code_exec) > show targets
    ...targets...
msf exploit(rails_dynamic_render_code_exec) > set TARGET < target-id >
msf exploit(rails_dynamic_render_code_exec) > show options
    ...show and set options...
msf exploit(rails_dynamic_render_code_exec) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security

;