--- title: "Vue.js" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/vuejs.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/vuejs.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # Vue.js ## XSS Sinks in Vue.js ### v-html Directive The `v-html` directive renders **raw** HTML. ` ``` ### v-bind with src or href Binding a user string to URL-bearing attributes (`href`, `src`, `xlink:href`, `formaction` …) lets payloads such as `javascript:alert(1)` run when the link is followed.[[2]](#references)[[3]](#references) ```html
Click me
``` ### v-on with user-controlled handlers If an attacker controls a Vue **template**, directive expressions such as `v-on:click="..."` become code in the compiled render function. Merely storing the string `alert(1)` in a data property does not execute it as JavaScript; the dangerous condition is untrusted template source.[[3]](#references) ```html
``` ### Dynamic attribute / event names User-supplied names in `v-bind:[attr]` or `v-on:[event]` expand the attack surface and can bypass application allowlists. Vue applies its own attribute/event handling and CSP still applies, so validate behavior against the deployed Vue version rather than assuming every `on*` name becomes a native handler.[[3]](#references) ```html ``` ### SSR attribute-name splitting in object `v-bind` When auditing SSR, test the **keys** of objects spread with `v-bind="attrs"`, not only their values. `@vue/server-renderer` through 3.5.41 checked dynamic attribute names against a blacklist that omitted carriage return (`U+000D`). A raw CR in an attacker-controlled key therefore reached the HTML response; the browser normalised it to LF and split one intended name into several attributes. This can create a zero-interaction XSS when an object from a CMS, form builder, API or stored JSON is spread onto an element. The published advisory listed no patched version at publication time.[[9]](#references) ```javascript // Reaches during SSR const attrs = { ['x\rautofocus\ronfocus']: 'alert(document.domain)' } // Browser parses: x="" autofocus="" onfocus="alert(document.domain)" ``` This is an **SSR-only** parser differential: client-side Vue uses `setAttribute()`, which rejects such a name. Send the key through the real input path (for example, JSON `"x\rautofocus\ronfocus"`), inspect the raw response bytes before hydration, and verify whether intermediaries preserve the CR. A source-code review should trace both property names and values into `v-bind="object"` or equivalent render-function props.[[9]](#references) ### Dynamic component (``) Allowing an untrusted component identifier in `:is` may expose components that were not intended for the user. A string containing `