XInclude Attacks
A DOCTYPE-free route to XXE: when you control only a single value that the server embeds into an XML document it builds,
xi:includepulls in local files or URLs without declaring any entities.
When it applies
Classic XXE needs you to control (or add) the DOCTYPE so you can declare entities. Some sinks deny that: the application takes a client value, inserts it into a server-built XML document (a back-end SOAP request, say), and parses the whole thing — you never see or control the document’s prologue. DOCTYPE-stripping filters and parsers configured to reject custom DOCTYPEs produce the same situation (What is XXE injection?, Ultimate Bug Bounty Guide to XXE).
XInclude (http://www.w3.org/2001/XInclude) is part of the XML spec that builds a document from sub-documents, and it loads resources independently of DTDs. An xi:include element placed inside any data value you control makes the parser inline an external resource — so the attack works even when you govern only one field (XXE | HackTricks, XXE Injection Overview).
Mechanics
Inject into the controlled value a namespace declaration plus an include element:
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="text" href="file:///etc/passwd"/>
</foo>
parse="text"is crucial for file read: it treats the target as plaintext, so non-XML files (like/etc/passwd) don’t break parsing (Ultimate Bug Bounty Guide to XXE, XXE Attack Guide | Hackviser).- An
hrefpointing at anhttp://URL turns it into SSRF / remote inclusion (XXE to SSRF and Cloud Metadata). - You must know which parameter is reflected; in real targets, test each value and watch which one returns included content (XXE: From Zero to Hero).
Because XInclude carries no DOCTYPE, it is effective against applications that sanitize or validate XML before processing — those defenses key on DOCTYPE/entities and never fire (Ultimate Bug Bounty Guide to XXE).
A separate switch, a separate finding
XInclude is not governed by external-entity settings. A parser hardened against entity resolution can still execute an explicitly-invoked XInclude step and read a file — dedsecops measured exactly this: lxml at its safe entity default still inlined a local file when the XInclude step ran (XXE as a DAST Finding). The defense is therefore its own: keep XInclude disabled unless explicitly required, independent of your entity hardening (OWASP XXE Prevention Cheat Sheet). Note that Python’s xml.etree.ElementInclude is opt-in and in one measurement treated a file:// URL as a literal filename — library behavior varies, so verify (XXE as a DAST Finding).
If even XInclude and entities are disabled but your input still lands unencoded in a server-built document, fall back to plain XML/tag injection to alter the document structure (XXE | HackTricks).
Related
- XML External Entity Injection
- XXE to SSRF and Cloud Metadata
- XXE Parser Defaults and Hardening
- XXE via File Uploads
Sources
- What is XXE injection? | PortSwigger · original
- Ultimate Bug Bounty Guide to XXE | YesWeHack · original
- XXE - XEE - XML External Entity | HackTricks · original
- XXE Attack Guide | Hackviser · original
- XXE Injection Overview · original
- XXE: From Zero to Hero · original
- XXE as a DAST Finding · original
- OWASP XXE Prevention Cheat Sheet · original