Weblogic RCE by only one GET request — CVE-2020–14882 Analysis
A vulnerability in Oracle WebLogic's console allowed an unauthenticated attacker to reach a dangerous method that loads arbitrary classes, leading to remote code execution. The flaw involved bypassing authentication via a crafted URL and then exploiting a class-loading sink to execute commands.
Published on testbnull.medium.com
Mới đó mà đã ngót nghét 1 năm, tầm này năm ngoái mình đang loay hoay với GadgetInspector, tìm ra CVE-2020–2555 và report cho ZDI.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Oracle's October 2020 Critical Patch Update brought a WebLogic bug that broke with the pattern of the previous year: CVE-2020-14882, rated CVSS 9.8/10, reachable over HTTP, and affecting all versions. The researcher had spent the preceding year on T3 deserialisation gadget chains (CVE-2020-2555, then the 2883 and 2884 bypasses), and had grown tired of the same entrypoint being patched and bypassed in turn. Disabling T3 and IIOP had been an effective mitigation for that whole class of bugs. This one did not need T3 at all.
The affected feature is the WebLogic Administration Console: the web application under /console, its Struts-style portal handling, and the servlets declared in the console's web.xml. The bug was reported by a researcher the author refers to as a Chinese researcher, and the write-up credits @voidfyoo as MVP.
Setup
The analysis was done on WebLogic [redacted]. The October patch is numbered 3191038; the July patch is 31535411. The method was patch diffing: download both, compare the console component, and look at which classes changed.
Two classes changed in the console component:
HandleFactory.classMBeanUtilsInitSingleFileServlet.class

Tooling: a debugger against a local WebLogic instance, and a modified build of GadgetInspector (the author had previously adapted it heavily while working on Liferay) to search for a constructor gadget in the new context.
Finding it
The sink: HandleFactory.getHandle()
The first changed class examined was com.bea.console.handles.HandleFactory.getHandle().

The patch adds a type check on handleClass: only classes that are instances of com.bea.console.handles.Handle are allowed through.

That check tells you what the pre-patch code did. getHandle() takes a String, processes it through several steps, and eventually reaches Class.forName(className) to load the class. It then looks inside that class for a constructor taking a single String argument and creates a new instance from it.
The processing flow, as the author diagrams it:

The entrypoint can be triggered with the following GET request, which at this stage still requires an authenticated session:
http://<target>/console/console.portal?_nfpb=true&_pageLabel=HomePage1&handle=java.lang.String("ahihi")
With a breakpoint on HandleFactory.getHandle(), both handleConstructor and args are shown to be controlled from the input data.
This is the position abused for RCE in CVE-2020-14882. To exploit it, you need a class with a public constructor taking one String argument. At this point the author stopped: the sink was known, but there was no pre-auth entrypoint yet, so there was no point running the gadget tool.
The source: MBeanUtilsInitSingleFileServlet
Since HandleFactory.getHandle() is the sink, the other patched class, MBeanUtilsInitSingleFileServlet, is the likely source.

The patch adds an IllegalUrl field:
private static final String[] IllegalUrl = new String[]{";", "%252E%252E", "%2E%2E", "..", "%3C", "%3E", "<", ">"};
The servlet's handling is simply to check whether the URL contains the string .. and reject the request if it does. Something about .. must matter, otherwise it would not be filtered. Reaching MBeanUtilsInitSingleFileServlet.service() also requires passing an authentication step, which made the author think this was only post-auth RCE and could not be the 9.8.
The console webapp layout
Like other Java servlets, WebLogic has a webapp folder; for the console it is:
\Middleware\Oracle_Home\wlserver\server\lib\consoleapp\webapp
It contains the usual web.xml and struts-config.xml configuration files.

According to web.xml, MBeanUtilsInitSingleFileServlet is an init-param of AppManagerServlet.

AppManagerServlet is mapped to these URL patterns:
/appmanager/**.portlet*.portion*.portal
That includes /console/console.portal, which is visible immediately after logging in to the console.

How authentication decisions are made
The class that decides whether a request needs authentication, in WebLogic [redacted], is weblogic.servlet.[redacted].WebAppSecurity.checkAccess().

Inside it, WebAppSecurityWLS.getConstraint(request) fetches the constraints for the current request. Each constraint carries information including an unrestrict flag: if unrestrict=true, the request is treated as unauthenticated; otherwise the login page is returned.
Stepping into WebAppSecurityWLS.getConstraint() gives the full constraint list, and from it the URL patterns that skip the authentication check:
/bea-helpsets/*/framework/skins/wlsconsole/images/*/framework/skins/wlsconsole/css/*/framework/skeletons/wlsconsole/js/*/framework/skeletons/wlsconsole/css/*/css/*/common/*/images/*

Trying the usual URL bypass tricks against these patterns, for example ..;/ and /#/../, produced nothing useful. At this point the author was stuck.
The hint
No PoC had appeared on Twitter, so the author asked contacts for a hint (the person is kept anonymous).

The contact sent a picture of a PoC.

The part abusing HandleFactory was already understood. The URL part was /console/console%2E%2E.portal, that is /console/console...portal. Testing it did not work: for /console/console%2E%2E.portal the constraint still returned unrestricted=false, meaning authentication was still required.

Asked again, the contact replied as follows.

The original PoC was only a hint: bypassing authentication needs a trick, abusing some resource, before it becomes unauthenticated RCE. Back to square one.
At that point the author brought in two more people, PeterJson and @Quynh Le, to work on it together, recalling CTF days when handing an idea to a teammate always worked better than playing alone. The group of three focused on bugs in Java.

The unauthenticated entrypoint
The breakthrough came from a German member of the group, who found a URL that triggers MBeanUtilsInitSingleFileServlet with no authentication at all:
/console/css/changemgmt.portal

The author was surprised by the request, but testing confirmed it does trigger the servlet.

In the debugger, the constraint is indeed mapped to /css/, so it really is unrestricted.
More surprising still: the servlet handling this entrypoint is AsyncInitServlet, not FileServlet as expected.

For comparison, a normal request with a .css suffix is handled by FileServlet.

The author had assumed there was something magic in FileServlet and had been digging there. The magic is in web.xml, in the static resource declarations:

- URL pattern
/common/*is handled byJSPCServlet(which handles requests to JSP files). - URL patterns
/framework/*are handled byFileServlet. - The URL patterns
/images/*and/css/*have no servlet declared to handle them.
Because of that, a request to /console/css/aaasdasdasd.portal is handled by AppManagerServlet. In summary:
/css/*bypasses authentication..portaltriggers the portal handling.
At this point MBeanUtilsInitSingleFileServlet.service() is reachable without authentication. The request still cannot reach HandleFactory.getHandle(), because the URL pattern does not match a portlet.
Double encoding
The original hint from the Chinese researcher now made sense.

The .. was meant to hint at using double encoding to trigger the bug. Retesting confirmed it:

After passing through MBeanUtilsInitSingleFileServlet.service() and several more steps, at UIServletInternal.getTree() the URL pattern is parsed again and the URL is decoded one more time.

Before decoding.
After decoding:

This explains why a double-encoded URL both bypasses the initial normalised-URL handling and still lets the later servlet handling work correctly.
Exploitation
- Reach the servlet unauthenticated. Request a path under
/css/with a.portalsuffix, for example/console/css/changemgmt.portal. The/css/*constraint is unrestricted, and because no servlet is declared for/css/*,AppManagerServlethandles the request and reachesMBeanUtilsInitSingleFileServlet.service(). - Match the portlet pattern. The URL must match a portlet pattern for the request to reach
HandleFactory.getHandle(). The..hint points to double encoding: the first normalisation rejects a literal.., but the later decode inUIServletInternal.getTree()turns the double-encoded sequence back into.., so the portlet pattern matches. - Control the handle. Supply the
handleparameter in the formjava.lang.String("ahihi")as in the authenticated example, so thatClass.forName(className)loads the named class and its single-String constructor is invoked with the attacker's argument. - Pick a gadget class. The original PoC used
com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext()to trigger RCE, but that chain requires outbound access. - Find a no-outbound chain. The author modified GadgetInspector for the new context and ran it for about five minutes, producing many results. One chain looked promising:

- Reach command execution. The chain, after receiving the argument from the constructor, calls
ShellSession.exec()and executes with that argument.

The chain behind ShellSession.exec() is long; the author summarises it as follows:

This allows execution of arbitrary MVEL expressions. The author notes surprise at finding such ready-made material in the code, and is not sure whether it is a backdoor left in the code. 7. Build the final PoC. Combining all of the above, the author wrote a PoC that executes a command and returns the response. The final PoC was completed by Duc, not by the author.
PoC video: https://youtu.be/JFVDOIL0YtA
Root cause
Two mistakes combine.
First, HandleFactory.getHandle() takes a String from the request, resolves it with Class.forName(className), and instantiates the class through a public single-String constructor, without restricting which classes are acceptable. The October patch adds exactly that restriction, allowing only instances of com.bea.console.handles.Handle.
Second, the console's web.xml leaves /css/* and /images/* without a declared servlet, while the security constraints mark /css/* as unrestricted. A request under /css/ with a .portal suffix therefore skips authentication and is still routed to AppManagerServlet, which reaches MBeanUtilsInitSingleFileServlet. The servlet's handling checks whether the URL contains .., but the URL is decoded again later in UIServletInternal.getTree(), so a double-encoded sequence passes the first check and becomes .. for the portlet matching. The patch adds the IllegalUrl list, including %252E%252E, %2E%2E and ...
Impact
An unauthenticated attacker can execute arbitrary commands on a WebLogic server over HTTP, with the response returned to the attacker, according to the author's PoC. The bug affects all versions and is rated CVSS 9.8/10. The original PoC's FileSystemXmlApplicationContext chain requires outbound access; the author's alternative chain does not, which matters because many servers block outbound traffic.
Fix
The October 2020 CPU patch analysed here is numbered 3191038. The changes are:
HandleFactory.getHandle()now checks the type ofhandleClassand only allows instances ofcom.bea.console.handles.Handle.MBeanUtilsInitSingleFileServletnow rejects URLs containing any of the strings inIllegalUrl:;,%252E%252E,%2E%2E,..,%3C,%3E,<,>.
Variants to test
- Undeclared static paths with a portal suffix. Request paths under
/css/or/images/with a.portalsuffix, for example/console/css/changemgmt.portal. A positive result is the request reachingMBeanUtilsInitSingleFileServletwithout a login redirect, visible in a debugger onWebAppSecurity.checkAccess()asunrestricted=true. - Double-encoded traversal in the portlet pattern. Combine the
/css/prefix with a double-encoded..so the first normalisation passes and the later decode inUIServletInternal.getTree()restores... A positive result is the URL matching a portlet pattern after decoding. - Handle parameter with arbitrary classes. Send
handle=java.lang.String("ahihi")(or another class with a public single-String constructor) toconsole.portal. A positive result is a breakpoint inHandleFactory.getHandle()showinghandleConstructorandargscontrolled by the input. - Constructor gadget search. Run GadgetInspector (or similar) against the console classpath for classes with a public single-String constructor that reach command execution, such as the
ShellSession.exec()chain. A positive result is a chain that executes without outbound access. - Other unrestricted patterns. Test the remaining patterns from the constraint list (
/bea-helpsets/*,/framework/skins/wlsconsole/images/*,/framework/skins/wlsconsole/css/*,/framework/skeletons/wlsconsole/js/*,/framework/skeletons/wlsconsole/css/*,/common/*,/images/*) with portal suffixes. A positive result is any of them reachingAppManagerServletwithout authentication.
What happened, in plain words
In October 2020, Oracle released its regular batch of security fixes, called a Critical Patch Update (CPU). One of the bugs fixed in that batch was CVE-2020-14882, a flaw in Oracle WebLogic Server. WebLogic is a Java application server: a program that runs web applications for an organisation, often the kind of software that sits behind a company's internal tools and admin pages. The bug was rated CVSS 9.8/10. CVSS is a public scoring system for how serious a security flaw is; 9.8 out of 10 is near the top of the scale. The bug could be reached over HTTP, the same ordinary web protocol your browser uses to load pages, and it affected all versions of the product.
That detail matters because of what the author had been doing for the previous year. Much of the WebLogic security research of that period concerned T3, a proprietary network protocol WebLogic uses for internal communication, and deserialisation bugs reached through it. Deserialisation is the process of turning a stream of bytes back into live objects inside a program; if an attacker can control those bytes, they can sometimes make the program build objects that do harmful things. The author had found such bugs (CVE-2020-2555, then the 2883 and 2884 bypasses of its fix) and had grown tired of the same entrypoint being patched and then bypassed again. Turning off T3 and IIOP (another internal protocol) had been an effective way to make that whole family of bugs unreachable. This new bug did not need T3 at all: it went over plain HTTP.
The affected feature is the WebLogic Administration Console. That is the web application served under the /console path: the browser-based control panel an administrator logs into to manage the server. The write-up looks at how that console handles portal pages, and at the small configuration and code pieces that decide who is allowed in.
The bug was reported by a researcher the author refers to as a Chinese researcher, and the write-up credits @voidfyoo as MVP.
Setting up the analysis
The analysis was done on WebLogic [redacted]. The October patch is numbered 3191038; the July patch is 31535411. The method was patch diffing: download the software before and after the fix, compare the parts that changed, and read the difference. It is like comparing two versions of a document to see exactly which sentences an editor changed; the changed sentences tell you what the author was worried about.
Two classes changed in the console component:
HandleFactory.classMBeanUtilsInitSingleFileServlet.class
A class is a blueprint in Java: a named bundle of code and data that the program creates objects from. A .class file is the compiled form of that blueprint. If a patch touches a class, that class is probably where the bug lives.

The tools used were a debugger (a program that lets you pause a running application, inspect its variables and step through its code one line at a time) attached to a local WebLogic instance, and a modified build of GadgetInspector. GadgetInspector is a tool that scans Java code looking for chains of existing classes that, when fed attacker-controlled input, end up doing something dangerous. The author had previously adapted it heavily while working on Liferay, another Java product.
Finding it
The sink: HandleFactory.getHandle()
The first changed class examined was com.bea.console.handles.HandleFactory.getHandle(). In security language, a sink is the place in the code where dangerous work finally happens, for example where a class gets loaded or a command gets run. Finding the sink is half the job; the other half is finding a way to reach it.

The patch adds a type check on handleClass: only classes that are instances of com.bea.console.handles.Handle are allowed through. In plain terms, the fixed code now says "only accept objects of this one approved family".

That check tells you what the pre-patch code did. getHandle() takes a String (a piece of text), processes it through several steps, and eventually reaches Class.forName(className) to load the class. Class.forName is a Java function that takes the name of a class as text and loads that class into the running program. It then looks inside that class for a constructor taking a single String argument and creates a new instance from it. A constructor is the special piece of code that builds a new object; if it takes a String, the attacker's text becomes part of the new object.
The processing flow, as the author diagrams it:

The entrypoint can be triggered with the following GET request, which at this stage still requires an authenticated session. A GET request is the simplest kind of web request: your browser sends it when you type an address or click a link. An authenticated session means the server already knows who you are, usually because you logged in and it gave your browser a cookie to remember you.
http://<target>/console/console.portal?_nfpb=true&_pageLabel=HomePage1&handle=java.lang.String("ahihi")
Line by line: http://<target> is the server address, with <target> standing in for the real host. /console/console.portal is the path of the admin console's portal page. After the ? come query parameters, the name=value pairs a URL can carry: _nfpb=true and _pageLabel=HomePage1 are parameters the console expects, and handle=java.lang.String("ahihi") is the interesting one. The handle parameter's value is the text java.lang.String("ahihi"), which is the name of a Java class followed by a quoted argument. The server will take that text, load the class it names, and call its single-String constructor with ahihi.
With a breakpoint on HandleFactory.getHandle(), both handleConstructor and args are shown to be controlled from the input data. A breakpoint is a marker you place in the debugger so the program pauses there; then you can look at the variables. handleConstructor is the constructor the code found, and args are the arguments it will pass to it. Both coming from the request means the attacker decides which class is built and with what text.
This is the position abused for RCE in CVE-2020-14882. RCE stands for remote code execution: an attacker somewhere else on the network gets their own commands run on the victim's server. To exploit it, you need a class with a public constructor taking one String argument. At this point the author stopped: the sink was known, but there was no pre-auth entrypoint yet, so there was no point running the gadget tool. Pre-auth means reachable before logging in; post-auth means only after logging in.
The source: MBeanUtilsInitSingleFileServlet
Since HandleFactory.getHandle() is the sink, the other patched class, MBeanUtilsInitSingleFileServlet, is the likely source: the place where attacker input first enters the dangerous path.

The patch adds an IllegalUrl field:
private static final String[] IllegalUrl = new String[]{";", "%252E%252E", "%2E%2E", "..", "%3C", "%3E", "<", ">"};
Line by line: private static final means this is a value that belongs to the class itself and never changes. String[] means an array of text strings. IllegalUrl is the name. The list contains ;, %252E%252E, %2E%2E, .., %3C, %3E, < and >. The % sequences are URL encoding: a way of writing characters in a URL that would otherwise be awkward, where %2E means a dot and %25 means a percent sign. So %2E%2E is .. encoded once, and %252E%252E is .. encoded twice. The servlet's handling is simply to check whether the URL contains the string .. and reject the request if it does. Something about .. must matter, otherwise it would not be filtered. Reaching MBeanUtilsInitSingleFileServlet.service() also requires passing an authentication step, which made the author think this was only post-auth RCE and could not be the 9.8.
The console webapp layout
Like other Java servlets, WebLogic has a webapp folder; for the console it is:
\Middleware\Oracle_Home\wlserver\server\lib\consoleapp\webapp
This is a file path on disk: inside the Oracle installation, under Middleware, then Oracle_Home, then wlserver, then server, then lib, then consoleapp, then webapp. It contains the usual web.xml and struts-config.xml configuration files. A servlet is a Java program that handles web requests; web.xml is the file that tells the server which servlet answers which URL.

According to web.xml, MBeanUtilsInitSingleFileServlet is an init-param of AppManagerServlet. An init-param is a setting passed to a servlet when it starts up; here it means the single-file servlet is configured as part of the app manager servlet rather than being mapped to a URL on its own.

AppManagerServlet is mapped to these URL patterns:
/appmanager/**.portlet*.portion*.portal
A URL pattern is a rule with a wildcard: *.portal means "any path ending in .portal". That includes /console/console.portal, which is visible immediately after logging in to the console.

How authentication decisions are made
The class that decides whether a request needs authentication, in WebLogic [redacted], is weblogic.servlet.[redacted].WebAppSecurity.checkAccess().

Inside it, WebAppSecurityWLS.getConstraint(request) fetches the constraints for the current request. A constraint here is a rule about access: which URL patterns are protected and which are open. Each constraint carries information including an unrestrict flag: if unrestrict=true, the request is treated as unauthenticated; otherwise the login page is returned.
Stepping into WebAppSecurityWLS.getConstraint() gives the full constraint list, and from it the URL patterns that skip the authentication check:
/bea-helpsets/*/framework/skins/wlsconsole/images/*/framework/skins/wlsconsole/css/*/framework/skeletons/wlsconsole/js/*/framework/skeletons/wlsconsole/css/*/css/*/common/*/images/*
These are the paths the console serves without asking who you are: help content, images, stylesheets, scripts. That makes sense for a login page, which has to load its own pictures and styling before you are logged in.

Trying the usual URL bypass tricks against these patterns, for example ..;/ and /#/../, produced nothing useful. These tricks rely on different parts of the software disagreeing about what a path means. At this point the author was stuck.
The hint
No PoC had appeared on Twitter, so the author asked contacts for a hint (the person is kept anonymous). A PoC is a proof of concept: a small demonstration that the bug really works.

The contact sent a picture of a PoC.

The part abusing HandleFactory was already understood. The URL part was /console/console%2E%2E.portal, that is /console/console...portal. Testing it did not work: for /console/console%2E%2E.portal the constraint still returned unrestricted=false, meaning authentication was still required.

Asked again, the contact replied as follows.

The original PoC was only a hint: bypassing authentication needs a trick, abusing some resource, before it becomes unauthenticated RCE. Back to square one.
At that point the author brought in two more people, PeterJson and @Quynh Le, to work on it together, recalling CTF days when handing an idea to a teammate always worked better than playing alone. A CTF is a capture-the-flag competition, a friendly contest where people practise finding and exploiting deliberately planted bugs. The group of three focused on bugs in Java.

The unauthenticated entrypoint
The breakthrough came from a German member of the group, who found a URL that triggers MBeanUtilsInitSingleFileServlet with no authentication at all:
/console/css/changemgmt.portal
Line by line: /console is the admin console, /css/ is one of the paths the console serves without authentication, and changemgmt.portal is a file name ending in .portal, which is the pattern that routes to the portal handling. The two halves are combined in one path.

The author was surprised by the request, but testing confirmed it does trigger the servlet.

In the debugger, the constraint is indeed mapped to /css/, so it really is unrestricted.
More surprising still: the servlet handling this entrypoint is AsyncInitServlet, not FileServlet as expected.

For comparison, a normal request with a .css suffix is handled by FileServlet.

The author had assumed there was something magic in FileServlet and had been digging there. The magic is in web.xml, in the static resource declarations:

- URL pattern
/common/*is handled byJSPCServlet(which handles requests to JSP files). - URL patterns
/framework/*are handled byFileServlet. - The URL patterns
/images/*and/css/*have no servlet declared to handle them.
Because of that, a request to /console/css/aaasdasdasd.portal is handled by AppManagerServlet. In summary:
/css/*bypasses authentication..portaltriggers the portal handling.
At this point MBeanUtilsInitSingleFileServlet.service() is reachable without authentication. The request still cannot reach HandleFactory.getHandle(), because the URL pattern does not match a portlet.
Double encoding
The original hint from the Chinese researcher now made sense.

The .. was meant to hint at using double encoding to trigger the bug. Double encoding means encoding a value twice: .. becomes %2E%2E, and encoding that again gives %252E%252E. Each time a piece of software decodes the URL, one layer comes off. If one check looks at the URL after one decode and a later step decodes again, the two steps can see different strings. Retesting confirmed it:

After passing through MBeanUtilsInitSingleFileServlet.service() and several more steps, at UIServletInternal.getTree() the URL pattern is parsed again and the URL is decoded one more time.

Before decoding.
After decoding:

This explains why a double-encoded URL both bypasses the initial normalised-URL handling and still lets the later servlet handling work correctly. Normalisation is the process of cleaning up a path, for example turning a/../b into b, so that checks and routing agree on what the path means.
Exploitation
- Reach the servlet unauthenticated. Request a path under
/css/with a.portalsuffix, for example/console/css/changemgmt.portal. The/css/*constraint is unrestricted, and because no servlet is declared for/css/*,AppManagerServlethandles the request and reachesMBeanUtilsInitSingleFileServlet.service(). - Match the portlet pattern. The URL must match a portlet pattern for the request to reach
HandleFactory.getHandle(). The..hint points to double encoding: the first normalisation rejects a literal.., but the later decode inUIServletInternal.getTree()turns the double-encoded sequence back into.., so the portlet pattern matches. - Control the handle. Supply the
handleparameter in the formjava.lang.String("ahihi")as in the authenticated example, so thatClass.forName(className)loads the named class and its single-String constructor is invoked with the attacker's argument. - Pick a gadget class. The original PoC used
com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext()to trigger RCE, but that chain requires outbound access. Outbound access means the server is allowed to make its own connections out to the internet; many servers are configured to block that. - Find a no-outbound chain. The author modified GadgetInspector for the new context and ran it for about five minutes, producing many results. One chain looked promising:

- Reach command execution. The chain, after receiving the argument from the constructor, calls
ShellSession.exec()and executes with that argument.

The chain behind ShellSession.exec() is long; the author summarises it as follows:

This allows execution of arbitrary MVEL expressions. MVEL is an expression language: a small scripting syntax that Java programs can evaluate at runtime, so a string written in MVEL can make the program do things. The author notes surprise at finding such ready-made material in the code, and is not sure whether it is a backdoor left in the code. 7. Build the final PoC. Combining all of the above, the author wrote a PoC that executes a command and returns the response. The final PoC was completed by Duc, not by the author.
PoC video: https://youtu.be/JFVDOIL0YtA
Root cause
Two mistakes combine.
First, HandleFactory.getHandle() takes a String from the request, resolves it with Class.forName(className), and instantiates the class through a public single-String constructor, without restricting which classes are acceptable. The October patch adds exactly that restriction, allowing only instances of com.bea.console.handles.Handle.
Second, the console's web.xml leaves /css/* and /images/* without a declared servlet, while the security constraints mark /css/* as unrestricted. A request under /css/ with a .portal suffix therefore skips authentication and is still routed to AppManagerServlet, which reaches MBeanUtilsInitSingleFileServlet. The servlet's handling checks whether the URL contains .., but the URL is decoded again later in UIServletInternal.getTree(), so a double-encoded sequence passes the first check and becomes .. for the portlet matching. The patch adds the IllegalUrl list, including %252E%252E, %2E%2E and ...
Impact
An unauthenticated attacker can execute arbitrary commands on a WebLogic server over HTTP, with the response returned to the attacker, according to the author's PoC. The bug affects all versions and is rated CVSS 9.8/10. The original PoC's FileSystemXmlApplicationContext chain requires outbound access; the author's alternative chain does not, which matters because many servers block outbound traffic.
Fix
The October 2020 CPU patch analysed here is numbered 3191038. The changes are:
HandleFactory.getHandle()now checks the type ofhandleClassand only allows instances ofcom.bea.console.handles.Handle.MBeanUtilsInitSingleFileServletnow rejects URLs containing any of the strings inIllegalUrl:;,%252E%252E,%2E%2E,..,%3C,%3E,<,>.
Variants to test
- Undeclared static paths with a portal suffix. Request paths under
/css/or/images/with a.portalsuffix, for example/console/css/changemgmt.portal. A positive result is the request reachingMBeanUtilsInitSingleFileServletwithout a login redirect, visible in a debugger onWebAppSecurity.checkAccess()asunrestricted=true. - Double-encoded traversal in the portlet pattern. Combine the
/css/prefix with a double-encoded..so the first normalisation passes and the later decode inUIServletInternal.getTree()restores... A positive result is the URL matching a portlet pattern after decoding. - Handle parameter with arbitrary classes. Send
handle=java.lang.String("ahihi")(or another class with a public single-String constructor) toconsole.portal. A positive result is a breakpoint inHandleFactory.getHandle()showinghandleConstructorandargscontrolled by the input. - Constructor gadget search. Run GadgetInspector (or similar) against the console classpath for classes with a public single-String constructor that reach command execution, such as the
ShellSession.exec()chain. A positive result is a chain that executes without outbound access. - Other unrestricted patterns. Test the remaining patterns from the constraint list (
/bea-helpsets/*,/framework/skins/wlsconsole/images/*,/framework/skins/wlsconsole/css/*,/framework/skeletons/wlsconsole/js/*,/framework/skeletons/wlsconsole/css/*,/common/*,/images/*) with portal suffixes. A positive result is any of them reachingAppManagerServletwithout authentication.
Glossary
- API: an interface that lets one program ask another to do something, without needing to know how it works inside.
- AppManagerServlet: the WebLogic console servlet that handles portal-style requests and reaches the single-file servlet.
- AsyncInitServlet: the servlet the debugger showed handling the
/css/entrypoint, rather thanFileServlet. - Authentication: proving who you are, usually by logging in.
- Breakpoint: a marker in a debugger that pauses the program so you can inspect its variables.
- Class: a named blueprint in Java from which objects are created; a
.classfile is its compiled form. - Class.forName: a Java function that loads a class by its name given as text.
- Constraint: an access rule in the web configuration saying which URL patterns are protected and which are open.
- Constructor: the code that builds a new object; a single-String constructor takes one piece of text as input.
- Cookie: a small piece of data a website stores in your browser to remember you between requests.
- CPU (Critical Patch Update): Oracle's regular quarterly batch of security fixes.
- CTF: capture-the-flag, a practice competition for finding and exploiting planted bugs.
- CVSS: a public scoring system for the severity of a security flaw, from 0 to 10.
- CVE: a public identifier for a specific security vulnerability.
- Debugger: a tool that lets you pause a running program, inspect variables and step through code.
- Deserialisation: turning a stream of bytes back into live objects inside a program; dangerous when the bytes are attacker-controlled.
- Double encoding: encoding a value twice, so that each decode step reveals a different string.
- FileServlet: the servlet that handles normal static file requests such as
.cssfiles. - GadgetInspector: a tool that scans Java code for chains of existing classes that can be abused to do something dangerous.
- GET request: the simplest kind of web request, sent when you open a URL.
- HandleFactory.getHandle(): the console method that loads a class named in the request and builds an object from it; the sink of this bug.
- HTTP: the ordinary web protocol browsers use to load pages.
- IIOP: another internal WebLogic protocol, alongside T3.
- Init-param: a setting passed to a servlet when it starts up.
- JSPCServlet: the servlet that handles requests to JSP files under
/common/*. - MBeanUtilsInitSingleFileServlet: the console servlet whose patch added the
IllegalUrlfilter; the source of this bug. - MVEL: an expression language that Java programs can evaluate at runtime.
- Normalisation: cleaning up a path so that checks and routing agree on what it means.
- Outbound access: whether a server is allowed to make its own connections out to the internet.
- Patch diffing: comparing software before and after a fix to see exactly what changed.
- PoC: proof of concept, a small demonstration that a bug really works.
- Post-auth: reachable only after logging in.
- Pre-auth: reachable before logging in.
- Query parameters: the name=value pairs after the
?in a URL. - RCE: remote code execution, running an attacker's commands on someone else's server.
- Servlet: a Java program that handles web requests.
- Session: the server's memory of who you are across several requests, usually kept via a cookie.
- Sink: the place in code where dangerous work finally happens.
- Source: the place where attacker input first enters the dangerous path.
- T3: a proprietary WebLogic protocol used for internal communication.
- URL encoding: writing characters in a URL as
%sequences, such as%2Efor a dot. - URL pattern: a rule with a wildcard, such as
*.portal, saying which URLs a servlet handles. - web.xml: the configuration file that maps URLs to servlets and declares access constraints.
- WebLogic: Oracle's Java application server.
- WebAppSecurity.checkAccess(): the WebLogic class that decides whether a request needs authentication.
- WebAppSecurityWLS.getConstraint(): the method that fetches the access constraints for a request.