# XSLT Server Side Injection (Extensible Stylesheet Languaje Transformations) {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** ๐Ÿ’ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐Ÿฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %} ## Basic Information XSLT๋Š” XML ๋ฌธ์„œ๋ฅผ ๋‹ค์–‘ํ•œ ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค. ๋ฒ„์ „ 1, 2, 3์ด ์žˆ์œผ๋ฉฐ, ๋ฒ„์ „ 1์ด ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋ณ€ํ™˜ ๊ณผ์ •์€ ์„œ๋ฒ„ ๋˜๋Š” ๋ธŒ๋ผ์šฐ์ € ๋‚ด์—์„œ ์‹คํ–‰๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ€์žฅ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: - **Gnome์˜ Libxslt**, - **Apache์˜ Xalan**, - **Saxonica์˜ Saxon**. XSLT์™€ ๊ด€๋ จ๋œ ์ทจ์•ฝ์ ์„ ์•…์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” xsl ํƒœ๊ทธ๊ฐ€ ์„œ๋ฒ„ ์ธก์— ์ €์žฅ๋˜์–ด์•ผ ํ•˜๋ฉฐ, ๊ทธ ์ฝ˜ํ…์ธ ์— ์ ‘๊ทผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ทจ์•ฝ์ ์˜ ์˜ˆ์‹œ๋Š” ๋‹ค์Œ ์ถœ์ฒ˜์— ๋ฌธ์„œํ™”๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค: [https://www.gosecure.net/blog/2019/05/02/esi-injection-part-2-abusing-specific-implementations/](https://www.gosecure.net/blog/2019/05/02/esi-injection-part-2-abusing-specific-implementations/). ## Example - Tutorial ```bash sudo apt-get install default-jdk sudo apt-get install libsaxonb-java libsaxon-java ``` {% code title="xml.xml" %} ```xml CD Title The artist Da Company 10000 1760 ``` {% endcode %} {% code title="xsl.xsl" %} ```xml

The Super title

Title artist
``` {% endcode %} ์‹คํ–‰: ```xml saxonb-xslt -xsl:xsl.xsl xml.xml Warning: at xsl:stylesheet on line 2 column 80 of xsl.xsl: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor

The Super title

Title artist
CD Title The artist
``` ### ์ง€๋ฌธ {% code title="detection.xsl" %} ```xml Version:
Vendor:
Vendor URL:
Product Name:
Product Version:
Is Schema Aware ?:
Supports Serialization:
Supports Backwards Compatibility:
``` {% endcode %} ๊ทธ๋ฆฌ๊ณ  ์‹คํ–‰ํ•˜์‹ญ์‹œ์˜ค ```xml $saxonb-xslt -xsl:detection.xsl xml.xml Warning: at xsl:stylesheet on line 2 column 80 of detection.xsl: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor

XSLT identification

Version:2.0
Vendor:SAXON 9.1.0.8 from Saxonica
Vendor URL:http://www.saxonica.com/
``` ### ๋กœ์ปฌ ํŒŒ์ผ ์ฝ๊ธฐ {% code title="read.xsl" %} ```xml ``` {% endcode %} ```xml $ saxonb-xslt -xsl:read.xsl xml.xml Warning: at xsl:stylesheet on line 1 column 111 of read.xsl: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin ``` ### SSRF ```xml ``` ### Versions ์‚ฌ์šฉ๋œ XSLT ๋ฒ„์ „์— ๋”ฐ๋ผ ๋” ๋งŽ๊ฑฐ๋‚˜ ์ ์€ ๊ธฐ๋Šฅ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: * [https://www.w3.org/TR/xslt-10/](https://www.w3.org/TR/xslt-10/) * [https://www.w3.org/TR/xslt20/](https://www.w3.org/TR/xslt20/) * [https://www.w3.org/TR/xslt-30/](https://www.w3.org/TR/xslt-30/) ## Fingerprint ์ด ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•˜๊ณ  ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค. ```xml Version:
Vendor:
Vendor URL:
Product Name:
Product Version:
Is Schema Aware ?:
Supports Serialization:
Supports Backwards Compatibility:
``` ## SSRF ```xml ``` ## ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฃผ์ž… ```xml ``` ## ๋””๋ ‰ํ† ๋ฆฌ ๋ชฉ๋ก (PHP) ### **Opendir + readdir** ```xml - - - - - - - - - ``` ### **Assert (var\_dump + scandir + false)** ```xml
``` ## ํŒŒ์ผ ์ฝ๊ธฐ ### **๋‚ด๋ถ€ - PHP** ```xml ``` ### **๋‚ด๋ถ€ - XXE** ```xml ]> &ext_file; ``` ### **HTTP๋ฅผ ํ†ตํ•œ** ```xml ``` ```xml ]> &passwd; ``` ### **๋‚ด๋ถ€ (PHP-ํ•จ์ˆ˜)** ```xml ``` ```xml
``` ### ํฌํŠธ ์Šค์บ” ```xml ``` ## ํŒŒ์ผ์— ์“ฐ๊ธฐ ### XSLT 2.0 ```xml Write Local File ``` ### **Xalan-J ํ™•์žฅ** ```xml Write Local File ``` ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์œผ๋กœ PDF์— ํŒŒ์ผ ์“ฐ๊ธฐ ## ์™ธ๋ถ€ XSL ํฌํ•จ ```xml ``` ```xml ``` ## ์ฝ”๋“œ ์‹คํ–‰ ### **php:function** ```xml ``` ```xml
``` Execute code using other frameworks in the PDF ### **๋” ๋งŽ์€ ์–ธ์–ด๋“ค** **์ด ํŽ˜์ด์ง€์—์„œ๋Š” ๋‹ค๋ฅธ ์–ธ์–ด์—์„œ์˜ RCE ์˜ˆ์ œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:** [**https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt\_injection#C%23%2FVB.NET%2FASP.NET**](https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt\_injection#C%23%2FVB.NET%2FASP.NET) **(C#, Java, PHP)** ## **ํด๋ž˜์Šค์—์„œ PHP ์ •์  ํ•จ์ˆ˜์— ์ ‘๊ทผํ•˜๊ธฐ** ๋‹ค์Œ ํ•จ์ˆ˜๋Š” ํด๋ž˜์Šค XSL์˜ ์ •์  ๋ฉ”์„œ๋“œ `stringToUrl`์„ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค: ```xml ``` (Example from [http://laurent.bientz.com/Blog/Entry/Item/using\_php\_functions\_in\_xsl-7.sls](http://laurent.bientz.com/Blog/Entry/Item/using\_php\_functions\_in\_xsl-7.sls)) ## More Payloads * Check [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSLT%20Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSLT%20Injection) * Check [https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection](https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.xslt_injection) ## **Brute-Force Detection List** {% embed url="https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/xslt.txt" %} ## **References** * [XSLT\_SSRF](https://feelsec.info/wp-content/uploads/2018/11/XSLT\_SSRF.pdf)\\ * [http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20IO%20Active.pdf](http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20IO%20Active.pdf)\\ * [http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20Blackhat%202015.pdf](http://repository.root-me.org/Exploitation%20-%20Web/EN%20-%20Abusing%20XSLT%20for%20practical%20attacks%20-%20Arnaboldi%20-%20Blackhat%202015.pdf) {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** ๐Ÿ’ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐Ÿฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}