Skip to content
RCE Write-up Advanced

Miracle One Vulnerability To Rule Them All

Nguyễn Tiến Giang Follow

Published on peterjson.medium.com

As mentioned in Jang blog, We (me and Jang) found a mega 0-day. After April Critical Patch, finally the vulnerability was patched properly.

Peterjson, on peterjson.medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

me and Jang trying to pwn Oracle :D From the original on peterjson.medium.com

Context

The target is Oracle Fusion Middleware, and specifically the ADF Faces framework that many Oracle products and Oracle online services are built on. The bug the authors call The Miracle Exploit (Middleware Fusion with Oracle) is a pre-auth deserialisation of untrusted data in ADF Faces, tracked as CVE-2022-21445. Because the flaw sits in the framework rather than in a single product, any application built from ADF is affected, including Oracle Cloud Infrastructure and Oracle's own online systems.

The feature involved is the resource-serving servlet. While investigating Oracle Business Intelligence, the authors found the servlet org.apache.myfaces.trinidad.webapp.ResourceServlet, which is mapped into several paths. The servlet fetches a resource named in the request and looks it up through org.apache.myfaces.trinidad.resource.ResourceLoader.getResource().

https://www.zerodayinitiative.com/advisories/published/ From the original on peterjson.medium.com

Setup

The work was a source-code review of ADF Faces, combined with spinning up virtual machines and installing the affected products to confirm exploitation. The authors report pre-auth RCE against:

  • Oracle Business Intelligence
  • Oracle Enterprise Manager
  • Oracle Identity Management
  • Oracle SOA Suite
  • Oracle WebCenter Portal
  • Oracle Application Testing Suite
  • Oracle Transportation Management

A key precondition is the version split. The authors first achieved pre-auth RCE on Oracle Fusion Middleware 12.x, but most online instances run 10.3.x, so a gadget chain that works under 10.3.x was needed. For Oracle Access Manager (OAM), the public SSO port is 14100, which does not use ADF, while the console on port 7001 exposes /em/ (Oracle Enterprise Manager) and /oamconsole/ (OAM Console), both heavily based on ADF. The chain therefore had to reach the ADF application on 7001 from the non-ADF application on 14100.

Finding it

The servlet and the loader

ResourceServlet.doGet() fetches the resource from the request and resolves it via ResourceLoader.getResource().

servlet mappings From the original on peterjson.medium.com

servlet mappings

org.apache.myfaces.trinidad.webapp.ResourceServlet.doGet() From the original on peterjson.medium.com

org.apache.myfaces.trinidad.webapp.ResourceServlet.doGet()

org.apache.myfaces.trinidad.resource.ResourceLoader.getResource() From the original on peterjson.medium.com

org.apache.myfaces.trinidad.resource.ResourceLoader.getResource()

Many classes override ResourceLoader.findResource(). Reviewing each override, oracle.adfinternal.view.resource.rich.RemoteApplicationResourceLoader stood out: it restores the resource from user input, which leads to deserialisation of untrusted data.

From the original on peterjson.medium.com
oracle.adfinternal.view.resource.rich.RemoteApplicationResourceLoader

oracle.adfinternal.view.resource.rich.RemoteApplicationResourceLoader

oracle.adfinternal.view.resource.rich.RemoteApplicationResourceLoader._getPathBean() From the original on peterjson.medium.com

oracle.adfinternal.view.resource.rich.RemoteApplicationResourceLoader._getPathBean()

oracle.adfinternal.view.rich.remote.resources.URLEncoderPathBean.getInstanceFromString() From the original on peterjson.medium.com

oracle.adfinternal.view.rich.remote.resources.URLEncoderPathBean.getInstanceFromString()

oracle.adf.view.rich.util.SerializationUtils.fromURLEncodingString() From the original on peterjson.medium.com

oracle.adf.view.rich.util.SerializationUtils.fromURLEncodingString()

The source

With the deserialisation sink identified, the authors needed a source that reaches it. In the constructor of oracle.adfinternal.view.resource.rich.RenderKitResourceLoader there are many defined paths, each mapped to a loader that handles it.

From the original on peterjson.medium.com

The resulting trigger URL is:

Text
http://HOST:PORT/contextApp/afr/foo/remote/bar/

where foo can be any string and bar is the payload.

Exploitation

Step 1: deserialisation on Oracle BI

This produced a successful pre-auth RCE on Oracle BI.

Step 2: SSRF in OAM (CVE-2022-21497)

For OAM, the authors focused on the SSO application on port 14100 to find SSRF or XXE, since the ADF-based consoles on 7001 are not directly reachable from the pre-auth surface. They built on tint0's research on XMLSec. OAM already blocks tint0's bugs through OSDT (Oracle Security Developer Tools), so the authors studied how OAM handles SAML between SP and IDP.

When processing a SAML Response, OAM processes the EncryptedAssertion element, and the KeyInfo element is processed before any authentication check. That places the attacker in a pre-auth context. The authors chose SOAP-based SAML over HTTP-based because they judged XXE/SSRF easier to find there.

Inside oracle.security.fed.security.crypto.enc.DomXmlDecrypter.decryptElement(), OAM takes the KeyInfo from user input.

oracle.security.fed.security.crypto.engine.impl.SAML20XmlCryptoEngine.processIncoming() From the original on peterjson.medium.com

oracle.security.fed.security.crypto.engine.impl.SAML20XmlCryptoEngine.processIncoming()

oracle.security.fed.security.crypto.enc.DomXmlDecrypter.getDecryptionKey() From the original on peterjson.medium.com

oracle.security.fed.security.crypto.enc.DomXmlDecrypter.getDecryptionKey()

From the original on peterjson.medium.com

In oracle.security.xmlsec.keys.RetrievalMethod.getKeyInfoData(), dereference() is triggered. ResolverDirectHTTP and ResolverLocalFilesystem cannot be used as in tint0's work, but the Transformation can. OSDT blocks the XSLT transform, so XPath is the candidate, and the document() function makes a GET HTTP request to a local ADF-based web application (EM or OAM Console on port 7001).

oracle.security.xmlsec.dsig.ObjectReference.dereference() From the original on peterjson.medium.com

oracle.security.xmlsec.dsig.ObjectReference.dereference()

Soap Based SAML request to http://HOST:PORT/oamfed/idp/soap/ From the original on peterjson.medium.com

Soap Based SAML request to http://HOST:PORT/oamfed/idp/soap/

Combining the SSRF with the ADF Faces deserialisation gives pre-auth RCE on Oracle Access Manager. The step is pre-auth because the KeyInfo is read before the cryptography check on the EncryptedAssertion.

Step 3: a universal gadget chain for 10.3.x

The class loader order from child to parent is:

  • GenericClassLoader > FilteringClassLoader > GenericClassLoader > Launcher$AppClassLoader

FilteringClassLoader is Oracle's classloader that applies a blacklist to dangerous classes during deserialisation. When ObjectInputStream.readObject() is called, the serialised object is reconstructed with the current classloader, the one at the call site. loadClass() searches from child to parent: GenericClassLoader, then FilteringClassLoader, and so on.

From the original on peterjson.medium.com

If the class name matches the filtered pattern, FilteringClassLoader.findClass() throws ClassNotFound and stops searching the parent. The filter list includes entries such as com.tangosol and org.python, which is why coherence.jar being loaded on the classpath did not help: deserialisation still threw ClassNotFound.

From the original on peterjson.medium.com

The bypass is to find a call to readObject() from an override of readObject(ObjectInputStream), so the classloader at that call site is not the FilteringClassLoader:

From the original on peterjson.medium.com

The authors wrap the serialised gadget chain in a ConcurrentHashMap:

From the original on peterjson.medium.com

Before ObjectInputStream.readObject() is called, the classloader is Launcher$AppClassLoader, not FilteringClassLoader. Separately, newer WebLogic versions apply a serialisation blacklist to the global runtime, but that blacklist applies to the WebLogic runtime, not the OAM/ADF context, which leaves room to craft the RCE chain.

At this point the authors had an unrestricted insecure deserialisation in the OAM/ADF context, with most WebLogic 10.3.6 libraries and coherence.jar on the classpath. Common chains (CommonsCollections series, Spring, CommonsBeanUtils) worked on local setups but not on public targets, for reasons the authors did not determine.

Step 4: abusing the coherence extractors

coherence.jar provides the ValueExtractor.extract() family, including MvelExtractor, FilterExtractor and ReflectionExtractor. Oracle patched these by checking the target object before invoking:

From the original on peterjson.medium.com

If oTarget is not in the blacklist, the method is invoked.

From the original on peterjson.medium.com

Oracle is oracle ...

The reflection blacklist matches every class that is an instance of java.lang.Class, java.lang.System and java.lang.Runtime.

From the original on peterjson.medium.com

CVE-2020-2555 used ChainedExtractor to chain extractors into an RCE chain, but that method uses java.lang.Class to get and invoke the destination method and involves java.lang.Runtime, so it is filtered here. The remaining capability is invoking any public method of any Serializable object.

The authors found RemoteInvocation, which is Serializable and has an invoke() method:

From the original on peterjson.medium.com

RemoteInvocation.invoke() uses the Reflect API to get and invoke a method from fully controlled parameters: methodName, parameterType and arguments. This completes the filtered ReflectionExtractor.extract().

Because ReflectionExtractor.extract() does not allow invoking an instance of type java.lang.Class, the chain is built with ChainedExtractor to reuse the result of one method execution as the argument of the next. The chain contains two ReflectionExtractor instances:

From the original on peterjson.medium.com
  1. The first ReflectionExtractor calls RemoteInvocation.invoke() with another RemoteInvocation instance as the argument.
  2. In the second RemoteInvocation.invoke(), the method newInstance() is taken from java.lang.Class (available by default) and invoked with the class ShellSession as the argument, equivalent to new ShellSession().
  3. The return object is a ShellSession instance, which is not filtered by the blacklist.
  4. The second stage calls ShellSession.exec() to execute a command using MVEL syntax.

Root cause

RemoteApplicationResourceLoader restores a resource from user input and passes it to URLEncoderPathBean.getInstanceFromString() and SerializationUtils.fromURLEncodingString(), deserializing untrusted data. The RenderKitResourceLoader constructor maps paths to loaders, and the /afr/foo/remote/bar/ URL shape lets an attacker reach the deserialisation sink with a GET request. The existing defences did not stop it: the FilteringClassLoader blacklist is bypassed by calling readObject() from an override so the classloader at the call site is Launcher$AppClassLoader, and the WebLogic serialisation blacklist applies to the WebLogic runtime rather than the OAM/ADF context. The coherence extractor blacklist is bypassed with RemoteInvocation and ChainedExtractor.

Impact

Any website built with ADF Faces is affected, including many Oracle online systems and Oracle Cloud Infrastructure. The authors achieved pre-auth RCE on Oracle BI and on OAM, and reported pre-auth RCEs to some large companies through their bug bounty programmes after the patch was released. For OAM, the SSRF on port 14100 reaches the ADF consoles on 7001 and leads to pre-auth RCE.

In the demonstration sent to Oracle, the authors chose edelivery.oracle.com and businessnetwork.oracle.com, both based on ADF Faces. They used a check script for the Miracle Exploit and only proved that they could get some information from Oracle's systems rather than execute commands, because executing commands might affect Oracle's systems and leak sensitive information.

edelivery.oracle.com From the original on peterjson.medium.com

edelivery.oracle.com

businessnetwork.oracle.com From the original on peterjson.medium.com

businessnetwork.oracle.com

They also achieved pre-auth RCE on login.oracle.com, which plays an important role in Oracle's online services.

login.oracle.com From the original on peterjson.medium.com

login.oracle.com

The authors state they targeted Oracle's sites to demonstrate the impact and prompt action, and that Oracle took 6 months to patch the vulnerability.

Fix

The patch was applied in oracle.adfinternal.view.rich.remote.resources.URLEncoderPathBean.getInstanceFromString().

original From the original on peterjson.medium.com

original

the patch From the original on peterjson.medium.com

the patch

Oracle fixed the ADF Faces vulnerability in the April Critical Patch (19/04/2022), and the first pre-auth RCE in OAM found by Jang was fixed in the January Critical Patch (18/01/2022). The authors describe the ADF Faces patch as small changes.

Variants to test

  • Other ADF-based products. Install Oracle Enterprise Manager, Oracle Identity Management, Oracle SOA Suite, Oracle WebCenter Portal, Oracle Application Testing Suite or Oracle Transportation Management and request http://HOST:PORT/contextApp/afr/foo/remote/bar/ with a serialised payload in bar. A positive result is deserialisation of the payload, for example a ClassNotFoundException for a probe class or code execution with a working chain.
  • Other resource loaders. Review overrides of ResourceLoader.findResource() for other loaders that restore resources from user input. A positive result is a path that reaches SerializationUtils.fromURLEncodingString() with attacker-controlled data.
  • SAML KeyInfo handling. Send a SOAP-based SAML request to http://HOST:PORT/oamfed/idp/soap/ with an EncryptedAssertion whose KeyInfo uses a RetrievalMethod with an XPath document() transformation. A positive result is an outbound GET request to the target host, visible in logs or a callback.
  • Classloader bypass. On 10.3.x, wrap a serialised gadget chain in a ConcurrentHashMap so readObject() is called from an override. A positive result is that classes blocked by FilteringClassLoader (such as com.tangosol or org.python) load successfully.
  • Extractor blacklist bypass. Build a ChainedExtractor with two ReflectionExtractor instances and a RemoteInvocation to call newInstance() on java.lang.Class with a ShellSession argument, then call ShellSession.exec(). A positive result is command execution with the extractor target outside the reflection blacklist.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 20 min read.

## What happened, in plain words

Two researchers, Nguy�
n Tiến Giang (known online as Jang) and peterjson, found a serious security flaw in software made by Oracle. Oracle is a large company whose database and business software runs a huge amount of the world's companies, banks and government systems. The flaw they found was not in one product: it was in a shared building block that many Oracle products are made from. That means one bug opened the door to many different systems at once, including some of Oracle's own public websites. The researchers nicknamed it **The Miracle Exploit**, a play on the words Middleware **Fusion** with Oracle.

The bug belongs to a family called **deserialisation of untrusted data**. To understand that, you first need to understand what serialisation is. When a program wants to save an object (a bundle of data and code in memory) to a file, or send it over the network, it converts it into a stream of bytes. That conversion is called **serialisation**. Turning the bytes back into a live object is called **deserialisation**. The danger is that if a program deserializes bytes that an attacker controls, the attacker can craft those bytes so that, when they are turned back into objects, the program ends up running the attacker's code. It is a bit like a parcel service that will assemble any flat-pack furniture you post to it: if you post the parts for something dangerous, it will happily build it.

Because the flaw was in a framework (a reusable set of code that many applications are built on top of) rather than in a single application, every website built with that framework was affected. The researchers confirmed this against a long list of Oracle products and against Oracle's own online services. They call the attack **pre-auth**, which means it works before the attacker has logged in: no username, no password, no session needed.


{{media:0}}


*The two researchers, pictured while working on the Oracle target.*

## The story behind it

The researchers explain that they found this bug while reading the source code of **ADF Faces**, a component inside Oracle Fusion Middleware. Oracle Fusion Middleware is a collection of server software that companies use to run business applications. ADF Faces is the part that draws the user interface, the web pages you see in the browser. Reading source code (the human-written instructions that make up a program) is a common way to find bugs: you follow the logic and look for places where the program trusts something it should not.

After about a day of reading, the first researcher confirmed a pre-auth remote code execution (RCE) in ADF Faces. **Remote code execution** means an attacker can make the server run commands of their choosing, from a distance, without ever touching the machine. It is generally the most severe kind of bug, because from there an attacker can read data, change data or take the machine over.

At that point the bug only worked on version 12.x of Oracle Fusion Middleware. But most of the systems reachable on the internet ran version 10.3.x. So the researchers needed a second piece of work: a **gadget chain** that works on 10.3.x. A gadget chain is a sequence of otherwise harmless pieces of code, already present in the software, that can be stitched together through deserialisation so that the end result is code execution. Think of it as a Rube Goldberg machine built only from parts that are already in the room. The researchers worked on that, and after a month they had a chain that worked broadly.

## The start of the journey

The researchers had previously worked with the **Zero Day Initiative** (ZDI), an organisation that buys and coordinates the disclosure of security bugs, on Oracle Business Intelligence. **Oracle Business Intelligence** (Oracle BI) is Oracle's reporting and analytics product: companies use it to build dashboards and reports from their data. This time they went back to Oracle BI hoping to find more bugs.


{{media:1}}


*A list of published advisories on the Zero Day Initiative site, where the earlier Oracle BI bugs were disclosed.*

### The servlet that serves resources

While looking at Oracle BI, they found an interesting **servlet**. A servlet is a small Java program that runs on a web server and handles a particular kind of request. When your browser asks for a page or a file, the server decides which servlet should handle that request. The servlet they found is called `org.apache.myfaces.trinidad.webapp.ResourceServlet`. Its job is to serve **resources**: files such as images, stylesheets or scripts that a web page needs.

The servlet was mapped to several URL paths. A **mapping** is the rule that says "requests whose address looks like this go to that servlet".


{{media:2}}


*The servlet mappings: the URL patterns that route requests to this servlet.*


{{media:3}}


*The `doGet()` method of `ResourceServlet`. `doGet()` is the part of a servlet that runs when the browser makes a GET request, which is the ordinary kind of request your browser makes when you open a link.*

The servlet takes the name of a resource from the incoming request and tries to find that resource using `org.apache.myfaces.trinidad.resource.ResourceLoader.getResource()`. In plain terms: the browser says "give me the file called X", and the server looks up X.


{{media:4}}


*The `getResource()` method of `ResourceLoader`, which looks up the resource named in the request.*

Many different classes override the `findResource()` method of `ResourceLoader`. **Overriding** means a subclass replaces the behaviour of a method defined in its parent class. So there are many different ways the server can look up a resource, one per subclass.


{{media:5}}


*A list of the classes that override `findResource()`.*

After reviewing each of those overrides, one stood out: `oracle.adfinternal.view.resource.rich.RemoteApplicationResourceLoader`. The bug is in its logic: when it tries to restore a resource from user input, it ends up deserializing untrusted data. In other words, the resource name supplied by the browser is not just treated as text; it is decoded back into an object, and that decoding is the dangerous deserialisation step.


{{media:6}}


*The `RemoteApplicationResourceLoader` class.*


{{media:7}}


*Its `_getPathBean()` method, where the user-supplied path is turned back into an object.*


{{media:8}}


*`URLEncoderPathBean.getInstanceFromString()`, which reconstructs the object from the URL-encoded string.*


{{media:9}}


*`SerializationUtils.fromURLEncodingString()`, the actual deserialisation call.*

So the researchers now had the **sink**: the place where dangerous data finally gets used. In security work you also need the **source**: the place where the attacker's data enters. Finding a sink is only useful if you can reach it with data you control.

### Finding the way in

Looking further, they found that the constructor of `oracle.adfinternal.view.resource.rich.RenderKitResourceLoader` defines many paths, each mapped to a loader that handles it. A **constructor** is the code that runs when an object is first created; here it sets up a table of paths and the loaders responsible for them.


{{media:10}}


*The constructor of `RenderKitResourceLoader`, showing the defined paths and their loaders.*

That table gives the URL shape needed to reach the sink:

```text
http://HOST:PORT/contextApp/afr/foo/remote/bar/
```

Line by line:

- `http://` is the ordinary web protocol your browser uses.
- `HOST` is the server's name or address.
- `PORT` is the numbered door on that server that the web application listens on. A single machine can run many services, each on its own port.
- `contextApp` is the name of the particular web application inside the server.
- `/afr/` is the fixed part of the path that routes the request to the resource-serving code.
- `foo` can be any string at all; it just has to be there to match the pattern.
- `/remote/` is another fixed part of the path that selects the remote resource loader.
- `bar` is the payload: the attacker's crafted bytes, encoded so they can travel inside a URL.

With that, they used **CVE-2020-14644** to exploit the deserialisation bug. A **CVE** is a public identifier for a known vulnerability, like a catalogue number. CVE-2020-14644 is an older bug whose gadget chain is not filtered during deserialisation, so it still worked here. The result was a successful pre-auth RCE on Oracle BI.

## Exploring more affected products

Because the flaw is inside the ADF Faces framework, any product or application built with ADF is affected. To confirm, the researchers set up virtual machines (software-simulated computers) and installed the products. They report achieving pre-auth RCE against:

- Oracle Business Intelligence
- Oracle Enterprise Manager
- Oracle Identity Management
- Oracle SOA Suite
- Oracle WebCenter Portal
- Oracle Application Testing Suite
- Oracle Transportation Management

For **Oracle Access Manager** (OAM), they found two ways to get pre-auth RCE. OAM is Oracle's single sign-on product: it is the system that lets a user log in once and then use many different applications. The first way was already published by Jang in a separate write-up. The researchers chose to focus on OAM because it sits at the centre of many companies' infrastructure, and because many of Oracle's own online and cloud services use OAM as their login service.

## The second OAM chain: SSRF plus deserialisation

Here is the setup. When OAM is installed, port 14100 is the single sign-on endpoint, public to the internet so users can log in. That application does not use ADF. On port 7001, however, there are consoles: `/em/` for Oracle Enterprise Manager and `/oamconsole/` for the OAM Console. Both are heavily built on ADF. So the researchers focused on the web application on port 14100, looking for bugs such as **SSRF** or **XXE** that could be chained into a full pre-auth RCE.

Two more terms to define:

- **SSRF** (server-side request forgery) means tricking the server into making a request of the attacker's choosing, for example to another service on the same machine that the attacker cannot reach directly. It is like persuading a receptionist to phone an internal extension for you.
- **XXE** (XML external entity) is a related bug in XML parsing. XML is a text format for structured data, and it allows "entities" that can point to external resources. If the parser follows them, an attacker can make the server fetch files or URLs.

The researchers built on earlier research by a security researcher known as tint0, on XML security libraries. OAM already blocks tint0's specific bugs through **OSDT** (Oracle Security Developer Tools), Oracle's own security library. So the researchers studied how OAM handles **SAML** between the service provider and the identity provider.

**SAML** is a standard for exchanging login information between systems. In SAML terms, the **identity provider** (IDP) is the system that authenticates the user, and the **service provider** (SP) is the application the user wants to access. When you click "log in with company account", SAML is often what happens behind the scenes.

When OAM processes a SAML Response message, it handles the `EncryptedAssertion` element. An **assertion** is the statement "this user is who they say they are"; when encrypted, it is wrapped in `EncryptedAssertion`. To decrypt it, OAM needs a key, and it finds that key through the `KeyInfo` element. Crucially, `KeyInfo` is processed before any authentication check. That means the attacker is already in a pre-auth position: they can influence what OAM does with `KeyInfo` without logging in.

SAML can be carried over HTTP or over SOAP. **SOAP** is a protocol for exchanging structured messages between systems, usually over HTTP. The researchers chose SOAP because they judged XXE and SSRF easier to find there.

Inside `oracle.security.fed.security.crypto.enc.DomXmlDecrypter.decryptElement()`, OAM takes the `KeyInfo` from user input.


{{media:11}}


*`SAML20XmlCryptoEngine.processIncoming()`, where the incoming SAML message is processed.*


{{media:12}}


*`DomXmlDecrypter.getDecryptionKey()`, where the key information is read from the message.*


{{media:13}}


*The code path that leads from the incoming message to the key lookup.*

Inside `oracle.security.xmlsec.keys.RetrievalMethod.getKeyInfoData()`, the `dereference()` method is triggered. `RetrievalMethod` is a way of saying "fetch the key from over there", and `dereference()` is the act of going to fetch it. This is where the bug lives. The researchers could not use `ResolverDirectHTTP` or `ResolverLocalFilesystem` the way tint0 did. But they could use the **Transformation**.

A **Transformation** in XML security is a processing step applied to data, for example an XSLT transform (a language for transforming XML) or an XPath expression (a language for selecting parts of XML). OSDT blocks the XSLT transform, so XPath was the candidate. And XPath has a function called `document()` which fetches an external document. That gives the researchers a way to make the server issue a GET request to a URL of their choosing.


{{media:14}}


*`ObjectReference.dereference()`, where the transformation is applied and the fetch happens.*


{{media:15}}


*A SOAP-based SAML request sent to `http://HOST:PORT/oamfed/idp/soap/`.*

The `document()` function lets them make a GET request to a local ADF-based web application, meaning the Enterprise Manager or OAM Console on port 7001. That is the SSRF. Combined with the ADF Faces deserialisation, it gives pre-auth RCE on Oracle Access Manager. The whole thing is pre-auth because the `KeyInfo` is read before the cryptography check on the `EncryptedAssertion`.

## A universal gadget chain for 10.3.x

There was a big problem. Most public targets run 10.3.x, not 12.x. And CVE-2020-14664 does not work on 10.3.x because of the **class loader**. A class loader is the part of Java that finds and loads classes (the blueprints for objects) when a program needs them. If the class loader refuses to load a class, deserialisation fails with a `ClassNotFoundException`.

The researchers describe it as having a big gun but no bullets. They were not willing to report a pre-auth deserialisation without a working RCE, so they set out to build a chain that works on 10.3.x.

The class loader order, from child to parent, is:

- `GenericClassLoader` > **FilteringClassLoader** > `GenericClassLoader` > `Launcher$AppClassLoader`

`FilteringClassLoader` is a class loader Oracle wrote to apply a **blacklist** to dangerous classes during deserialisation. A blacklist is a list of things that are forbidden. When `ObjectInputStream.readObject()` is called, the serialised object is rebuilt using the class loader that is current at the place where `readObject()` was called. `loadClass()` searches from child to parent: first `GenericClassLoader`, then `FilteringClassLoader`, and so on.


{{media:16}}


*The `findClass()` method of `FilteringClassLoader`.*

If the class name matches a filtered pattern, `FilteringClassLoader.findClass()` throws `ClassNotFound` and stops searching the parent. The filter list includes entries such as `com.tangosol` and `org.python`. That is why `coherence.jar` being present on the classpath did not help: deserialisation still threw `ClassNotFound`. A **classpath** is the list of places Java looks for classes; a `.jar` file is a packaged library of Java classes.


{{media:17}}


*The filter list used by `FilteringClassLoader`.*

The bypass is to find a call to `readObject()` from an override of `readObject(ObjectInputStream)`. Because that call site is inside a different class, the class loader in effect there is not the `FilteringClassLoader`.


{{media:18}}


*An example of a `readObject()` override that calls `readObject()` again.*

The researchers wrap the serialised gadget chain in a `ConcurrentHashMap`. A `ConcurrentHashMap` is a standard Java collection (a map from keys to values) that is safe to use from multiple threads at once. It is useful here because it has its own `readObject()` override.


{{media:19}}


*The `ConcurrentHashMap` wrapper around the serialised gadget chain.*

Before `ObjectInputStream.readObject()` is called, the class loader is `Launcher$AppClassLoader`, not `FilteringClassLoader`. Separately, newer WebLogic versions apply a serialisation blacklist to the global runtime. **WebLogic** is Oracle's Java application server, the software that runs Java web applications. But that blacklist applies to the WebLogic runtime, not to the OAM/ADF context, which leaves room to craft the RCE chain.

At this point the researchers had an unrestricted insecure deserialisation in the OAM/ADF context, with most WebLogic 10.3.6 libraries and `coherence.jar` on the classpath. They tried common chains such as the CommonsCollections series, Spring and CommonsBeanUtils. These are well-known gadget chains built from popular Java libraries. Most of them worked on local setups but not on public targets, for reasons the researchers did not determine.

## Abusing the coherence extractors

`coherence.jar` provides the `ValueExtractor.extract()` family, including `MvelExtractor`, `FilterExtractor` and `ReflectionExtractor`. An **extractor** is a small object whose job is to pull a value out of another object. Oracle patched these by checking the target object before invoking:


{{media:20}}


*The check Oracle added before invoking the extractor.*

If `oTarget` is not in the blacklist, the method is invoked.


{{media:21}}


*A comment from the researchers on Oracle's approach.*

The reflection blacklist matches every class that is an instance of `java.lang.Class`, `java.lang.System` and `java.lang.Runtime`. These are the Java classes that represent classes themselves, the system, and the ability to run commands. Blocking them blocks the obvious ways to reach code execution.


{{media:22}}


*The reflection blacklist.*

CVE-2020-2555 used `ChainedExtractor` to chain extractors into an RCE chain. A **ChainedExtractor** runs several extractors in sequence, feeding the result of one into the next. But that method uses `java.lang.Class` to get and invoke the destination method and involves `java.lang.Runtime`, so it is filtered here. The remaining capability is invoking any public method of any Serializable object. **Serializable** means the object can be turned into bytes and back, which is exactly what deserialisation needs.

The researchers found `RemoteInvocation`, which is `Serializable` and has an `invoke()` method:


{{media:23}}


*The `RemoteInvocation` class.*


{{media:24}}


*Its `invoke()` method.*

`RemoteInvocation.invoke()` uses the Reflect API to get and invoke a method from fully controlled parameters: `methodName`, `parameterType` and `arguments`. The **Reflect API** is Java's built-in ability to look up and call methods by name at runtime. This completes the filtered `ReflectionExtractor.extract()`.

Because `ReflectionExtractor.extract()` does not allow invoking an instance of type `java.lang.Class`, the chain is built with `ChainedExtractor` to reuse the result of one method execution as the argument of the next. The chain contains two `ReflectionExtractor` instances:


{{media:25}}


*A diagram of the execution chain.*

1. The first `ReflectionExtractor` calls `RemoteInvocation.invoke()` with another `RemoteInvocation` instance as the argument.
2. In the second `RemoteInvocation.invoke()`, the method `newInstance()` is taken from `java.lang.Class` (available by default) and invoked with the class `ShellSession` as the argument, equivalent to `new ShellSession()`. `newInstance()` creates a new object of a given class.
3. The return object is a `ShellSession` instance, which is not filtered by the blacklist.
4. The second stage calls `ShellSession.exec()` to execute a command using MVEL syntax. **MVEL** is an expression language that can be evaluated at runtime.

## Root cause

`RemoteApplicationResourceLoader` restores a resource from user input and passes it to `URLEncoderPathBean.getInstanceFromString()` and `SerializationUtils.fromURLEncodingString()`, deserializing untrusted data. The `RenderKitResourceLoader` constructor maps paths to loaders, and the `/afr/foo/remote/bar/` URL shape lets an attacker reach the deserialisation sink with a GET request.

The existing defences did not stop it. The `FilteringClassLoader` blacklist is bypassed by calling `readObject()` from an override, so the class loader at the call site is `Launcher$AppClassLoader`. The WebLogic serialisation blacklist applies to the WebLogic runtime rather than the OAM/ADF context. The coherence extractor blacklist is bypassed with `RemoteInvocation` and `ChainedExtractor`.

## Impact

Any website built with ADF Faces is affected, including many Oracle online systems and Oracle Cloud Infrastructure. The researchers achieved pre-auth RCE on Oracle BI and on OAM, and reported pre-auth RCEs to some large companies through their bug bounty programmes after the patch was released. A **bug bounty programme** is a scheme where a company pays researchers for reporting security bugs. For OAM, the SSRF on port 14100 reaches the ADF consoles on 7001 and leads to pre-auth RCE.

In the demonstration sent to Oracle, the researchers chose `edelivery.oracle.com` and `businessnetwork.oracle.com`, both based on ADF Faces. `edelivery.oracle.com` is where users download Oracle products; `businessnetwork.oracle.com` is Oracle's business network site. They used a check script for the Miracle Exploit and only proved that they could get some information from Oracle's systems rather than execute commands, because executing commands might affect Oracle's systems and leak sensitive information.


{{media:28}}


*The check against `edelivery.oracle.com`.*


{{media:29}}


*The check against `businessnetwork.oracle.com`.*

They also achieved pre-auth RCE on `login.oracle.com`, which plays an important role in Oracle's online services.


{{media:30}}


*The check against `login.oracle.com`.*

The researchers state they targeted Oracle's sites to demonstrate the impact and prompt action, and that Oracle took 6 months to patch the vulnerability.

## The fix

The patch was applied in `oracle.adfinternal.view.rich.remote.resources.URLEncoderPathBean.getInstanceFromString()`.


{{media:26}}


*The original code.*


{{media:27}}


*The patched code.*

Oracle fixed the ADF Faces vulnerability in the April Critical Patch (19/04/2022), and the first pre-auth RCE in OAM found by Jang was fixed in the January Critical Patch (18/01/2022). A **Critical Patch Update** is Oracle's regular scheduled release of security fixes. The researchers describe the ADF Faces patch as small changes.

## Variants to test

If you want to look for the same class of bug elsewhere, here are the directions the researchers point to. Each one is a way to check whether a system is vulnerable.

- **Other ADF-based products.** Install Oracle Enterprise Manager, Oracle Identity Management, Oracle SOA Suite, Oracle WebCenter Portal, Oracle Application Testing Suite or Oracle Transportation Management and request `http://HOST:PORT/contextApp/afr/foo/remote/bar/` with a serialised payload in `bar`. A positive result is deserialisation of the payload, for example a `ClassNotFoundException` for a probe class or code execution with a working chain.
- **Other resource loaders.** Review overrides of `ResourceLoader.findResource()` for other loaders that restore resources from user input. A positive result is a path that reaches `SerializationUtils.fromURLEncodingString()` with attacker-controlled data.
- **SAML KeyInfo handling.** Send a SOAP-based SAML request to `http://HOST:PORT/oamfed/idp/soap/` with an `EncryptedAssertion` whose `KeyInfo` uses a `RetrievalMethod` with an XPath `document()` transformation. A positive result is an outbound GET request to the target host, visible in logs or a callback.
- **Classloader bypass.** On 10.3.x, wrap a serialised gadget chain in a `ConcurrentHashMap` so `readObject()` is called from an override. A positive result is that classes blocked by `FilteringClassLoader` (such as `com.tangosol` or `org.python`) load successfully.
- **Extractor blacklist bypass.** Build a `ChainedExtractor` with two `ReflectionExtractor` instances and a `RemoteInvocation` to call `newInstance()` on `java.lang.Class` with a `ShellSession` argument, then call `ShellSession.exec()`. A positive result is command execution with the extractor target outside the reflection blacklist.

## Glossary

- **ADF Faces**: Oracle's framework for building web user interfaces; many Oracle products and online services are built on it.
- **Blacklist**: a list of things that are forbidden; here, classes that the software refuses to load or invoke.
- **Bug bounty programme**: a scheme where a company pays researchers for reporting security bugs.
- **ChainedExtractor**: a coherence class that runs several extractors in sequence, feeding each result into the next.
- **Class loader**: the part of Java that finds and loads classes when a program needs them.
- **Classpath**: the list of places Java looks for classes.
- **ConcurrentHashMap**: a standard Java map (key to value) that is safe to use from multiple threads; here used to wrap a serialised chain.
- **Constructor**: the code that runs when an object is first created.
- **Critical Patch Update**: Oracle's regular scheduled release of security fixes.
- **CVE**: a public identifier for a known vulnerability, like a catalogue number.
- **Deserialisation**: turning a stream of bytes back into a live object in memory.
- **EncryptedAssertion**: a SAML element that wraps an encrypted statement about a user's identity.
- **Extractor**: a small object whose job is to pull a value out of another object.
- **FilteringClassLoader**: Oracle's class loader that applies a blacklist to dangerous classes during deserialisation.
- **Gadget chain**: a sequence of otherwise harmless pieces of existing code stitched together through deserialisation to achieve code execution.
- **Identity provider (IDP)**: in SAML, the system that authenticates the user.
- **Jar file**: a packaged library of Java classes.
- **KeyInfo**: the SAML element that tells the receiver where to find the key needed to decrypt an assertion.
- **Mapping**: the rule that says which servlet handles which URL pattern.
- **MVEL**: an expression language that can be evaluated at runtime.
- **Oracle Access Manager (OAM)**: Oracle's single sign-on product.
- **Oracle Business Intelligence (Oracle BI)**: Oracle's reporting and analytics product.
- **Oracle Fusion Middleware**: a collection of Oracle server software used to run business applications.
- **OSDT (Oracle Security Developer Tools)**: Oracle's own security library, which blocks some known attacks.
- **Override**: a subclass replacing the behaviour of a method defined in its parent class.
- **Port**: a numbered door on a server that a particular service listens on.
- **Pre-auth**: working before the attacker has logged in.
- **Reflect API**: Java's built-in ability to look up and call methods by name at runtime.
- **Remote code execution (RCE)**: making a server run commands of the attacker's choosing from a distance.
- **SAML**: a standard for exchanging login information between systems.
- **Serializable**: an object that can be turned into bytes and back.
- **Serialisation**: converting an object into a stream of bytes for storage or transport.
- **Service provider (SP)**: in SAML, the application the user wants to access.
- **Servlet**: a small Java program that runs on a web server and handles a particular kind of request.
- **Sink**: the place in code where dangerous data finally gets used.
- **SOAP**: a protocol for exchanging structured messages between systems, usually over HTTP.
- **Source**: the place in code where the attacker's data enters.
- **SSRF (server-side request forgery)**: tricking the server into making a request of the attacker's choosing.
- **Transformation**: in XML security, a processing step applied to data, such as XSLT or XPath.
- **WebLogic**: Oracle's Java application server, the software that runs Java web applications.
- **XXE (XML external entity)**: a bug in XML parsing where the parser follows external references supplied by an attacker.
- **Zero Day Initiative (ZDI)**: an organisation that buys and coordinates the disclosure of security bugs.

More by Nguyễn Tiến Giang

View all

1 more disclosed report, best first.

More from Oracle

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.