๐Ÿงช Labs โ€บ Injection

XML External Entities (XXE)

Severity: High
Illustration for XML External Entities (XXE)

A permissive XML parser can be told to fetch files and URLs for you.

What it is

XML lets a document define 'entities' โ€” named shortcuts. An EXTERNAL entity tells the parser to pull its value from a URI, including local files. If an app parses attacker-controlled XML with external entities enabled, the parser will happily read files or make network requests on the attacker's behalf.

Anywhere an app accepts XML โ€” SOAP, SAML, document uploads, some APIs, even SVGs โ€” is a candidate.

It ranges from reading sensitive files to acting as a springboard for server-side request forgery.

How to approach it

  • Find an endpoint that accepts XML and reflects or acts on any part of it.
  • Define an entity whose value comes from a local resource and reference it where the response will echo it back.
  • When the response doesn't echo, look for an out-of-band channel to pull the data to a server you control.
  • Note what the parser can reach โ€” local files, internal URLs โ€” and reason about impact from there.

Your task

Use the document parser to read a file outside the web root.

โ–ถ Access the lab

Opens your hosted RatCTF instance. Work on it directly โ€” there's nothing to submit here; you'll know when you've solved it.

How to prevent it

  • Disable external entity and DTD processing in the XML parser โ€” this is a one-line config in most libraries.
  • Prefer less dangerous formats (JSON) where XML isn't required.
  • Patch and harden the parser; don't rely on input filtering.

More Injection labs

โ† All labs