Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities - Nessus

Critical   Plugin ID: 139607

This page contains detailed information about the Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 139607
Name: Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities
Filename: struts_2_5_22.nasl
Vulnerability Published: 2020-08-11
This Plugin Published: 2020-08-14
Last Modification Time: 2022-04-11
Plugin Version: 1.7
Plugin Type: local
Plugin Family: Misc.
Dependencies: os_fingerprint.nasl, struts_detect_nix.nbin, struts_detect_win.nbin

Vulnerability Information


Severity: Critical
Vulnerability Published: 2020-08-11
Patch Published: 2019-11-19
CVE [?]: CVE-2019-0230, CVE-2019-0233
CPE [?]: cpe:/a:apache:struts

Synopsis

Apache Struts installed on the remote host is affected by multiple vulnerabilities.

Description

The version of Apache Struts installed on the remote host is 2.x prior or equal to 2.5.20. It is, therefore, affected by multiple vulnerabilities:

- The Apache Struts frameworks, when forced, performs double evaluation of attributes' values assigned to certain tags attributes such as id so it is possible to pass in a value that will be evaluated again when a tag's attributes will be rendered. With a carefully crafted request, this can lead to Remote Code Execution (RCE). The problem only applies when forcing OGNL evaluation inside a Struts tag attribute, when the expression to evaluate references raw, unvalidated input that an attacker is able to directly modify by crafting a corresponding request.Example:List available EmployeesIf an attacker is able to modify the skillName attribute in a request such that a raw OGNL expression gets passed to the skillName property without further validation, the provided OGNL expression contained in the skillName attribute gets evaluated when the tag is rendered as a result of the request.The opportunity for using double evaluation is by design in Struts since 2.0.0 and a useful tool when done right, which most notably means only referencing validated values in the given expression. However, when referencing unvalidated user input in the expression, malicious code can get injected. In an ongoing effort, the Struts framework includes mitigations for limiting the impact of injected expressions, but Struts before 2.5.22 left an attack vector open which is addressed by this report. This issue is similar to: S2-029 and S2-036. (CVE-2019-0230)

- When a file upload is performed to an Action that exposes the file with a getter, an attacker may manipulate the request such that the working copy of the uploaded file is set to read-only. As a result, subsequent actions on the file will fail with an error. It might also be possible to set the Servlet container's temp directory to read only, such that subsequent upload actions will fail. In Struts prior to 2.5.22, stack-accessible values (e.g. Action properties) of type java.io.File and java.nio.File as well as other classes from these standard library packages are not properly protected by the framework to deny access to potentially harmful underlying properties. (CVE-2019-0233)

Note that Nessus has not tested for these issues but has instead relied only on the application's self-reported version number.

Solution

Upgrade to Apache Struts version 2.5.22 or later or apply the workarounds as referenced in in the vendor security bulletins.

Public Exploits


Target Network Port(s): N/A
Target Asset(s): installed_sw/Apache Struts, installed_sw/Struts
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 Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities vulnerability:

  1. Metasploit: exploit/multi/http/struts2_multi_eval_ognl
    [Apache Struts 2 Forced Multi OGNL Evaluation]
  2. Exploit-DB: exploits/multiple/remote/49068.py
    [EDB-49068: Apache Struts 2.5.20 - Double OGNL evaluation]
  3. GitHub: https://github.com/0day666/Vulnerability-verification
    [CVE-2019-0230]
  4. GitHub: https://github.com/360quake/papers
    [CVE-2019-0230]
  5. GitHub: https://github.com/A2gel/CVE-2019-0230
    [CVE-2019-0230: CVE-2019-0230 Exploit]
  6. GitHub: https://github.com/Al1ex/CVE-2019-0230
    [CVE-2019-0230: S2-059(CVE-2019-0230)]
  7. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2019-0230]
  8. GitHub: https://github.com/fengziHK/CVE-2019-0230
    [CVE-2019-0230]
  9. GitHub: https://github.com/gitworldhero/CVE-2019-0230
    [CVE-2019-0230: S2-059 CVE-2019-0230]
  10. GitHub: https://github.com/s1kr10s/Apache-Struts-v4
    [CVE-2019-0230]
  11. GitHub: https://github.com/soshewh97/CVE-2019-0230_Struts2S2-059
    [CVE-2019-0230]
  12. GitHub: https://github.com/tw-eason-tseng/CVE-2019-0230_Struts2S2-059
    [CVE-2019-0230]
  13. GitHub: https://github.com/woods-sega/woodswiki
    [CVE-2019-0230]
  14. GitHub: https://github.com/BH2UOL/CVE-2019-0230
    [CVE-2019-0230: CVE-2019-0230 Exploit]
  15. GitHub: https://github.com/f8al/CVE-2019-0230-PoC
    [CVE-2019-0230: PoC for apache struts 2 vuln cve-2019-0230]
  16. GitHub: https://github.com/PrinceFPF/CVE-2019-0230
    [CVE-2019-0230: CVE-2019-0230 Exploit POC]
  17. GitHub: https://github.com/ramoncjs3/CVE-2019-0230
    [CVE-2019-0230: CVE-2019-0230 & s2-059 poc.]

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-2019-0230
CVSS V2 Vector: AV:N/AC:L/Au:N/C:P/I:P/A:P/E:F/RL:OF/RC:C
CVSS Base Score:7.5 (High)
Impact Subscore:6.4
Exploitability Subscore:10.0
CVSS Temporal Score:6.2 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:6.2 (Medium)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C
CVSS Base Score:9.8 (Critical)
Impact Subscore:5.9
Exploitability Subscore:3.9
CVSS Temporal Score:9.1 (Critical)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:9.1 (Critical)

Go back to menu.

Plugin Source


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

  script_cve_id("CVE-2019-0230", "CVE-2019-0233");

  script_name(english:"Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities");

  script_set_attribute(attribute:"synopsis", value:
"Apache Struts installed on the remote host is affected by multiple vulnerabilities.");
  script_set_attribute(attribute:"description", value:
"The version of Apache Struts installed on the remote host is 2.x prior or equal to 2.5.20. It is, therefore,
affected by multiple vulnerabilities:

  - The Apache Struts frameworks, when forced, performs double evaluation of attributes' values assigned to
    certain tags attributes such as id so it is possible to pass in a value that will be evaluated again when
    a tag's attributes will be rendered. With a carefully crafted request, this can lead to Remote Code
    Execution (RCE). The problem only applies when forcing OGNL evaluation inside a Struts tag attribute, when
    the expression to evaluate references raw, unvalidated input that an attacker is able to directly modify
    by crafting a corresponding request.Example:List available EmployeesIf an attacker is able to modify the
    skillName attribute in a request such that a raw OGNL expression gets passed to the skillName property
    without further validation, the provided OGNL expression contained in the skillName attribute gets
    evaluated when the tag is rendered as a result of the request.The opportunity for using double evaluation
    is by design in Struts since 2.0.0 and a useful tool when done right, which most notably means only
    referencing validated values in the given expression. However, when referencing unvalidated user input in
    the expression, malicious code can get injected. In an ongoing effort, the Struts framework includes
    mitigations for limiting the impact of injected expressions, but Struts before 2.5.22 left an attack
    vector open which is addressed by this report. This issue is similar to: S2-029 and S2-036. (CVE-2019-0230)

  - When a file upload is performed to an Action that exposes the file with a getter, an attacker may
    manipulate the request such that the working copy of the uploaded file is set to read-only. As a result,
    subsequent actions on the file will fail with an error. It might also be possible to set the Servlet
    container's temp directory to read only, such that subsequent upload actions will fail. In Struts prior
    to 2.5.22, stack-accessible values (e.g. Action properties) of type java.io.File and java.nio.File as well
    as other classes from these standard library packages are not properly protected by the framework to deny
    access to potentially harmful underlying properties. (CVE-2019-0233)

Note that Nessus has not tested for these issues but has instead relied only on the application's self-reported version
number.");
  script_set_attribute(attribute:"see_also", value:"https://cwiki.apache.org/confluence/display/WW/S2-059");
  script_set_attribute(attribute:"see_also", value:"https://cwiki.apache.org/confluence/display/WW/S2-060");
  script_set_attribute(attribute:"solution", value:
"Upgrade to Apache Struts version 2.5.22 or later or apply the workarounds as referenced in in the vendor security
bulletins.");
  script_set_attribute(attribute:"agent", value:"all");
  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:F/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:F/RL:O/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2019-0230");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'Apache Struts 2 Forced Multi OGNL Evaluation');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2020/08/11");
  script_set_attribute(attribute:"patch_publication_date", value:"2019/11/19");
  script_set_attribute(attribute:"plugin_publication_date", value:"2020/08/14");

  script_set_attribute(attribute:"plugin_type", value:"local");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:apache:struts");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Misc.");

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

  script_dependencies("os_fingerprint.nasl", "struts_detect_win.nbin", "struts_detect_nix.nbin");
  script_require_ports("installed_sw/Apache Struts", "installed_sw/Struts");

  exit(0);
}

include('vcf.inc');

win_local = FALSE;
os = get_kb_item_or_exit('Host/OS');
if ('windows' >< tolower(os)) win_local = TRUE;

app_info = vcf::get_app_info(app:'Apache Struts', win_local:win_local);

vcf::check_granularity(app_info:app_info, sig_segments:3);

constraints = [
  { 'min_version' : '2.0.0', 'max_version' : '2.5.20', 'fixed_version' : '2.5.22' }
];

vcf::check_version_and_report(app_info:app_info, constraints:constraints, severity:SECURITY_HOLE);


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

Go back to menu.

How to Run


Here is how to run the Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities 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 Misc. plugin family.
  6. On the right side table select Apache Struts 2.x <= 2.5.20 Multiple Vulnerabilities plugin ID 139607.
  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_5_22.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

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

Go back to menu.

References


See also: Similar and related Nessus plugins:
  • 117363 - Apache Struts 2.x < 2.2.1 OGNL RCE (S2-005)
  • 117388 - Apache Struts 2.x < 2.2.3 Multiple XSS (S2-006)
  • 143125 - Apache Struts 2.x < 2.3.1.1 Multiple Vulnerabilities
  • 117403 - Apache Struts 2.x < 2.3.1.2 RCE (S2-009)
  • 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)
  • 117389 - Apache Struts 2.x < 2.3.14.3 RCE (S2-015)
  • 128765 - Apache Struts 2.x < 2.3.14.3 Remote Code Execution Vulnerability (S2-012)
  • 117362 - Apache Struts 2.x < 2.3.15.1 Multiple Vulnerabilities (S2-016) (S2-017)
  • 117402 - Apache Struts 2.x < 2.3.15.2 Dynamic Method Invocation Multiple Vulnerabilities (S2-019)
  • 117393 - Apache Struts 2.x < 2.3.16.2 Multiple Vulnerabilities (S2-020)
  • 117457 - Apache Struts 2.x < 2.3.20 Multiple ClassLoader Manipulation Vulnerabilities (S2-021)
  • 90773 - Apache Struts 2.x < 2.3.28.1 Multiple Vulnerabilities
  • 90153 - Apache Struts 2.x < 2.3.28 Multiple Vulnerabilities (S2-028) (S2-029) (S2-030) (S2-034)
  • 91812 - Apache Struts 2.x < 2.3.29 Multiple Vulnerabilities (S2-035 - S2-040)
  • 94336 - Apache Struts 2.3.1 < 2.3.31 / 2.5.x < 2.5.5 Convention Plugin Path Traversal RCE (S2-042)
  • 118731 - Apache Struts 2.3.x < 2.3.33 Denial of Service (S2-049)
  • 118732 - Apache Struts <= 2.3.36 FileUpload Deserialization Vulnerability
  • 101361 - Apache Struts 2.3.x Showcase App Struts 1 Plugin ActionMessage Class Error Message Input Handling RCE (S2-048)
  • 97576 - Apache Struts 2.3.5 - 2.3.31 / 2.5.x < 2.5.10.1 Jakarta Multipart Parser RCE (S2-045) (S2-046)
  • 101548 - Apache Struts 2.5.x < 2.5.12 Multiple DoS (S2-047) (S2-049)
  • 102960 - Apache Struts 2.1.x >= 2.1.2 / 2.2.x / 2.3.x < 2.3.34 / 2.5.x < 2.5.13 Multiple Vulnerabilities (S2-050 - S2-053)
  • 105005 - Apache Struts 2.5.x < 2.5.14.1 Json-lib JSON Parsing Unspecified DoS (S2-054) (S2-055)
  • 108760 - Apache Struts XStream Handler REST Plugin XML Request Handling Remote DoS (S2-056)
  • 112036 - Apache Struts CVE-2018-11776 Results With No Namespace Possible Remote Code Execution (S2-057)
  • 143599 - Apache Struts 2.x < 2.5.26 RCE (S2-061)
  • 151425 - Apache Struts 2.0.0 < 2.5.26 Possible Remote Code Execution vulnerability (S2-061)
  • 159667 - Apache Struts 2.0.0 < 2.5.30 Possible Remote Code Execution vulnerability (S2-062)

Version


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

Go back to menu.