# 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:include` pulls 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 ([[raw/portswigger.net/what-is-xxe-xml-external-entity-injection-tutorial-examples-web-securi-460|What is XXE injection?]], [[raw/yeswehack.com/xml-external-entity-the-ultimate-bug-bounty-guide-to-xxe-yeswehack-2823|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 ([[raw/book.hacktricks.xyz/xxe-xee-xml-external-entity-hacktricks-455|XXE | HackTricks]], [[raw/medium.com/xxe-injection-overview-3135|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 ([[raw/yeswehack.com/xml-external-entity-the-ultimate-bug-bounty-guide-to-xxe-yeswehack-2823|Ultimate Bug Bounty Guide to XXE]], [[raw/hackviser.com/xml-external-entity-xxe-attack-guide-hackviser-2824|XXE Attack Guide | Hackviser]]). - An `href` pointing at an `http://` 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 ([[raw/infosecwriteups.com/xxe-from-zero-to-hero-5090|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 ([[raw/yeswehack.com/xml-external-entity-the-ultimate-bug-bounty-guide-to-xxe-yeswehack-2823|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 ([[raw/dedsecops.com/xxe-as-a-dast-finding-in-band-error-based-and-out-of-band-confirmation-14210|XXE as a DAST Finding]]). The defense is therefore its own: **keep XInclude disabled** unless explicitly required, independent of your entity hardening ([[raw/cheatsheetseries.owasp.org/xml-external-entity-prevention-owasp-cheat-sheet-series-2059|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 ([[raw/dedsecops.com/xxe-as-a-dast-finding-in-band-error-based-and-out-of-band-confirmation-14210|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 ([[raw/book.hacktricks.xyz/xxe-xee-xml-external-entity-hacktricks-455|XXE | HackTricks]]). ## Related - [[XML External Entity Injection]] - [[XXE to SSRF and Cloud Metadata]] - [[XXE Parser Defaults and Hardening]] - [[XXE via File Uploads]] ## Sources - [[raw/portswigger.net/what-is-xxe-xml-external-entity-injection-tutorial-examples-web-securi-460|What is XXE injection? | PortSwigger]] - [[raw/yeswehack.com/xml-external-entity-the-ultimate-bug-bounty-guide-to-xxe-yeswehack-2823|Ultimate Bug Bounty Guide to XXE | YesWeHack]] - [[raw/book.hacktricks.xyz/xxe-xee-xml-external-entity-hacktricks-455|XXE - XEE - XML External Entity | HackTricks]] - [[raw/hackviser.com/xml-external-entity-xxe-attack-guide-hackviser-2824|XXE Attack Guide | Hackviser]] - [[raw/medium.com/xxe-injection-overview-3135|XXE Injection Overview]] - [[raw/infosecwriteups.com/xxe-from-zero-to-hero-5090|XXE: From Zero to Hero]] - [[raw/dedsecops.com/xxe-as-a-dast-finding-in-band-error-based-and-out-of-band-confirmation-14210|XXE as a DAST Finding]] - [[raw/cheatsheetseries.owasp.org/xml-external-entity-prevention-owasp-cheat-sheet-series-2059|OWASP XXE Prevention Cheat Sheet]]