Skip to content
Info disclosure Write-up Intermediate

How I found my first AEM related bug.

The AEM QueryBuilder servlet was reachable despite the Dispatcher acting as a protective front end, because a crafted path with a fake static file extension and an encoded newline confused the Dispatcher's routing. An attacker could then read the contents of internal directories such as /etc, /home and /content.

Vedant Tekale Follow

Published on vedanttekale20.medium.com

Hello all the amazing hackers and cyber security enthusiasts. My name is Vedant(Also known as Vegeta on Twitter😁) and I’m an aspiring bug bounty hunter and a cyber security enthusiast.

Vedant Tekale, on vedanttekale20.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. 4 min read.

Context

Adobe Experience Manager (AEM) is a content management solution for building websites, mobile apps and forms, and in practice it works as a CMS in the same family as WordPress and Drupal. Two AEM components matter for this story.

The first is the Query Builder servlet. AEM Query Builder is a framework developed by Adobe to build queries (JCR XPath underneath) for a query engine (the OAK Query Engine), composed as a simple set of predicates in key/value form. The second is the Dispatcher, Adobe Experience Manager's caching and load balancing tool, which also helps protect the AEM server from attack. The author's mental model for the Dispatcher is a WAF sitting in front of the AEM instance.

The bug described here is a dispatcher bypass that reaches the Query Builder servlet and lets an attacker read internal paths on the server.

Setup

The work was manual. The researcher had already gathered subdomains for a chosen program and had tried to find vulnerabilities in them several times without success. The tooling used to identify the target was Wappalyzer, run against each subdomain to spot one built on AEM. No accounts, roles or specific versions are described.

Finding it

After a run of duplicates and informative reports on HackerOne in July, the researcher decided to learn new bug classes. A talk by Mikhail Egorov on AEM related bugs was the starting point, followed by reading every write-up on AEM vulnerabilities that could be found. With a basic idea of the topic in hand, the researcher went back to a program whose subdomains had already been enumerated.

Checking each subdomain with Wappalyzer turned up one built on AEM. The next step was fuzzing for the Query Builder servlet, because exploiting it lets an attacker read internal paths. The fuzzing was done by hand, since trying to bypass the Dispatcher is the fun part.

From the original on vedanttekale20.medium.com

The first payloads all came back as 404. The idea being tested is that suffixes such as /a.css or /a.png can be used to confuse the Dispatcher into granting access to the Query Builder servlet.

Credits to Mikhail Egorov. From the original on vedanttekale20.medium.com

After trying similar payloads, one worked.

Exploitation

Step 1: identify an AEM instance

Browse the program's subdomains with Wappalyzer and look for the AEM fingerprint. One subdomain was built using AEM.

Step 2: fuzz for the Query Builder servlet through the Dispatcher

Send requests for the Query Builder servlet with suffixes designed to make the Dispatcher treat the request as a static asset. The payloads tried initially returned 404, but the approach of appending things like /a.css or /a.png was kept up.

Step 3: the payload that worked

The final payload looked like this:

Text
/bin/querybuilder.json.;%0aa.css?path=/etc&p.hits=full&p.limit=-1

The path targets the Query Builder servlet with a .json extension. The .;%0aa.css suffix is the part that got past the Dispatcher, which the report attributes to confusing it with a static-file suffix. The query string sets path=/etc as the search root, p.hits=full to return full results, and p.limit=-1 to remove the result limit.

With this payload the contents of directories such as /etc, /home and /content could be read.

Step 4: report

The issue was reported quickly. It was triaged after 2 days and a bounty was awarded after a week.

From the original on vedanttekale20.medium.com

The same class of bug can be hunted with automation: there are many nuclei templates for AEM related bugs in the projectdiscovery nuclei-templates repository under misconfiguration/aem.

Root cause

The Dispatcher is meant to shield the AEM server, and the Query Builder servlet is not something a visitor should reach directly. The bypass works because the Dispatcher's handling of the request path can be confused by a suffix that looks like a static asset, such as /a.css or /a.png. The report does not describe the Dispatcher configuration or the exact parsing difference behind the bypass.

Impact

An attacker who can reach the Query Builder servlet through the Dispatcher can read internal paths on the AEM instance. In this case the contents of directories such as /etc, /home and /content were readable. The exposure depends on the target being an AEM instance behind a Dispatcher that can be bypassed this way, and on the Query Builder servlet being reachable once the Dispatcher is fooled.

Fix

The report does not state what the program changed. The measure implied by the finding is to make the Dispatcher block access to the Query Builder servlet reliably, so that path tricks with suffixes such as .css and encoded characters cannot reach it.

Variants to test

  1. Try other static suffixes in place of .css, such as .png, appended after the servlet path. A positive result is a response from the Query Builder servlet instead of a 404.
  2. Change the path parameter to other roots such as /home or /content and keep p.hits=full and p.limit=-1. A positive result is a listing of the contents of that directory.
  3. Run the AEM nuclei templates from the misconfiguration/aem directory against AEM subdomains found with Wappalyzer. A positive result is a template match for the Query Builder servlet exposure.

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. 11 min read.

What happened, in plain words

A security researcher found a way to read folders on a company's web server that visitors are not supposed to see. The website was built with a product called Adobe Experience Manager, or AEM for short. AEM is a system that lets a company build and manage a website without writing every page by hand, in the same way WordPress or Drupal do. The researcher found a request that slipped past the protective layer in front of the site and could read the contents of folders such as /etc, /home and /content. He reported it, the company confirmed the problem two days later, and he was paid a bounty a week after that. This article walks through the same story from the beginning, explaining each idea as it comes up.

Background: the three things you need to know

Before the bug makes sense, you need three ideas: what AEM is, what the Query Builder servlet is, and what the Dispatcher is. Each one is explained below from scratch.

What AEM is

A content management system, or CMS, is software that stores a website's pages, images and other material in a database and lets staff edit them through a control panel. WordPress and Drupal are well known examples. Adobe Experience Manager is Adobe's version of the same idea, aimed at larger organisations. The researcher quotes Adobe's own description: AEM is "a comprehensive content management solution for building websites, mobile apps and forms. And it makes it easy to manage your marketing content and assets." In plain terms, a company installs AEM, fills it with pages, and AEM serves those pages to visitors.

What the Query Builder servlet is

A servlet is a small program that runs inside a Java web server and answers a particular kind of request. Think of a servlet as a service counter in a large building: you walk up to the right counter with the right form, and the clerk behind it fetches what you asked for. AEM ships with many servlets, and one of them is the Query Builder servlet.

The Query Builder is, in the researcher's words, "a framework developed by adobe to build queries (JCR XPath underneath) for a query engine (OAK Query Engine) which are simple to compose. A query can be described as simple set of predicates in key value form." That is dense, so here is the everyday version. A query is a question you ask a database, such as "give me every page whose path starts with /content". The Query Builder lets you write that question as a list of settings in the address bar rather than in a programming language. Each setting is a name and a value, like path=/etc or p.limit=-1. The servlet reads those settings, runs the search, and sends back the results, usually as JSON, which is a plain text format for structured data that both humans and programs can read.

The important point for this story is that the Query Builder servlet is a powerful internal tool. If an outsider can reach it, they can ask the server questions about its own file system. That is not something a normal visitor should be able to do.

What the Dispatcher is

The Dispatcher is, again quoting the researcher, "Adobe Experience Manager's caching and/or load balancing tool. Using AEM's Dispatcher also helps to protect AEM server from attack". Two jobs are packed into that sentence.

Caching means keeping a copy of a page so it can be handed out again quickly without asking the main server to rebuild it. Load balancing means spreading incoming traffic across several servers so no single one is overwhelmed. The protective part is the third job: the Dispatcher sits in front of AEM and decides which requests are allowed through to the AEM server behind it and which are turned away.

The researcher's mental model is that the Dispatcher works like a WAF. A WAF, or web application firewall, is a filter placed in front of a website that inspects each incoming request and blocks the ones that look dangerous. So picture the Dispatcher as a receptionist at the front desk of an office. Visitors ask the receptionist for things, and the receptionist either walks the request back to the right department or says no. The Query Builder servlet is a back-office department that visitors are not meant to reach directly. The whole bug is about getting past the receptionist.

The vulnerability

In July the researcher had collected a lot of duplicate reports and reports that turned out to be informative rather than valid on HackerOne, a platform where companies run bug bounty programmes. A duplicate is a report of a bug someone else already reported; an informative report is one the company reads but does not treat as a security problem. A run like that is discouraging, and the researcher recalls a quote he uses when hunting gets hard: "If your life just got harder, you've just leveled up".

Or watch on YouTube
From the original on vedanttekale20.medium.com

Rather than keep doing the same thing, he decided to learn some new types of bug. After searching around he found a talk by Mikhail Egorov about AEM related bugs. The topic was completely new to him, so he explored further and read every write-up he could find about AEM vulnerabilities. With a basic idea in hand, he picked one programme to work on. He had already gathered that programme's subdomains, which are the smaller addresses under a company's main domain, such as shop.example.com or blog.example.com, and had tried to find bugs in them several times without success. This time was different.

He went through every subdomain using Wappalyzer. Wappalyzer is a browser extension that looks at a website and guesses which software it is built with, by spotting telltale signs such as file names, headers and scripts. Its purpose here was simple: find a subdomain running AEM. After a while he found one.

From the original on vedanttekale20.medium.com

Next he started fuzzing for the Query Builder servlet. Fuzzing means sending a large number of slightly different requests and watching the responses, hoping one of them behaves differently from the rest. He was doing it by hand rather than with a tool, because, as he puts it, it is very fun trying to bypass the Dispatcher. The goal of each request was to reach the Query Builder servlet even though the Dispatcher was supposed to block it.

His first attempts all came back as 404. A 404 is the standard web response for "not found": the server is saying it has nothing at that address. The idea he was testing is that adding a suffix such as /a.css or /a.png to the end of a request can confuse the Dispatcher into treating the request as a harmless static file. A static file is one that is simply stored and sent as-is, like an image or a stylesheet, as opposed to a request that makes the server run a program. Dispatchers are usually happy to let static files through, because serving them is cheap and safe. If the Dispatcher can be convinced that a request for the Query Builder servlet is really a request for a stylesheet, it may pass it along.

Credits to Mikhail Egorov. From the original on vedanttekale20.medium.com

As the image shows, suffixes like /a.css and /a.png are the trick being tried. He kept sending variations, and eventually one worked.

The payload that worked

The final request looked like this:

Text
/bin/querybuilder.json.;%0aa.css?path=/etc&p.hits=full&p.limit=-1

Here is what each part does, piece by piece.

  • /bin/querybuilder.json is the address of the Query Builder servlet. The .json at the end asks for the answer in JSON format, the structured text format described earlier.
  • .;%0aa.css is the part that got past the Dispatcher, which the report attributes to confusing it with a static-file suffix. %0a is how a newline character is written when it has to travel inside a web address, because a real line break cannot appear in a URL. The .css ending makes the whole thing look, to the Dispatcher, like a request for a stylesheet. The report does not describe the Dispatcher's configuration or the exact parsing difference behind the bypass.
  • ? marks the start of the query string, the part of a web address that carries settings rather than a location.
  • path=/etc tells the Query Builder where to start searching. Here it is the /etc directory, a standard folder on Linux systems that holds configuration files.
  • p.hits=full asks for full results rather than a short summary.
  • p.limit=-1 removes the limit on how many results come back. A negative number here means "no cap".

With this request, the contents of directories such as /etc, /home and /content could be read. In other words, the receptionist was fooled into walking the request back to the back office, and the back office answered.

Reporting it

The researcher reported the issue quickly. It was triaged after 2 days, which means the company's security team looked at it and confirmed it was a real problem worth fixing. After a week he was awarded a bounty, a payment that bug bounty programmes give for valid reports.

From the original on vedanttekale20.medium.com

The same kind of bug can also be hunted with automation. Nuclei is a tool that runs a library of ready-made checks, called templates, against a target. There are many nuclei templates for AEM related bugs, collected in the projectdiscovery nuclei-templates repository under misconfiguration/aem. Running those templates against AEM subdomains found with Wappalyzer is a way to look for the same exposure without writing each request by hand.

Why it worked

The Dispatcher exists to shield the AEM server, and the Query Builder servlet is not something a visitor should reach directly. The bypass works because the Dispatcher's handling of the request path can be confused by a suffix that looks like a static asset, such as /a.css or /a.png. The encoded newline is part of that confusion. The report does not describe the Dispatcher configuration or the exact parsing difference, so the precise mechanism is likely a mismatch between how the Dispatcher and the servlet container normalise and match the path.

What an attacker could do

An attacker who can reach the Query Builder servlet through the Dispatcher can read internal paths on the AEM instance. In this case the contents of directories such as /etc, /home and /content were readable. How much is exposed depends on the target being an AEM instance behind a Dispatcher that can be bypassed this way, and on the Query Builder servlet being reachable once the Dispatcher is fooled.

How to fix it

The measure implied by the finding is to make the Dispatcher block access to the Query Builder servlet reliably, so that path tricks with suffixes such as .css and encoded characters cannot reach it.

Variants to test

If you want to look for the same kind of problem on a target you are authorised to test, these are the variations the technical write-up suggests. Each one changes a single part of the working request and watches for a different response.

  1. Try other static suffixes in place of .css, such as .png, appended after the servlet path. A positive result is a response from the Query Builder servlet instead of a 404.
  2. Change the path parameter to other roots such as /home or /content and keep p.hits=full and p.limit=-1. A positive result is a listing of the contents of that directory.
  3. Run the AEM nuclei templates from the misconfiguration/aem directory against AEM subdomains found with Wappalyzer. A positive result is a template match for the Query Builder servlet exposure.

Glossary

  • 404: the standard web response meaning "not found", sent when the server has nothing at the requested address.
  • AEM (Adobe Experience Manager): Adobe's content management system for building websites, mobile apps and forms.
  • Bounty: a payment a company gives to a researcher who reports a valid security problem through its bug bounty programme.
  • Bug bounty programme: a scheme where a company invites outside researchers to report security problems, usually in exchange for a reward.
  • CMS (content management system): software that stores and serves a website's content and lets staff edit it through a control panel, such as WordPress, Drupal or AEM.
  • Caching: keeping a copy of something so it can be served again quickly without rebuilding it.
  • Dispatcher: Adobe Experience Manager's caching and load balancing tool, which also helps protect the AEM server from attack by filtering requests before they reach it.
  • Duplicate report: a report of a bug that someone else has already reported.
  • Encoded character: a character written in a form that can travel inside a web address, such as %0a for a newline.
  • Fuzzing: sending many slightly different requests and watching the responses, hoping one behaves differently from the rest.
  • HackerOne: a platform where companies run bug bounty programmes and researchers submit reports.
  • Informative report: a report a company reads but does not treat as a security problem.
  • JCR XPath: the query language used underneath AEM's Query Builder to search the content repository.
  • JSON: a plain text format for structured data that both humans and programs can read.
  • Load balancing: spreading incoming traffic across several servers so no single one is overwhelmed.
  • Nuclei: a tool that runs a library of ready-made checks, called templates, against a target.
  • OAK Query Engine: the query engine that AEM's Query Builder uses to run searches.
  • Payload: the specific request, or part of a request, crafted to trigger a bug.
  • Query: a question asked of a database, such as "list everything under this path".
  • Query Builder servlet: the AEM component that turns key/value settings in a web address into a query and returns the results.
  • Query string: the part of a web address after the ? that carries settings rather than a location.
  • Servlet: a small program running inside a Java web server that answers a particular kind of request.
  • Static file: a file stored and sent as-is, such as an image or a stylesheet, rather than one that makes the server run a program.
  • Subdomain: a smaller address under a company's main domain, such as shop.example.com.
  • Template (nuclei): a ready-made check in the nuclei library that describes how to test for a particular issue.
  • Triaged: reviewed by the company's security team and confirmed as a real problem worth acting on.
  • WAF (web application firewall): a filter placed in front of a website that inspects each incoming request and blocks the ones that look dangerous.
  • Wappalyzer: a browser extension that guesses which software a website is built with by spotting telltale signs such as file names, headers and scripts.

More by Vedant Tekale

View all

8 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.