XXE Explained: The XML Attack Hiding in Plain Sight

XXE explained in plain terms means understanding the attack that turns a server’s own XML parser against it, tricking it into reading files it was never meant to share, and that has quietly breached systems for over two decades. The central question is how a document format as boring as XML can be dangerous at all, and the answer is that XML was designed to be helpful, and helpful features make excellent weapons.

XXE stands for XML External Entity, an attack in which a malicious XML document defines an entity that points outside the document, to a file on the server, a service on the internal network, or a remote address, and the parser obediently fetches it. The result can be stolen files, server-side request forgery, or a crashed service, all from a single crafted upload.

This article explains what XXE is, how it works, and how to stop it.

Key takeaways

  • XXE is an attack that abuses XML external entities to read server files.
  • It exploits a feature of XML, not a bug in any one program.
  • It can leak files, reach internal services, and crash servers.
  • It appears wherever applications accept XML uploads or feeds.
  • Disabling external entities stops it, and the fix is usually one setting.

What XXE is

XXE is a class of attack against applications that parse XML input, in which the attacker includes a document type definition that declares an external entity, and the parser resolves that entity by reading the referenced resource. The classic payload points at a local file, and when the application echoes the parsed data back, the file’s contents come with it, which is how secrets leave a server through its own front door.

Its signature feature is that the attack uses a legitimate XML mechanism. External entities were designed so documents could include shared content from other files, and the feature works exactly as specified, which is why the vulnerability has appeared in so many parsers across so many languages. The parser is not broken; it is doing what it was told, and the application simply should never have let an untrusted document tell it to.

The design of XML made the attack almost inevitable. The format dates to the late nineties, when documents were trusted and parsers were built to be maximally helpful, and external entities, internal subsets, and parameter entities were all part of the specification. Security was not the priority, and two decades later the world’s servers are still paying for that optimism.

It became one of the most consistently ranked web risks. XXE appeared in the OWASP Top 10 in 2017 and has stayed on security teams’ checklists ever since, because XML is still everywhere: in document uploads, office file formats, SOAP services, SAML logins, and RSS feeds. Any of those that accepts XML from an untrusted source can be a target.

Its most famous property is the range of damage from one payload. The same technique that reads a password file can also make the server request internal addresses, scan the private network, or expand a tiny document into gigabytes of memory and crash the service. One crafted file, many different disasters, and the attacker chooses which one to cause.

Our guide to HSTS explains how browsers enforce secure connections that limit what an attacker can do with stolen data, and our guide to side-channel attacks explains another family of attacks that abuse a system’s own features.

How XXE works

Everything starts with the document type definition, the part of an XML document that can declare entities. The attacker writes a definition that names an entity and points it at a file path, then uses that entity where a normal value would go, and when the parser builds the document it replaces the entity with the file’s contents. The application, expecting a name or a comment, receives the server’s secrets instead.

File disclosure is the simplest version. An entity pointing at the system’s password file, a configuration file, or an application secret is resolved by the parser, and if the application returns the parsed document to the attacker, the file comes back with it. The attacker never touches the filesystem directly, and the server’s own parser does the reading for them.

Server-side request forgery is the more dangerous version. An entity that points at an internal address makes the server itself send the request, reaching services that are not exposed to the internet at all, like internal admin panels, metadata services, and databases. The attacker uses the server as a proxy into its own private network, and the requests come from a trusted address.

Denial of service is the crudest version, and it needs no exfiltration at all. A document that defines entities inside entities, each expanding into many copies of the next, grows from a few hundred bytes into gigabytes of memory, a trick known as the billion laughs attack, and the parser exhausts the server’s memory before it finishes. The service falls over, and the attacker only sent a tiny file.

Blind XXE is the version used when the application never returns the parsed data. The attacker points the entity at a server they control, and the parser’s request to that server, carrying a fragment of the stolen file, reveals the data indirectly, or the timing of the request reveals whether a file exists. It is slower and noisier, but it works against applications that never echo anything back.

A dark office desk with a laptop showing glowing green document text, a locked steel box and a notebook beside it
A dark office desk with a laptop showing glowing green document text, a locked steel box and a notebook beside it, shows how XXE works: a document asks the parser to fetch a file, and the parser obeys without asking who wrote the document.

Comparing XXE with other injection attacks

XXE is one of several injection attacks, and each was built with a different emphasis. SQL injection targets databases through crafted queries, cross-site scripting targets browsers through crafted pages, and command injection targets the operating system through crafted input, while XXE targets the XML parser itself, and each approach trades reach for subtlety in a different way.

The table below sets out the main contrasts between the leading approaches.

Aspect XXE SQL injection Cross-site scripting
Target XML parser Database Browser
Reads server files Yes Sometimes No
Reaches internal network Yes Rarely No
Needs echoed output Not always Not always Yes
Best defence Disable entities Parameters Output encoding

The practical result is that XXE is stopped by disabling entities, SQL injection is stopped by parameterised queries, and cross-site scripting is stopped by encoding output.

Where XXE is used

Document uploads are the classic target. Any application that accepts XML files, office documents, or SVG images from users is parsing XML, and office formats are XML in disguise, which means a crafted spreadsheet or drawing can carry an XXE payload. The upload form is the attack surface, and the parser is the weapon.

SOAP services are a frequent victim. Older enterprise integrations still exchange XML over SOAP, and those services often parse whatever arrives with a permissive parser and an old configuration. A single request to a forgotten endpoint can expose the files of a system nobody has audited in years.

Single sign-on is a high-value target. SAML, the protocol behind enterprise logins, is built on XML, and a vulnerable identity provider is a prize worth chasing, because it guards the keys to every application behind it. The login flow is the last place anyone expects an XML attack, which is why attackers look there.

Feed readers and importers are a quiet risk. Applications that fetch RSS feeds, import data from partners, or consume XML from third parties are parsing documents written by strangers, and a malicious feed can carry the same payload as a direct upload. The trust placed in a partner’s feed is the vulnerability.

Bug bounty hunters find it everywhere. XXE remains a reliable finding in bounty programs, because so many applications still accept XML with default parser settings, and the proof of impact, a file read from the server, is dramatic and easy to demonstrate. It is one of the first things a tester checks.

Strengths and limits

The greatest strength of XXE, from the attacker’s side, is that it abuses a feature rather than a bug. There is no patch for the XML specification, and the attack works against any parser configured to resolve external entities, which means the vulnerability is as widespread as XML itself. The defence is configuration, not a fix, and configuration is easy to get wrong.

It is also a strength that the attack is so flexible. One technique reads files, reaches internal services, and crashes servers, and the attacker can choose the version that fits the target, switching from file disclosure to blind exfiltration when the application stops echoing output. That adaptability keeps the attack relevant long after its discovery.

The limits are real, though, and the biggest is that the fix is simple and well known. Disabling external entities, or switching to a parser that never resolves them, removes the attack entirely, and modern frameworks increasingly ship with safe defaults. XXE survives on old code and lazy configuration, not on any strength of its own.

XXE checklist

  • Disable external entities in every XML parser you use.
  • Disable parameter entities and internal subsets where possible.
  • Use a parser that never resolves external entities by default.
  • Never accept XML uploads without validating the content first.
  • Patch or replace SOAP services that still use old parsers.
  • Test SAML endpoints for XXE during every security review.
  • Block outbound requests from application servers where possible.
  • Log parser errors; unexpected entity failures can signal probing.
  • Prefer JSON over XML for new integrations, and avoid XML entirely.

Frequently asked questions

What is XXE in simple terms?

It is an attack in which a malicious XML document tricks the server’s parser into reading a file or contacting an internal service, using a feature of XML called external entities.

How is XXE different from the billion laughs attack?

The billion laughs attack is one kind of XXE, using nested entities to exhaust memory. XXE is the wider family, which also includes reading files and reaching internal services.

Does XXE affect JSON?

No, JSON has no entities and no document type definitions, which is one reason new systems prefer it. XXE is specific to XML and formats built on it.

Can XXE affect office documents?

Yes, modern office formats are XML inside a compressed archive, so a crafted document can carry an XXE payload. Applications that open untrusted documents need safe parser settings.

What is blind XXE?

It is XXE against an application that never returns the parsed data, where the attacker exfiltrates information indirectly, usually by making the parser request a server they control.

When should I worry about XXE?

Whenever your application accepts XML from users, partners, or feeds, including uploads, SOAP services, SAML logins, and office documents. If you parse XML, check your settings.

The bottom line

XXE explained in one line is this: an attack that turns a server’s own XML parser into a thief, by asking it to fetch files and internal addresses it was never meant to share.

It is the price of a helpful feature in a trusting format, and the reason it still matters is that XML is still everywhere, and too many parsers still arrive configured to obey any document they are given.

This article is general information about how XXE works, not advice about securing a particular application or system.

Latest articles

Scroll to Top