AI pentesting guides / Vulnerability classes

XML parsing

XXE testing

XXE testing checks whether an application's XML parser will resolve external entities defined in attacker-supplied XML, which can expose local files, trigger server-side requests or exhaust resources. XML external entity injection is CWE-611 and, in the OWASP Top 10 2021, was folded into A05: Security Misconfiguration, because it is usually a parser default left on.

XXE is less common than it was, as many libraries now disable external entities by default, but it persists in SOAP services, document imports (DOCX, XLSX and SVG are XML underneath), SAML handling and older Java and .NET code.

Classification

  • CWE-611 Improper Restriction of XML External Entity Reference; CWE-776 for entity-expansion denial of service.
  • OWASP Top 10 2021: A05 Security Misconfiguration.
  • OWASP API Security Top 10 2023: API8 Security Misconfiguration covers insecure parser configuration in APIs.

Where to test

  • Endpoints that accept XML bodies, including SOAP, XML-RPC and import functions.
  • JSON APIs that also accept XML when Content-Type is changed.
  • File uploads of XML-based formats: SVG, DOCX, XLSX, GPX.
  • SAML assertions and RSS or Atom feed processing.

How it is proven

A textbook test defines an external entity in a DOCTYPE and references it in the document body. If the entity's content, such as a local file, appears in the response, that is direct proof. Most real XXE is blind, so the entity points instead at a unique URL on infrastructure you control; a DNS or HTTP request from the target proves the parser resolved it. Avoid entity-expansion payloads against production, as they can take a service down.

Remediation

Disable DTD processing entirely if you do not need it, or at least disable external entities and external DTD loading, using your parser's documented settings. Keep XML libraries current. Prefer simpler formats such as JSON where possible, and reject XML content types on endpoints that do not need them.

With Pentest-Swarm

How Pentest-Swarm tests for XXE

XXE has a live out-of-band proof producer in Pentest-Swarm's verification layer, documented alongside its other oracles.

  • The adaptive sweep posts an external-entity payload to XML-accepting endpoints (paths containing xml, import, soap or rpc).
  • A parser that resolves the entity calls back to an interactsh host; that callback is the proof.
  • Needs interactsh-client on the PATH, and the out-of-band oracle never reports silence as safe.
  • Scope checks and rate limits apply to every probe.

Where it falls short

Pentest-Swarm's XXE sweep targets endpoints whose paths suggest XML handling; XXE in file uploads (SVG, Office documents), SAML or content-type switching on JSON endpoints is less likely to be reached automatically and should be tested manually. Egress-restricted targets can leave real XXE unproven. Note that XXE is not listed among the headline classes in the project's COVERAGE catalogue, though its oracle producer is documented.

Questions

Is XXE still relevant?

Yes, though less common. It persists in legacy parsers, SOAP services, document processing and SAML.

Can XXE lead to SSRF?

Yes. An external entity pointing at an internal URL makes the server fetch it, which is SSRF through the XML parser.

How do I prevent XXE in Java?

Disable DOCTYPE declarations or external entities on the parser factory. The OWASP XXE Prevention Cheat Sheet lists the exact settings per parser.

Sources

  1. CWE-611
  2. OWASP A05:2021 Security Misconfiguration
  3. OWASP XXE Prevention Cheat Sheet