Another Zoho ManageEngine Story
An unauthenticated servlet in ADManager Plus skipped its credential check when the username parameter was omitted, and a second parameter let the attacker reach the authenticated branch. From there the attacker could insert or update rows in the product-details database table and drive event executors that changed settings such as mail, proxy and SSO configuration.
Published on medium.com
This is another white-box analysis story about a product from Zoho Corp (see my older blog post on OpManager SQLi). Since several critical findings in ManageEngine products (CVE-2020–10189, CVE-2019–8394) were currently discovered, I thought do give them another chance to practice some code auditing.
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
ADManager Plus is a Zoho ManageEngine product described in the report as "An Active Directory (AD) management and reporting solution that allows IT administrators and technicians to manage AD objects easily and generate instant reports at the click of a button!". It is deployed in internal networks at large companies and is also found publicly exposed, for example via Shodan.
The report is a white-box code audit of the Java web application, which runs in a Tomcat web container. The researcher was primarily interested in bugs exploitable from an unauthenticated perspective, and focused on servlets mapped under the /servlet/ prefix, which appeared less protected than the RestAPI counterparts.
Setup
The researcher downloaded the trial version of ADManager Plus and set up a Windows Domain Controller, crediting the DetectionLab project. A ServiceDesk Plus VM was also set up and connected to ADManager Plus through the Integration function, so that the behaviour of the ADSProductDetails table could be observed. The PostgreSQL instance installed as a bundle together with ADManager Plus was inspected directly.
Finding it
The starting point was the web.xml file (there are several). It declares Filters, Listeners and Java Servlets, and a few observations stood out:
- Several filters had something to do with "Security", for example
SecurityFilter. - The
SecurityFilterwas not applied to all URL patterns. - A lot of URL patterns end in
.do, a good indicator for Struts. - There were several references to configuration files such as
struts-config.xmlandapi-struts-config.xml, confirming Struts.
Reading the <servlet-mapping/> sections, which define the mapping between servlet classes and URL patterns, made clear that not all URL patterns had to pass the SecurityFilter. All URLs with the /servlet/ prefix seemed less protected than the RestAPI counterparts, so the researcher began walking through the servlets' implementations, starting with the first three at the top of the list.

The third one turned out to be the jackpot: com.manageengine.ads.fw.servlet.UpdateProductDetails.
Exploitation
Step 1: confirm the servlet is reachable without authentication
Sending a POST request to /servlet/UpdateProductDetails with an empty body returned a 200 response with a simple answer, "Failed", and no 401. That was enough to justify reading the doPost(...) implementation.

Step 2: follow the request object into the authentication check
Following the HttpServletRequest parameter request, which is under the attacker's control, appeared to lead to a dead end almost immediately. It did not.

Looking closely at the function isUserAuthenticated(...), the username and password were processed as part of the request object, but reaching the code that returns Boolean.valueOf(true) was possible even without running into the unwanted ADSErrorHandlers. This is a logical bug: not sending a username parameter at all bypasses the credential check.

Bypassing the second outer if-statement was straightforward by setting the parameter UPDATE_HA_VIRTUAL_HOST to "true", which reaches line 194 with "return Boolean.valueOf(true)".
Step 3: map the request parameters to database writes
Back in UpdateProductDetails.class, various request parameters were fed into functions that appeared to operate on database tables such as ADSProductDetails. Checking the schema in the bundled PostgreSQL instance revealed interesting columns such as is_remotely_hosted.

Reading the ADManager Plus documentation and using the web interface showed that this table stores references to other ManageEngine products used in combination. For example, ServiceDesk Plus makes sense to install in parallel, since helpdesk staff usually want to operate on Windows Active Directories as well (password resets and so on). Administration of the Active Directory should primarily take place in ADManager Plus, but a ServiceDesk instance could be connected to as well. After setting up a ServiceDesk VM and connecting both products with the Integration function, a new row was inserted into ADSProductDetails. The servlet was able to insert and update these entries.

Step 4: insert a row with a host of choice
The following request made sure all conditions were met to bypass the authentication check and additionally inserted a row into the table with a host of the researcher's choice. A listening netcat can be used to confirm the configuration, and ADManager Plus will ask whether the connection was possible.

Step 5: reach the EVENTS parameter
This was not the only kind of modification possible with the servlet. The most powerful part was reachable with another request parameter: EVENTS.

The inner class EventExecutor extends java.lang.Thread, and its start() method triggers the implemented run(). The static method executeEvents(...) of DBSyncModulesContainer took the original EVENTS parameter (a JSONArray object) and passed it to the execute(...) method of various Executor implementations.

The getExecutor() method triggers a database read operation and, based on the key EXECUTOR_CLASS, resolves to the implementing class ADMPExecutorImpl. The first lines of code of ADMPExecutorImpl.execute() show what is possible; the report gives one example of inserting another critical setting into the database.

Even this specific Executor implementation was only the tip of the iceberg. At the end of the execute() function there was another call to super.execute(jsonRow), that is, ExecutorImpl.execute(...), another fallback code branch. The report asks whether that branch allows setting or overwriting Mail Settings, Proxy Settings, or SSOConfig (Single-Sign-On).

After working out how the EVENTS parameter had to be hierarchically structured, the researcher obtained the following:

There are many additional ways to abuse this servlet, which the report leaves as an exercise for the reader.
Root cause
The authentication check in UpdateProductDetails is a logical check on request parameters rather than a real authorisation decision. isUserAuthenticated(...) reads username and password from the request object, and the path that returns Boolean.valueOf(true) is reachable when no username parameter is sent at all, without hitting the ADSErrorHandlers. The second outer if-statement is bypassed by setting UPDATE_HA_VIRTUAL_HOST to "true".
The servlet is mapped under /servlet/, a prefix that appeared less protected than the RestAPI counterparts, so the request reached the vulnerable code. The parameters are then passed into functions that write to tables such as ADSProductDetails, and the EVENTS parameter, a JSONArray object, is passed to Executor implementations, including ADMPExecutorImpl and the fallback ExecutorImpl, which write configuration settings to the database.
Impact
An unauthenticated attacker can insert or update rows in ADSProductDetails, including a host of their choice, and can drive the EVENTS handling to insert or overwrite critical settings such as Mail Settings, Proxy Settings and SSOConfig. The report does not quantify the impact further or state a CVSS score.
Fix
The report does not describe a fix or a vendor response.
Variants to test
- Enumerate servlets mapped under prefixes not covered by the security filter, and send an empty POST to each. A 200 response with an application-level error rather than a 401 is a positive result.
- For each reachable servlet, inspect the authentication helper for branches that return true when a parameter is absent. Omitting the
usernameparameter and observing that the request proceeds is a positive result. - Look for boolean parameters that gate the second outer if-statement, such as
UPDATE_HA_VIRTUAL_HOST, and set them to "true". Reaching the success return is a positive result. - Trace request parameters into database write functions and compare against the schema. Columns such as
is_remotely_hostedthat store host references are worth targeting; a new row appearing in the table is a positive result. - Look for parameters that carry serialised structures such as JSON arrays (here
EVENTS) and are dispatched to Executor classes. A structure that reachesexecute(...)and writes a setting is a positive result. - Check for fallback branches such as
super.execute(jsonRow)that accept broader setting types. Overwriting Mail, Proxy or SSO configuration is a positive result.
What happened, in plain words
A security researcher spent some time reading the source code of a Zoho product called ADManager Plus, looking for a way to get in without a username or password. ADManager Plus is a tool that companies use to manage their Windows Active Directory, which is the central list of staff accounts, computers and permissions inside a company network. The vendor describes it as "An Active Directory (AD) management and reporting solution that allows IT administrators and technicians to manage AD objects easily and generate instant reports at the click of a button!". Companies often run it on internal networks, but the researcher notes that instances are also publicly exposed, for example via Shodan, a search engine that lists devices and services reachable on the internet.
Reading code is different from guessing at a website from the outside. When you can see the source, you can follow exactly how a request is handled, which checks run, and which checks are missing. The researcher calls this a white-box analysis. The goal was to find bugs that an attacker could use without logging in at all, which is the most serious kind, because no stolen password is needed.
The application is written in Java and runs inside a Tomcat web container. A web container is the piece of software that receives HTTP requests and hands them to the right piece of application code. The researcher focused on a particular kind of code called a servlet, mapped under the /servlet/ prefix, because those URLs looked less protected than the RestAPI counterparts. An API is simply a way for one program to talk to another over the network; a REST API is a common style of API where each URL represents a thing and standard HTTP methods (GET, POST and so on) act on it. A servlet is a Java class that handles requests for a given URL pattern.
What the researcher found was a servlet that could be reached without logging in, that accepted a request with no username at all and treated that as a successful login, and that then wrote attacker-chosen values into the product's database. Those values included a host of the attacker's choice and critical settings such as mail, proxy and single sign-on configuration. The report does not give a CVSS score or a bounty amount, and it does not describe a fix or a vendor response.
Setting up a lab
To study the product safely, the researcher downloaded the trial version of ADManager Plus and built a small test environment. A Windows Domain Controller was set up, crediting the DetectionLab project, which is a set of scripts that builds a realistic Windows network for testing. A ServiceDesk Plus virtual machine was also set up and connected to ADManager Plus through the product's Integration function, so that the behaviour of a database table called ADSProductDetails could be watched. Finally, the PostgreSQL database that ships bundled with ADManager Plus was inspected directly. PostgreSQL is a database server; a database is where an application stores its structured data, in tables made of rows and columns, much like a spreadsheet.
Why go to this trouble? Because to know whether a request actually changed something, you need a working copy of the product and a way to look inside its database before and after. Without that, you are only guessing.
Finding it
The starting point was the web.xml file. In a Java web application there are usually several of these, and they act as the master configuration: they declare Filters, Listeners and Java Servlets. A Filter is code that runs before a request reaches its destination, a bit like a security guard at the door of a building who checks everyone coming in. A Listener is code that reacts to events in the application's lifecycle, such as startup. A Servlet, as above, is the code that handles a particular URL.
A few observations stood out:
- Several filters had something to do with "Security", for example
SecurityFilter. - The
SecurityFilterwas not applied to all URL patterns. - A lot of URL patterns end in
.do, a good indicator for Struts. - There were several references to configuration files such as
struts-config.xmlandapi-struts-config.xml, confirming Struts.
Struts is a popular Java framework for building web applications; the .do suffix is a common giveaway that a site is built with it. The important point is the second bullet: if the guard only stands at some doors, the other doors are worth trying.
Reading the <servlet-mapping/> sections, which define the mapping between servlet classes and URL patterns, made clear that not all URL patterns had to pass the SecurityFilter. All URLs with the /servlet/ prefix seemed less protected than the RestAPI counterparts, so the researcher began walking through the servlets' implementations, starting with the first three at the top of the list.

The third one turned out to be the jackpot: com.manageengine.ads.fw.servlet.UpdateProductDetails. The name suggests it updates product details, which is exactly the kind of function that writes to a database, and therefore exactly the kind worth testing.
Exploitation
Step 1: confirm the servlet is reachable without authentication
Sending a POST request to /servlet/UpdateProductDetails with an empty body returned a 200 response with a simple answer, "Failed", and no 401. That was enough to justify reading the doPost(...) implementation.
A POST request is the HTTP method a browser uses when it submits a form; the body is the part of the request that carries the data. An empty body means no data at all was sent. HTTP status codes are the three-digit numbers servers return: 200 means the request was understood and handled, while 401 means "unauthorised", that is, you need to log in first. Getting a 200 with the word "Failed" is interesting because it means the request got all the way into the application's own logic, which then decided something had failed, rather than being stopped at the door by an authentication check. In other words, the guard was not at this door.

Step 2: follow the request object into the authentication check
Following the HttpServletRequest parameter request, which is under the attacker's control, appeared to lead to a dead end almost immediately. It did not.
In Java web applications, HttpServletRequest is the object that represents the incoming request: its URL, its headers, its parameters and its body. Everything in it comes from the client, so everything in it is under the attacker's control. Following that object through the code is how you find out which of its values are trusted and which are checked.

Looking closely at the function isUserAuthenticated(...), the username and password were processed as part of the request object, but reaching the code that returns Boolean.valueOf(true) was possible even without running into the unwanted ADSErrorHandlers. This is a logical bug: not sending a username parameter at all bypasses the credential check.
Boolean.valueOf(true) is Java for "the answer is true", in this case "yes, this user is authenticated". ADSErrorHandlers are error-handling routines that would have interrupted the flow if something went wrong. A logical bug means the code does what it was written to do, but the logic itself is wrong: the check asks "is the username and password valid?" in a way that, when there is no username at all, skips the comparison and falls through to the success answer. A useful everyday comparison is a bouncer who checks your name against a guest list, but who, when you hand over no name at all, assumes you must be on the list and waves you through.

Bypassing the second outer if-statement was straightforward by setting the parameter UPDATE_HA_VIRTUAL_HOST to "true", which reaches line 194 with "return Boolean.valueOf(true)". An if-statement is a branch in the code: if the condition is true, do one thing, otherwise do another. The second outer if-statement was another gate on the way to the success return, and it could be opened simply by sending a parameter with the value "true".
Step 3: map the request parameters to database writes
Back in UpdateProductDetails.class, various request parameters were fed into functions that appeared to operate on database tables such as ADSProductDetails. Checking the schema in the bundled PostgreSQL instance revealed interesting columns such as is_remotely_hosted.
A schema is the description of a database: which tables exist, which columns each table has, and what type of data each column holds. Seeing a column called is_remotely_hosted tells you the table stores references to hosts that are somewhere else on the network, which is exactly the kind of value an attacker would like to control.

Reading the ADManager Plus documentation and using the web interface showed that this table stores references to other ManageEngine products used in combination. For example, ServiceDesk Plus makes sense to install in parallel, since helpdesk staff usually want to operate on Windows Active Directories as well (password resets and so on). Administration of the Active Directory should primarily take place in ADManager Plus, but a ServiceDesk instance could be connected to as well. After setting up a ServiceDesk VM and connecting both products with the Integration function, a new row was inserted into ADSProductDetails. The servlet was able to insert and update these entries.
This is the key insight of the step: by using the product normally, the researcher learned what a legitimate row in the table looks like. Then, by reading the servlet, the researcher learned that the same table could be written to through the servlet, without logging in.

Step 4: insert a row with a host of choice
The following request made sure all conditions were met to bypass the authentication check and additionally inserted a row into the table with a host of the researcher's choice. A listening netcat can be used to confirm the configuration, and ADManager Plus will ask whether the connection was possible.
Netcat is a small command-line tool that can listen on a network port and show anything that connects to it. If you point the product at a host you control and run netcat there, you can see the connection arrive, which proves the configuration was accepted and used. The product itself will also ask whether the connection was possible, which is a second confirmation.

Step 5: reach the EVENTS parameter
This was not the only kind of modification possible with the servlet. The most powerful part was reachable with another request parameter: EVENTS.

The inner class EventExecutor extends java.lang.Thread, and its start() method triggers the implemented run(). The static method executeEvents(...) of DBSyncModulesContainer took the original EVENTS parameter (a JSONArray object) and passed it to the execute(...) method of various Executor implementations.
A thread is a unit of work inside a program; starting a thread means running code in the background. JSON is a text format for structured data, made of objects (key and value pairs in curly braces) and arrays (ordered lists in square brackets). A JSONArray is simply a JSON list. An Executor, in this code, is a class whose job is to carry out an action described by the data it is given. So the EVENTS parameter is a list of instructions, and the application reads that list and hands each entry to the code that performs it.

The getExecutor() method triggers a database read operation and, based on the key EXECUTOR_CLASS, resolves to the implementing class ADMPExecutorImpl. The first lines of code of ADMPExecutorImpl.execute() show what is possible; the report gives one example of inserting another critical setting into the database.
In plain terms: the key EXECUTOR_CLASS is used in a database read to resolve which piece of code to run. Because that value comes from the request, the attacker chooses the code path. ADMPExecutorImpl is one such piece of code, and its execute() method writes settings into the database.

Even this specific Executor implementation was only the tip of the iceberg. At the end of the execute() function there was another call to super.execute(jsonRow), that is, ExecutorImpl.execute(...), another fallback code branch. The report asks whether that branch allows setting or overwriting Mail Settings, Proxy Settings, or SSOConfig (Single-Sign-On).
super in Java means "the parent class". Calling super.execute(jsonRow) means the specific Executor hands the same data up to a more general Executor, which handles a broader range of settings. A fallback branch is a path the code takes when the specific handler does not deal with the setting itself. Mail settings control how the product sends email, proxy settings control how it reaches the network, and SSOConfig controls single sign-on, the mechanism that lets users log in once and be recognised by several systems. Overwriting any of these is a serious capability.

After working out how the EVENTS parameter had to be hierarchically structured, the researcher obtained the following:

There are many additional ways to abuse this servlet, which the report leaves as an exercise for the reader.
Why it works
The authentication check in UpdateProductDetails is a logical check on request parameters rather than a real authorisation decision. isUserAuthenticated(...) reads username and password from the request object, and the path that returns Boolean.valueOf(true) is reachable when no username parameter is sent at all, without hitting the ADSErrorHandlers. The second outer if-statement is bypassed by setting UPDATE_HA_VIRTUAL_HOST to "true".
The servlet is mapped under /servlet/, a prefix that appeared less protected than the RestAPI counterparts, so the request reached the vulnerable code. The parameters are then passed into functions that write to tables such as ADSProductDetails, and the EVENTS parameter, a JSONArray object, is passed to Executor implementations, including ADMPExecutorImpl and the fallback ExecutorImpl, which write configuration settings to the database.
Once it is an object, the code can loop over it and act on each entry.
What an attacker could do
An unauthenticated attacker can insert or update rows in ADSProductDetails, including a host of their choice, and can drive the EVENTS handling to insert or overwrite critical settings such as Mail Settings, Proxy Settings and SSOConfig. The report does not quantify the impact further or state a CVSS score.
What the report does not cover
The report does not describe a fix or a vendor response.
Things worth trying elsewhere
These are patterns to look for when auditing a similar product, not steps that were all carried out in this report.
- Enumerate servlets mapped under prefixes not covered by the security filter, and send an empty POST to each. A 200 response with an application-level error rather than a 401 is a positive result.
- For each reachable servlet, inspect the authentication helper for branches that return true when a parameter is absent. Omitting the
usernameparameter and observing that the request proceeds is a positive result. - Look for boolean parameters that gate the second outer if-statement, such as
UPDATE_HA_VIRTUAL_HOST, and set them to "true". Reaching the success return is a positive result. - Trace request parameters into database write functions and compare against the schema. Columns such as
is_remotely_hostedthat store host references are worth targeting; a new row appearing in the table is a positive result. - Look for parameters that carry serialised structures such as JSON arrays (here
EVENTS) and are dispatched to Executor classes. A structure that reachesexecute(...)and writes a setting is a positive result. - Check for fallback branches such as
super.execute(jsonRow)that accept broader setting types. Overwriting Mail, Proxy or SSO configuration is a positive result.
Glossary
- API: a defined way for one program to talk to another over a network, usually a set of URLs and data formats.
- REST API: a common style of API where each URL represents a thing and standard HTTP methods act on it.
- Servlet: a Java class that handles requests for a particular URL pattern in a Java web application.
- Tomcat: a web container for Java applications; it receives HTTP requests and passes them to the application code.
- Web container: software that runs web application code and manages requests and responses.
web.xml: the configuration file of a Java web application, declaring filters, listeners and servlets.- Filter: code that runs before a request reaches its destination, often used for security checks.
- Listener: code that reacts to application lifecycle events such as startup.
- Struts: a Java framework for building web applications, often recognisable by
.doURLs. - POST request: an HTTP method used to submit data, with the data carried in the request body.
- HTTP status code: the three-digit number a server returns, such as 200 (handled) or 401 (unauthorised).
- 401: the HTTP status meaning the request needs authentication.
HttpServletRequest: the Java object representing an incoming request, including its parameters, headers and body.- Parameter: a named value sent with a request, either in the URL or in the body.
Boolean.valueOf(true): Java code that produces the boolean value true, here meaning "authenticated".- Logical bug: a flaw where the code does what it was written to do, but the logic itself is wrong.
- if-statement: a branch in code that runs one path when a condition is true and another when it is false.
- Database: software that stores structured data in tables of rows and columns.
- PostgreSQL: a database server; here it ships bundled with the product.
- Schema: the description of a database's tables and columns.
- Column: a named field in a database table, holding one kind of value for every row.
- Row: one record in a database table.
- Netcat: a command-line tool that can listen on a network port and show incoming connections.
- Thread: a unit of work inside a program that can run alongside other work.
- JSON: a text format for structured data made of objects and arrays.
- JSONArray: a JSON list, an ordered collection of values in square brackets.
- Deserialise: turn text from a request into a live object in the program's memory.
- Executor: in this code, a class that carries out an action described by the data it is given.
super: in Java, a reference to the parent class;super.execute(...)calls the parent's version of the method.- Fallback branch: a code path taken when the specific handler does not deal with the input itself.
- SSOConfig: single sign-on configuration, controlling how users log in once and are recognised by several systems.
- Shodan: a search engine that lists devices and services reachable on the internet.
- White-box analysis: security testing where the tester can read the source code.
- Unauthenticated: without logging in, that is, without a valid username and password.
- CVSS: a standard scoring system for the severity of a vulnerability.