Skip to content

Bug class · Intermediate

XML external entities (XXE)

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

median public bounty
$1,050

Covers CWE 611, 776.

How it works

Full lesson

The pattern behind every report in this class.

XML external entity (XXE) is a flaw in how an application parses XML. When a parser is allowed to resolve external entities and process document type definitions, an attacker who controls any part of the XML can make the parser fetch local files, contact remote hosts, or expand entities until resources run out. The database behind this lesson holds 97 reports, 19 with summaries and 8 paid, so it is a real but not always rewarded class of bug. Programs care because the same parser mistake can expose configuration files, credentials and internal services, and because the fix is usually a single parser setting.

What it usually leads to is information disclosure: local files read back in a response or an error, outbound requests that prove the server can be steered, and in the worst cases cloud metadata credentials or NTLM hashes captured from a Windows host. Some reports show it escalating to remote code execution, for example on DoD web servers and on-premises Dynamics 365, but those are the exception rather than the rule. Denial of service through entity expansion is also documented.

It turns up wherever XML is parsed: SOAP services, SAML response parameters, sitemap and feed crawlers, XLSX and XLF uploads, image metadata in WAV, JPEG and SVG files, PDF generators, workflow schedulers, search ingest APIs, login endpoints and configuration loaders. The evidence also shows it in less obvious places such as spell-check endpoints, EPP dashboards, ColdFusion WDDX packets and AMF parsers that carry XML. If a feature accepts XML, or accepts a file that contains XML, it is a candidate.

The attack starts with a document type definition at the top of an XML document. That definition can declare an entity whose value is not a literal string but a reference to something outside the document, such as a local file path or a remote address. When the parser meets a reference to that entity in the body of the document, it resolves it, and the resolved content is substituted where the reference appeared.

Things to try

All 81

Each line worked in a disclosed report. Test only what a program's scope allows.

Third-party products and platforms 30

  • Test Stanford CoreNLP XML parsing for external entity references.
  • Feed XML into LangChain's XMLOutputParser and text splitters and test for entity expansion and XXE.
  • Send a WDDX packet to a ColdFusion endpoint and test whether the embedded XML resolves external entities.
  • Send AMF-encoded data that carries XML and check whether the parser resolves external entities.

XML request bodies and parameters 10

  • Send an XML body that declares an external entity pointing at a local file and reference it in a field, then check whether the file contents come back in the response or an error.
  • Send XML with injected elements or attributes to endpoints that build XML from user input and check for injection.
  • Feed XML into a component that performs XSLT parsing and check whether external entities are resolved.
  • Send XML to a messaging servlet that parses it and check for file reads and outbound requests.

Other 8

  • Send XXE payloads to an EPP endpoint and then check other dashboard pages for the stored file contents appearing later.
  • Store XXE output in one feature and look for it rendered later on a different page or export.
  • Test multiple domains belonging to the same organisation for blind out-of-band XXE.
  • Test XML parsing on production infrastructure for read access.

Feeds, sitemaps and crawlers 7

  • Point a site audit or crawler at a sitemap.xml you host that declares an external entity, then check for callbacks or file contents.
  • Capture a search request, change it to POST with an XML content type, add a DTD reference and check your server logs for the callback.
  • Submit an RSS or XML feed that declares an external entity and see whether the feed reader resolves it.
  • Point an enterprise search web crawler at a page or sitemap you host that declares external entities.

SVG and image processing 6

  • Upload an SVG that references an external DTD and reads a local file, then render it through the image conversion pipeline.
  • Craft a WAV file whose iXML chunk contains XML with an external entity and upload it to a media library as an author-level user.
  • Embed an XMP metadata block in an uploaded JPEG that references an external DTD and watch for a callback from the image processor.
  • Use an insert SVG feature in a desktop or web application to trigger blind XXE through the SVG parser.

Bypasses and variations

All 10
  • When HTTP out-of-band exfiltration fails, use FTP or other protocols instead.
  • Use error-based techniques when out-of-band channels are blocked.
  • Store XXE output and retrieve it later from a different page.
  • Use UNC-style paths in external entities to capture NTLM hashes.
  • After confirming XXE, pivot to the cloud metadata endpoint to obtain credentials.
  • Use a double forward slash in an SVG fill attribute to get past a regex filter and load an external SVG.

Typical fixes

All 11
  • Disable external entity resolution and DTD processing in XML parsers.
  • Do not pass flags that explicitly enable entity substitution, even on PHP 8.
  • Disable external entity resolution in sitemap parsers.
  • Disable entity expansion in XML configuration loaders.
  • Do not trust client-supplied file type lists; validate file types server-side.
  • Disable external entity expansion and XInclude processing in ImageMagick SVG handling.

Tips for beginners

All 13
  • Start with features that obviously parse XML: SOAP endpoints, SAML response parameters, sitemap and RSS crawlers, search ingest APIs and login endpoints that accept XML bodies. Then widen to uploads that contain XML, such as XLSX, XLF, WAV, JPEG and SVG, because the parser is often hidden behind the file type.
  • Before sending anything, confirm the feature is in scope and that you are allowed to make outbound requests from the target. A blind XXE test causes the server to contact a host you control, which some programmes treat as prohibited or rate-limited. Read the policy first; reporting an out-of-scope callback is a common beginner mistake.
  • Use a host you control to watch for callbacks, and have a fallback ready. If HTTP callbacks are blocked, try other protocols, error-based techniques or PHP stream wrappers where the stack allows it. The evidence shows all of these being used when the simple channel failed.
  • Prove impact with the smallest possible read. A single local file that is clearly sensitive, such as a configuration file, is enough to demonstrate the flaw. Do not go hunting through the filesystem for trophies; that increases risk and adds nothing to the report.
  • If the response does not show the resolved content, look for a second place it might appear. Stored XXE output has been found rendered on a different page or export, sometimes without access control. Check dashboards, previews and exports after submitting.
  • On cloud-hosted targets, a confirmed file read can often be extended to the metadata service to show credential exposure. Treat this as a separate, higher-impact step and only take it if the programme permits it. The same caution applies to UNC paths that capture NTLM hashes on Windows hosts.

Start here: a reading path

Open the path

Clear reports in order, easiest first.

Guides and techniques

View all

The best explainers, cheat sheets and technique posts on XXE, from around the web.

Newest reports

All 299

Most recently disclosed.

New XXE reports by email

Follow XXE and get each week's new disclosures in one short email.

Free. New reports for what you follow, weekly by default. One-click unsubscribe. Privacy