XSLT Server Side Injection

Basic Information

XSLT is a technology employed for transforming XML documents into different formats. It comes in three versions: 1, 2, and 3, with version 1 being the most commonly utilized. The transformation process can be executed either on the server or within the browser.

The frameworks that are most frequently used include:

  • Libxslt from Gnome,

  • Xalan from Apache,

  • Saxon from Saxonica.

For the exploitation of vulnerabilities associated with XSLT, it is necessary for xsl tags to be stored on the server side, followed by accessing that content. An illustration of such a vulnerability is documented in the following source: https://www.gosecure.net/blog/2019/05/02/esi-injection-part-2-abusing-specific-implementations/.

Example - Tutorial

sudo apt-get install default-jdk
sudo apt-get install libsaxonb-java libsaxon-java

xml.xml:

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
    <cd>
        <title>CD Title</title>
        <artist>The artist</artist>
        <company>Da Company</company>
        <price>10000</price>
        <year>1760</year>
    </cd>
</catalog>

xsl.xsl:

Execute:

Fingerprint

detection.xsl:

And execute:

Read Local File

read.xsl

SSRF

Versions

There might be more or less functions depending on the XSLT version used:

Fingerprint

Upload this and take information

SSRF

Javascript Injection

Directory listing (PHP)

Opendir + readdir

Assert (var_dump + scandir + false)

Read files

Internal - PHP

Internal - XXE

Through HTTP

Internal (PHP-function)

Port scan

Write to a file

XSLT 2.0

Xalan-J extension

Other ways to write files in the PDF

Include external XSL

Execute code

php:function

Execute code using other frameworks in the PDF

More Languages

In this page you can find examples of RCE in other languajes: https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection#C%23%2FVB.NET%2FASP.NET (C#, Java, PHP)

Access PHP static functions from classes

The following function will call the static method stringToUrl of the class XSL:

(Example from http://laurent.bientz.com/Blog/Entry/Item/using_php_functions_in_xsl-7.sls)

More Payloads

Brute-Force Detection List

Auto_Wordlists/xslt.txt at main · carlospolop/Auto_WordlistsGitHub

References

Last updated