What is MDM?
A Hessian deserialization vulnerability in MobileIron MDM allowed unauthenticated remote code execution, and the author bypassed Apache rewrite rules to reach the vulnerable endpoint. The exploit was used to compromise Facebook's exposed MobileIron server.
Published on blog.orange.tw
📌 [繁體中文 | English ]
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
Mobile Device Management (MDM) is an asset assessment system that makes employees' BYOD more manageable for enterprises. It was proposed in 2012 in response to the increasing number of tablets and mobile devices. MDM can guarantee that devices run under the corporate policy and in a trusted environment; enterprises can manage assets, install certificates, deploy applications and even lock or wipe devices remotely to prevent data leakage. UEM (Unified Endpoint Management) is a newer term with a broader definition for managed devices; the article uses MDM to represent similar products.
MDM is a centralised system that manages and controls all employees' devices, and it must be reachable publicly to synchronise devices all over the world. That combination, a centralised and publicly exposed appliance, is what drew the researcher to it. Hackers and APT groups have abused MDM: phishing victims to make MDM a C&C server for their mobile devices, or compromising the corporate exposed MDM server to push malicious Trojans to all devices. The article points to Cisco Talos's "Malicious MDM: Let's Hide This App" and CheckPoint CPR's "First seen in the wild - Malware uses Corporate MDM as attack vector" for details.
After listing known MDM solutions and scanning corresponding patterns across the Internet, the researcher found the most prevalent MDMs to be VMware AirWatch and MobileIron. MobileIron was chosen because, according to its official website, more than 20,000 enterprises use it, most of the researcher's customers use it as well, Facebook has exposed a MobileIron server since 2016, and an analysis of the Fortune Global 500 found more than 15% using and exposing their MobileIron server to the public.
{{media:0}}
The research was presented at HITCON 2020.
## Setup
From past vulnerabilities the researcher learned that not many researchers dive into MobileIron, and suspected the main reason is that the firmware is too hard to obtain. Turning pure black-box testing into grey-box or white-box testing is vital when researching an appliance, so a lot of time went into searching for information on the Internet. The search ended with an RPM package, supposedly the developer's testing package, sitting on a listable WebRoot and indexed by Google Search.
{{media:1}}
The released date of the file is early 2018, a little old but better than nothing. MobileIron was informed and the sensitive files have since been removed.
After a painful time solving the dependency hell, the testing package was set up. The component is based on Java and exposes three ports:
- 443 - the user enrollment interface
- 8443 - the appliance management interface
- 9997 - the MobileIron device synchronization protocol (MI Protocol)
All opened ports are TLS-encrypted. Apache sits in front of the web part and proxies all connections to a backend Tomcat with Spring MVC inside.
{{media:2}}
## Finding it
Because of Spring MVC, finding traditional vulnerabilities such as SQL Injection or XSS from a single view is hard, so the goal became examining the logic and architecture.
The root cause turned out to be straightforward: Tomcat exposed a Web Service that deserialises user input in Hessian format. Knowing that is not the same as being able to trigger it. The endpoint is located on both:
- User enrollment interface - `https://mobileiron/mifs/services/`
- Management interface - `https://mobileiron:8443/mics/services/`
The deserialisation could only be reached through the management interface, because the user interface blocks access to the Web Service. That is a critical hit: most enterprises will not expose their management interface to the Internet, and a management-only vulnerability is not useful.
Scrutinising the architecture showed that Apache blocks access through Rewrite Rules. MobileIron relied on Apache Rewrite Rules to block all access to the Web Service, with Apache in front of a reverse-proxy architecture and a Java-based web server at the back. This is the reverse proxy attack surface the researcher proposed in 2015 and presented as Breaking Parser Logic at Black Hat USA 2018: the technique leverages the inconsistency between Apache and Tomcat to bypass the ACL control and reach the Web Service again. The same technique was applied to the F5 BIG-IP TMUI RCE vulnerability.
```text
https://mobileiron/mifs/.;/services/someService
```
The technique leverages the inconsistency between Apache and Tomcat to bypass the ACL control and reach the Web Service again.
## Exploitation
### Step 1: reach the Hessian deserialisation
With the path trick, the deserialisation is reachable whether it sits on the enrollment interface or the management interface.
Moritz Bechler's whitepaper Java Unmarshaller Security summarises the Hessian deserialisation vulnerability. From the marshalsec source code, Hessian deserialisation triggers `equals()` and `hashcode()` while reconstructing a `HashMap`, and can also trigger `toString()` through `XString`. The known exploit gadgets at the time were:
- Apache XBean
- Caucho Resin
- Spring AOP
- ROME EqualsBean/ToStringBean
In this environment only the Spring AOP gadget chain could be triggered, and it yields a JNDI Injection.
| Name | Effect |
|---|---|
| Apache XBean | JNDI Injection |
| Caucho Resin | JNDI Injection |
| **Spring AOP** | **JNDI Injection** |
| ROME EqualsBean | RCE |
### Step 2: JNDI Injection and the Java mitigation
With a JNDI Injection, the rest looked easy: leverage Alvaro Muñoz and Oleksandr Mirosh's Black Hat USA 2016 work, A Journey From JNDI/LDAP to Remote Code Execution Dream Land, to get code execution.
{{media:3}}
That technique helped countless researchers and brought Java deserialisation into a new era, but Java mitigated the last JNDI/LDAP puzzle in October 2018. After that, all Java versions higher than 8u181, 7u191 and 6u201 can no longer get code execution through JNDI remote URL-Class loading, so exploiting the Hessian deserialisation on the latest MobileIron has to face this problem.
Java changed the default value of `com.sun.jndi.ldap.object.trustURLCodebase` to `False` to prevent attackers from downloading a remote URL-Class for code execution. Only that has been prohibited: JNDI can still be manipulated to redirect the Naming Reference to a local Java Class. The concept resembles Return-Oriented Programming, using a local existing Java Class for further exploitation. Michael Stepankin's early 2019 article Exploiting JNDI Injections in Java describes POST-JNDI exploitation and how to abuse Tomcat's `BeanFactory` to populate the `ELProcessor` gadget for code execution. Based on the same concept, Welkin provides another `ParseClass` gadget on Groovy, described in his Chinese article:
> 除了 javax.el.ELProcessor,当然也还有很多�
�他的类符合条件可以作为 beanClass 注�
�到 BeanFactory 中实现利用。举个例子,如果目标机器 classpath 中有 groovy 的库,则可以结合之前 Orange 师�
发过的 [Jenkins 的漏洞实现利用](https://blog.orange.tw/2019/02/abusing-meta-programming-for-unauthenticated-rce.html)
That suggests the Meta Programming exploitation from the earlier Jenkins research could be used here too.
Both gadgets are unavailable on this target because its libraries are outdated. Tomcat introduced `ELProcessor` in 8.5, but the target is Tomcat 7. The target Groovy version, 1.5.6 from 2008, is too old to support Meta Programming. A new gadget had to be found, and one was found on `GroovyShell`; the researcher sent it as a Pull Request to Welkin's JNDI-Injection-Bypass project.
### Step 3: attacking Facebook, and the outbound connection problem
Chaining JNDI Injection, Tomcat `BeanFactory` and `GroovyShell` gives a working RCE. Facebook has used MobileIron since 2016; although the server's index responds 403 Forbidden, the Web Service is still accessible.
{{media:4}}
Several days before the scheduled attack, a critical problem surfaced. From the previous time a shell was popped on Facebook, the researcher knew Facebook blocks outbound connections for security reasons. The outbound connection is vital for JNDI Injection, because the idea is to make the victim connect to a malicious server for further exploitation. With no outbound connection possible, that route is closed.
{{media:5}}
### Step 4: back to Hessian, and a new gadget
With all attack surfaces on JNDI Injection closed, the only option was to return to Hessian deserialisation. Because of the lack of available gadgets, a new one had to be discovered.
{{media:6}}
Re-reading Moritz Bechler's paper, one sentence stood out:
> Cannot restore Groovy's MethodClosure as readResolve() is called which throws an exception.
Why would the author leave that note? It failed with exceptions, but there must have been something special for the author to write it down. The target runs a very old Groovy, so the guess was that the `readResolve()` constraint might not have been applied to that code base yet. Comparing `groovy/runtime/MethodClosure.java` between the latest version and 1.5.6 confirmed it: there is no `ALLOW_RESOLVE` in Groovy 1.5.6. CVE-2015-3253 is just for that, a mitigation for the rising Java deserialisation vulnerability in 2015. Since Groovy is an internally used library, developers will not update it without an emergency, and the outdated Groovy is a good case study of how a harmless component can leave you compromised.
The shell on Facebook was obtained in the end.
{{media:7}}
## Root cause
The chain has several layers. Tomcat exposes a Web Service that deserialises user input in Hessian format, and Hessian reconstruction of a `HashMap` triggers `equals()` and `hashcode()`, which is what makes gadget chains reachable at all. Access control for that Web Service is implemented only in Apache Rewrite Rules in front of the reverse proxy; the inconsistency between Apache and Tomcat path normalisation lets a request such as `https://mobileiron/mifs/.;/services/someService` pass the rules and still reach the backend service. The only gadget available in this environment, Spring AOP, gives JNDI Injection rather than direct code execution, and the JNDI remote class loading route is closed by the `com.sun.jndi.ldap.object.trustURLCodebase` default change in Java versions above 8u181, 7u191 and 6u201. The POST-JNDI gadgets that would work around that (`ELProcessor` via Tomcat `BeanFactory`, `ParseClass` on Groovy) are unavailable because the target runs Tomcat 7 and Groovy 1.5.6. The final gadget relies on Groovy 1.5.6 lacking the `ALLOW_RESOLVE` check in `groovy/runtime/MethodClosure.java`, the fix associated with CVE-2015-3253. With all attack surfaces on JNDI Injection closed, the only option was to return to Hessian deserialisation, and a new gadget had to be found.
## Impact
The result is a completely unauthenticated RCE on MobileIron. On Facebook, the researcher obtained a shell; the report states that a shell was dropped on Facebook and reported to their Bug Bounty program, and that the shell was obtained in the end. The article also lists, as topics not covered in detail, taking over employees' devices from MDM, disassembling the MI Protocol, and the CVE-2020-15506 authentication bypass.
## Fix
All the vulnerabilities were reported to the vendor and fixed in June. The advisory was sent to MobileIron on 4/3, the patch was released on 6/15, and it addressed three CVEs:
- CVE-2020-15505 - Remote Code Execution
- CVE-2020-15506 - Authentication Bypass
- CVE-2020-15507 - Arbitrary File Reading
After the patch, the researcher monitored the Internet to track overall fixing progress by checking the `Last-Modified` header on static files; the result is for information only, and Unknown stands for a server that closed both 443 and 8443 ports.
{{media:8}}
Facebook was monitored as well. With 15 days of no-patch confirmed, a shell was popped and reported to their Bug Bounty program on 7/2.
## Variants to test
- **Path normalisation bypass against a reverse proxy ACL.** Send a request to a blocked backend path with a `.;` segment, as in `https://mobileiron/mifs/.;/services/someService`. A positive result is the backend service responding instead of the proxy's block page.
- **Hessian deserialisation on other Tomcat services.** Look for Web Services that deserialise Hessian input and test the known gadget chains (Apache XBean, Caucho Resin, Spring AOP, ROME EqualsBean/ToStringBean). A positive result is a triggered `equals()`/`hashcode()` or `toString()` side effect, such as a JNDI lookup or code execution.
- **POST-JNDI gadgets on newer stacks.** Where JNDI Injection is reachable, try Tomcat `BeanFactory` with `ELProcessor` (Tomcat 8.5 and later) or Groovy `ParseClass`. A positive result is code execution without remote class loading.
- **Old Groovy `MethodClosure`.** On targets bundling Groovy older than the CVE-2015-3253 fix, test whether `MethodClosure` can be restored during deserialisation. A positive result is the closure being reconstructed rather than rejected by `readResolve()`.
- **Outbound-connection-restricted hosts.** Where JNDI callbacks are blocked, prefer gadget chains that execute locally, as the `GroovyShell` gadget does, rather than chains that require the victim to connect back.## What happened, in plain words
A security researcher spent part of March looking at a type of product called Mobile Device Management, or MDM. An MDM is the system a company uses to keep track of and control its employees' phones, tablets and laptops. It can install apps, push settings, lock a lost phone or wipe it remotely. Because it has to reach devices all over the world, it usually sits on the public internet, which makes it an attractive target.
The researcher found a way to run commands on one brand of MDM, MobileIron, without logging in at all. That kind of break-in is called remote code execution, or RCE. The vendor fixed it in June. Afterwards the researcher kept watching which big companies had applied the fix, and noticed that Facebook had not, for more than two weeks. So the researcher used the same technique against Facebook's MobileIron server, got a shell (a command prompt on the remote machine), and reported it through Facebook's bug bounty programme, which pays people for reporting security problems.
The article walks through the whole journey: how the software was obtained, how the flaw was found, how several obstacles were worked around, and how Facebook was eventually reached. This version explains every step from scratch, assuming you can use a browser and a computer and nothing more.
{{media:0}}
The research was also presented at HITCON 2020, a security conference.
## What an MDM is, and why it matters
Mobile Device Management, MDM for short, is an asset assessment system: software that lets a company keep an inventory of its devices and make sure they follow corporate policy. The idea took off around 2012, when tablets and phones started appearing in offices in large numbers. The article uses the term BYOD, bring your own device, for the practice of employees using their personal phones for work. An MDM makes that manageable: the company can manage assets, install certificates, deploy applications and even lock or wipe devices remotely to prevent data leakage.
A newer term, UEM or Unified Endpoint Management, covers the same idea with a broader definition of what counts as a managed device. Throughout the article, MDM stands for all of these products.
Think of an MDM as the master key cabinet for a company's phones: whoever holds it can open every device. That is exactly why it is interesting to attackers. The article notes that hackers and APT groups (organised, often state-backed attackers) have abused MDM in the past: phishing victims so that the MDM becomes a command-and-control server for their phones, or breaking into a company's exposed MDM server to push malicious Trojans to every device. Two reports are cited for detail: "Malicious MDM: Let's Hide This App" by Cisco Talos, and "First seen in the wild - Malware uses Corporate MDM as attack vector" by CheckPoint CPR.
## Choosing a target
The researcher listed the known MDM products and scanned the internet for patterns that identify each one. The most common turned out to be VMware AirWatch and MobileIron. MobileIron was chosen for several reasons:
1. Its official website says more than 20,000 enterprises use it.
2. Most of the researcher's own customers use it.
3. Facebook has had a MobileIron server exposed since 2016.
4. An analysis of the Fortune Global 500 found more than 15% of those companies using MobileIron and exposing it to the public.
A publicly reachable, centralised appliance that controls every employee's phone is about as appealing a target as an attacker can find.
## Getting hold of the software
To study a device properly you want to move from black-box testing to grey-box or white-box testing. Black-box means you can only poke at it from outside, like knocking on a closed box. Grey-box and white-box mean you can see some or all of what is inside, which makes finding flaws far easier. For an appliance like this, the key is the firmware, the software image the device runs.
Past vulnerability records showed that not many researchers had looked into MobileIron, and the article suspects the reason is that the firmware is hard to obtain. So a lot of time went into searching the internet for anything usable. The search ended with an RPM package. RPM is a common package format for Linux software; this particular file was supposedly the developer's testing package. It was simply sitting on a listable WebRoot, meaning a web server directory whose contents a browser can list, and it had been indexed by Google Search.
{{media:1}}
The file was released in early 2018. A little old, but better than nothing. MobileIron was informed and the sensitive files have since been removed.
## Setting the software up
Getting the package to run took what the article calls a painful time solving the dependency hell. Dependencies are the other pieces of software a program needs in order to work; when many of them have to line up in the right versions, that is the "hell". Once it ran, the picture was clear. The component is based on Java, a widely used programming language, and it exposes three ports:
- 443, the user enrollment interface
- 8443, the appliance management interface
- 9997, the MobileIron device synchronisation protocol, or MI Protocol
A port is a numbered doorway on a server; a browser connecting to a website is normally talking to port 443. An interface here means a web-facing part of the product with its own purpose: one for users enrolling their devices, one for administrators managing the appliance, one for devices synchronising.
All the open ports are TLS-encrypted, meaning the traffic is wrapped in the same kind of encryption a padlock in the browser address bar indicates. Apache, a very common web server, sits in front of the web part and proxies all connections to a backend Tomcat with Spring MVC inside. A proxy is a middleman: the request arrives at Apache, and Apache forwards it to the real application behind. Tomcat is a Java application server, the piece that actually runs the Java web code. Spring MVC is a framework that organises how that Java code handles web requests.
{{media:2}}
## Finding the flaw
Because Spring MVC structures the application in a disciplined way, finding traditional bugs such as SQL Injection or XSS from a single view is hard. SQL Injection is when user input is slipped into a database query and changes its meaning; XSS, cross-site scripting, is when an attacker gets their own script to run in someone else's browser. Neither was the goal here. Instead the researcher examined the logic and the architecture: how the parts fit together and what each part trusts.
The root cause turned out to be straightforward. Tomcat exposed a Web Service that deserialises user input in Hessian format. A Web Service is an endpoint meant for other software to talk to, rather than for a person clicking pages. Deserialisation is the act of turning a stream of bytes back into live objects inside the program; Hessian is one particular format for doing that. The danger is that the program is rebuilding objects chosen by whoever sent the bytes, and some objects do things when they are rebuilt.
Knowing that is not the same as being able to trigger it. The endpoint is located on both:
- User enrollment interface: `https://mobileiron/mifs/services/`
- Management interface: `https://mobileiron:8443/mics/services/`
In these URLs, `mobileiron` stands for the server's address, and `:8443` means "connect to port 8443 instead of the default". The path `/mifs/services/` or `/mics/services/` is the location of the Web Service on that server.
The deserialisation could only be reached through the management interface, because the user interface blocks access to the Web Service. That is a critical hit for the researcher: most enterprises will not expose their management interface to the internet, and a vulnerability that only works on the management interface is not useful in practice. The interesting interface, the one reachable from outside, was the one that said no.
Scrutinising the architecture showed why. Apache blocks access through Rewrite Rules. A Rewrite Rule is a filter in the web server that inspects the incoming request and can refuse or redirect it before it ever reaches the application. MobileIron relied on these rules to block all access to the Web Service, with Apache in front of a reverse-proxy architecture and a Java-based web server at the back. A reverse proxy is the same middleman idea seen from the server's side: the outside world only ever talks to Apache.
This is the reverse proxy attack surface the researcher proposed in 2015 and presented as Breaking Parser Logic at Black Hat USA 2018. The idea is that Apache and Tomcat can disagree about what a path means once it has been cleaned up, and that disagreement lets a request slip past the filter and still arrive at the service behind it. The same technique was later applied to the F5 BIG-IP TMUI RCE vulnerability.
```text
https://mobileiron/mifs/.;/services/someService
```
Line by line, in plain words:
- `https://mobileiron` is the server, reached over encrypted HTTP.
- `/mifs/` is the part of the path the enrollment interface normally serves.
- `/.;/` is the trick. It is a path segment made of a dot and a semicolon. Apache and Tomcat normalise, that is clean up, paths differently, so one of them treats this segment as something to collapse or ignore while the other keeps it. The result is that the request passes the Rewrite Rules and still lands on the Web Service.
- `/services/someService` is the Web Service endpoint itself; `someService` is a placeholder for whichever service you want to reach.
## Exploiting it
### Step 1: reach the Hessian deserialisation
With the path trick, the deserialisation is reachable whether it sits on the enrollment interface or the management interface. The filter that was supposed to keep people out no longer does.
Moritz Bechler's whitepaper Java Unmarshaller Security summarises the Hessian deserialisation vulnerability. From the marshalsec source code, the researcher learned the mechanics: Hessian deserialisation triggers `equals()` and `hashcode()` while reconstructing a `HashMap`, and can also trigger `toString()` through `XString`. In plain terms, when the program rebuilds certain standard Java objects, it calls small methods on them, and an attacker who controls which objects are rebuilt can make those methods do something useful. A gadget is a class already present in the application that, when rebuilt this way, sets off a chain of calls leading to something harmful. The known gadgets at the time were:
- Apache XBean
- Caucho Resin
- Spring AOP
- ROME EqualsBean/ToStringBean
In this environment only the Spring AOP gadget chain could be triggered, and it yields a JNDI Injection.
| Name | Effect |
|---|---|
| Apache XBean | JNDI Injection |
| Caucho Resin | JNDI Injection |
| **Spring AOP** | **JNDI Injection** |
| ROME EqualsBean | RCE |
The table lists each gadget and what it gives you. The ticked row is the one that worked here. JNDI Injection needs explaining: JNDI is Java's built-in directory lookup service, a way for a program to ask "where do I find this named thing?" and be told a location. If an attacker can influence the answer, the program can be pointed at a server the attacker controls. RCE, remote code execution, is the stronger outcome: running your own commands on the target.
### Step 2: JNDI Injection and the Java mitigation
With a JNDI Injection, the rest looked easy. The plan was to leverage Alvaro Muñoz and Oleksandr Mirosh's Black Hat USA 2016 work, A Journey From JNDI/LDAP to Remote Code Execution Dream Land, to get code execution. LDAP is a directory protocol, the kind of thing JNDI talks to; the talk showed how a lookup could be turned into running code.
{{media:3}}
That technique helped countless researchers and brought Java deserialisation into a new era, but Java mitigated the last JNDI/LDAP puzzle in October 2018. After that, all Java versions higher than 8u181, 7u191 and 6u201 can no longer get code execution through JNDI remote URL-Class loading, so exploiting the Hessian deserialisation on the latest MobileIron has to face this problem. In plain words: the old trick relied on the victim downloading a class, a piece of Java code, from the attacker's server and running it. Java now refuses to do that by default.
Specifically, Java changed the default value of `com.sun.jndi.ldap.object.trustURLCodebase` to `False` to prevent attackers from downloading a remote URL-Class for code execution. That setting is a switch inside Java; setting it to `False` means "do not trust code that arrives from a URL". Only that has been prohibited. JNDI can still be manipulated to redirect the Naming Reference to a local Java Class. A Naming Reference is the answer JNDI gives when you look something up: instead of a value, it can say "this name refers to this class". Pointing it at a class that already exists on the victim's machine avoids the download entirely.
The concept resembles Return-Oriented Programming, using a local existing Java Class for further exploitation. Return-Oriented Programming is a classic technique where an attacker does not inject new code but instead strings together small pieces already present in memory. Here the same spirit applies at the Java level: use what is already installed.
Michael Stepankin's early 2019 article Exploiting JNDI Injections in Java describes this POST-JNDI exploitation and how to abuse Tomcat's `BeanFactory` to populate the `ELProcessor` gadget for code execution. `BeanFactory` is a Tomcat component that builds objects from a description; `ELProcessor` is a Java class that evaluates expressions, and if an attacker can feed it an expression, it will evaluate the attacker's expression. Based on the same concept, Welkin provides another `ParseClass` gadget on Groovy, described in his Chinese article:
> 除了 javax.el.ELProcessor,当然也还有很多�
�他的类符合条件可以作为 beanClass 注�
�到 BeanFactory 中实现利用。举个例子,如果目标机器 classpath 中有 groovy 的库,则可以结合之前 Orange 师�
发过的 [Jenkins 的漏洞实现利用](https://blog.orange.tw/2019/02/abusing-meta-programming-for-unauthenticated-rce.html)
Roughly, the quoted passage says that besides `javax.el.ELProcessor` there are many other classes that qualify as a `beanClass` to inject into `BeanFactory`, and that if the target's classpath contains the Groovy library, the Jenkins exploitation published earlier by Orange could be combined with it. Groovy is a programming language that runs on Java; a classpath is the list of places Java looks for classes. That suggests the Meta Programming exploitation from the earlier Jenkins research could be used here too. Meta Programming, in this context, means code that manipulates code at runtime, which is exactly the kind of power an attacker wants.
Both gadgets are unavailable on this target because its libraries are outdated. Tomcat introduced `ELProcessor` in 8.5, but the target is Tomcat 7. The target Groovy version, 1.5.6 from 2008, is too old to support Meta Programming. A new gadget had to be found, and one was found on `GroovyShell`; the researcher sent it as a Pull Request to Welkin's JNDI-Injection-Bypass project. A Pull Request is a proposed change to someone else's code repository, the standard way to contribute a fix or an addition.
### Step 3: attacking Facebook, and the outbound connection problem
Chaining JNDI Injection, Tomcat `BeanFactory` and `GroovyShell` gives a working RCE. Facebook has used MobileIron since 2016; although the server's index responds 403 Forbidden, the Web Service is still accessible. A 403 Forbidden is the web server's way of saying "you are not allowed to see this". The front page was locked, but the service behind it was not.
{{media:4}}
Several days before the scheduled attack, a critical problem surfaced. From the previous time a shell was popped on Facebook, the researcher knew Facebook blocks outbound connections for security reasons. An outbound connection is one the server makes towards the internet, as opposed to one it receives. The outbound connection is vital for JNDI Injection, because the idea is to make the victim connect to a malicious server for further exploitation. With no outbound connection possible, that route is closed. The victim cannot be made to call home, so the attacker's server never gets a chance to hand over anything.
{{media:5}}
### Step 4: back to Hessian, and a new gadget
With all attack surfaces on JNDI Injection closed, the only option was to return to Hessian deserialisation. Because of the lack of available gadgets, a new one had to be discovered.
{{media:6}}
Re-reading Moritz Bechler's paper, one sentence stood out:
> Cannot restore Groovy's MethodClosure as readResolve() is called which throws an exception.
In plain words: when the tool tries to rebuild a Groovy `MethodClosure` object during deserialisation, a method called `readResolve()` runs and throws an exception, so the object cannot be restored. `MethodClosure` is a Groovy object that points at a method to call later; `readResolve()` is a hook Java calls after rebuilding an object, often used to substitute a safe version. Why would the author leave that note? It failed with exceptions, but there must have been something special for the author to write it down.
The target runs a very old Groovy, so the guess was that the `readResolve()` constraint might not have been applied to that code base yet. Comparing `groovy/runtime/MethodClosure.java` between the latest version and 1.5.6 confirmed it: there is no `ALLOW_RESOLVE` in Groovy 1.5.6. There is no `ALLOW_RESOLVE` in Groovy 1.5.6. CVE-2015-3253 is just for that, a mitigation for the rising Java deserialisation vulnerability in 2015. A CVE is a public identifier for a known vulnerability, so people can refer to the same flaw unambiguously.
Since Groovy is an internally used library, developers will not update it without an emergency, and the outdated Groovy is a good case study of how a harmless component can leave you compromised. A library nobody thinks about, bundled years ago, quietly removed the safety catch.
The shell on Facebook was obtained in the end.
{{media:7}}
## Root cause
The chain has several layers, and it helps to see them in order.
1. Tomcat exposes a Web Service that deserialises user input in Hessian format. Hessian reconstruction of a `HashMap` triggers `equals()` and `hashcode()`, which is what makes gadget chains reachable at all.
2. Access control for that Web Service is implemented only in Apache Rewrite Rules in front of the reverse proxy. The inconsistency between Apache and Tomcat path normalisation lets a request such as `https://mobileiron/mifs/.;/services/someService` pass the rules and still reach the backend service.
3. The only gadget available in this environment, Spring AOP, gives JNDI Injection rather than direct code execution.
4. The JNDI remote class loading route is closed by the `com.sun.jndi.ldap.object.trustURLCodebase` default change in Java versions above 8u181, 7u191 and 6u201.
5. The POST-JNDI gadgets that would work around that, `ELProcessor` via Tomcat `BeanFactory` and `ParseClass` on Groovy, are unavailable because the target runs Tomcat 7 and Groovy 1.5.6.
6. The final gadget relies on Groovy 1.5.6 lacking the `ALLOW_RESOLVE` check in `groovy/runtime/MethodClosure.java`, the fix associated with CVE-2015-3253.
7. With all attack surfaces on JNDI Injection closed, the only option was to return to Hessian deserialisation, and a new gadget had to be found.
## Impact
The result is a completely unauthenticated RCE on MobileIron. Unauthenticated means no login, no password, no account: anyone who can reach the service can use it. That is what turns a niche bug into a serious one.
On Facebook, the researcher obtained a shell. The report states that a shell was dropped on Facebook and reported to their Bug Bounty program, and that the shell was obtained in the end. The article also lists, as topics not covered in detail, taking over employees' devices from MDM, disassembling the MI Protocol, and the CVE-2020-15506 authentication bypass.
## Fix
All the vulnerabilities were reported to the vendor and fixed in June. The advisory was sent to MobileIron on 4/3, the patch was released on 6/15, and it addressed three CVEs:
- CVE-2020-15505, Remote Code Execution
- CVE-2020-15506, Authentication Bypass
- CVE-2020-15507, Arbitrary File Reading
An authentication bypass means getting past a login check without valid credentials. Arbitrary file reading means reading files on the server that should not be readable.
After the patch, the researcher monitored the internet to track overall fixing progress by checking the `Last-Modified` header on static files. A header is a small piece of metadata sent along with a web response; `Last-Modified` says when the file was last changed, which is a rough clue to whether the server has been updated. The result is for information only, and Unknown stands for a server that closed both 443 and 8443 ports.
{{media:8}}
Facebook was monitored as well. With 15 days of no-patch confirmed, a shell was popped and reported to their Bug Bounty program on 7/2.
## Variants to test
These are the same ideas generalised, so that someone testing a similar product knows what to try.
- **Path normalisation bypass against a reverse proxy ACL.** Send a request to a blocked backend path with a `.;` segment, as in `https://mobileiron/mifs/.;/services/someService`. A positive result is the backend service responding instead of the proxy's block page.
- **Hessian deserialisation on other Tomcat services.** Look for Web Services that deserialise Hessian input and test the known gadget chains (Apache XBean, Caucho Resin, Spring AOP, ROME EqualsBean/ToStringBean). A positive result is a triggered `equals()`/`hashcode()` or `toString()` side effect, such as a JNDI lookup or code execution.
- **POST-JNDI gadgets on newer stacks.** Where JNDI Injection is reachable, try Tomcat `BeanFactory` with `ELProcessor` (Tomcat 8.5 and later) or Groovy `ParseClass`. A positive result is code execution without remote class loading.
- **Old Groovy `MethodClosure`.** On targets bundling Groovy older than the CVE-2015-3253 fix, test whether `MethodClosure` can be restored during deserialisation. A positive result is the closure being reconstructed rather than rejected by `readResolve()`.
- **Outbound-connection-restricted hosts.** Where JNDI callbacks are blocked, prefer gadget chains that execute locally, as the `GroovyShell` gadget does, rather than chains that require the victim to connect back.
## Glossary
- **ACL**: access control list, the rules that decide who may reach which part of a system.
- **Apache**: a very common web server that receives requests and can forward them to an application behind it.
- **API**: an interface meant for software to talk to software, rather than for a person clicking pages.
- **APT group**: an advanced persistent threat group, an organised attacker, often state-backed, that works quietly over a long period.
- **BeanFactory**: a Tomcat component that builds objects from a description supplied to it.
- **Black-box testing**: testing a system only from the outside, without seeing its code or internals.
- **Bug bounty programme**: a scheme where a company pays researchers for reporting security problems responsibly.
- **BYOD**: bring your own device, employees using personal phones or tablets for work.
- **Class**: in Java, the blueprint for an object; a piece of code that can be loaded and run.
- **Classpath**: the list of places Java looks for classes when it needs one.
- **Command-and-control server (C&C)**: a server an attacker uses to send instructions to compromised devices.
- **CVE**: a public identifier for a known vulnerability, so people can refer to the same flaw unambiguously.
- **Dependency**: another piece of software a program needs in order to work.
- **Deserialisation**: turning a stream of bytes back into live objects inside a program; dangerous when the bytes come from an attacker.
- **ELProcessor**: a Java class that evaluates expressions; if fed an attacker's expression, it evaluates that.
- **equals() / hashcode()**: standard Java methods called on objects, including while a `HashMap` is being rebuilt.
- **Firmware**: the software image a device or appliance runs.
- **Gadget**: a class already present in an application that, when rebuilt during deserialisation, sets off a chain of calls leading to something harmful.
- **Grey-box testing**: testing with partial knowledge of the system's internals.
- **Groovy**: a programming language that runs on Java.
- **GroovyShell**: a Groovy class that can run Groovy code, used here as the final gadget.
- **HashMap**: a standard Java data structure that maps keys to values; rebuilding one triggers `equals()` and `hashcode()`.
- **Header**: a small piece of metadata sent with a web request or response, such as `Last-Modified`.
- **Hessian**: a binary format for serialising objects, used by the vulnerable Web Service.
- **Interface**: a web-facing part of a product with its own purpose, such as enrollment or management.
- **Java**: a widely used programming language and runtime.
- **JNDI**: Java's built-in directory lookup service, which lets a program ask where a named thing is found.
- **JNDI Injection**: influencing the answer to a JNDI lookup so the program is pointed somewhere the attacker controls.
- **LDAP**: a directory protocol that JNDI can talk to.
- **Library**: a reusable piece of software that an application bundles and calls.
- **MDM**: Mobile Device Management, software that lets a company manage and control its employees' devices.
- **Meta Programming**: code that manipulates code at runtime.
- **MethodClosure**: a Groovy object that points at a method to call later.
- **MI Protocol**: MobileIron's device synchronisation protocol, on port 9997.
- **Naming Reference**: the answer JNDI gives for a lookup, which can say a name refers to a particular class.
- **Outbound connection**: a connection the server makes towards the internet, as opposed to one it receives.
- **Port**: a numbered doorway on a server; 443 is the usual one for encrypted web traffic.
- **POST-JNDI exploitation**: turning a JNDI Injection into code execution using classes already on the victim, after remote class loading was blocked.
- **Proxy / reverse proxy**: a middleman that forwards requests; a reverse proxy sits in front of the application and hides it from the outside.
- **Pull Request**: a proposed change to someone else's code repository.
- **RCE**: remote code execution, running your own commands on someone else's machine.
- **readResolve()**: a Java hook called after an object is rebuilt during deserialisation, often used to substitute a safe version.
- **Return-Oriented Programming**: a technique that strings together small pieces already present in memory instead of injecting new code.
- **Rewrite Rule**: a filter in a web server that inspects incoming requests and can refuse or redirect them.
- **RPM**: a common package format for Linux software.
- **Shell**: a command prompt on a machine, here on a remote one.
- **Spring AOP**: a Spring framework component; here, the gadget that produced JNDI Injection.
- **Spring MVC**: a framework that organises how Java code handles web requests.
- **SQL Injection**: slipping user input into a database query so that it changes the query's meaning.
- **TLS**: the encryption that wraps web traffic, shown as a padlock in the browser.
- **Tomcat**: a Java application server that runs Java web code.
- **toString()**: a standard Java method that turns an object into text, called in some deserialisation paths.
- **Trojan**: malicious software disguised as something legitimate.
- **UEM**: Unified Endpoint Management, a broader term for MDM-style products.
- **Unauthenticated**: usable without any login or credentials.
- **WebRoot**: a directory on a web server whose contents are served over HTTP, sometimes listable in a browser.
- **Web Service**: an endpoint meant for software to talk to software.
- **White-box testing**: testing with full knowledge of the system's code and internals.
- **XSS**: cross-site scripting, getting an attacker's script to run in someone else's browser.