---
title: Never Use v-html with User-Provided Content
impact: HIGH
impactDescription: Using v-html with untrusted content leads to XSS vulnerabilities
type: capability
tags: [vue3, security, xss, v-html, template]
---
# Never Use v-html with User-Provided Content
**Impact: HIGH** - Dynamically rendering arbitrary HTML with `v-html` can lead to Cross-Site Scripting (XSS) vulnerabilities. Attackers can inject malicious scripts that execute in users' browsers, stealing credentials or performing actions on their behalf.
The `v-html` directive renders raw HTML without sanitization. While useful for trusted content, it bypasses Vue's automatic text escaping and should never be used with user input.
## Task Checklist
- [ ] Never use `v-html` with user-provided content
- [ ] Prefer text interpolation `{{ }}` which automatically escapes HTML
- [ ] Use components for template composition instead of `v-html`
- [ ] If raw HTML is absolutely needed, sanitize it with a library like DOMPurify
- [ ] Audit existing `v-html` usage for potential XSS vectors
**Incorrect:**
```vue
const userComment = ref(props.comment)
```
**Correct:**
```vue