Vue · VUE0009

Restrict v-html to trusted HTML

Traces the HTML bound to v-html and flags it when it comes from the route, a request, storage, or a v-model input.
VUE0009vite-doctor/vuesecurityerrorNo fix

Run this rule

pnpm vite-doctor . --framework vue --rules vue/security/restrict-v-html

Why it matters

v-html sets innerHTML without escaping, so markup in a value a visitor can shape runs as script in the page. Doctor follows the value through refs, computed values, props, and the local modules and Nuxt auto-imports its functions come from. It reports route, request, cookie, storage, fetched, and v-model values as errors, and HTML whose source it cannot trace, such as a prop, as a low-confidence warning. Shiki and uqr output, DOMPurify, sanitize-html and xss output, and string literals pass. Markdown rendered by marked or HTML-enabled markdown-it is as trusted as its input. Ordinary markdown-it instances with raw HTML disabled pass; customized or unresolved renderers produce a warning.

Render untrusted values as text, or sanitize them with DOMPurify.sanitize() or sanitize-html before binding them to v-html.

Example

Sanitize HTML from the route

Before

<script setup lang="ts">
const route = useRoute()
</script>

<template>
  <div v-html="route.query.bio" />
</template>

After

<script setup lang="ts">
import DOMPurify from "dompurify"
const route = useRoute()
const bio = computed(() => DOMPurify.sanitize(String(route.query.bio ?? "")))
</script>

<template>
  <div v-html="bio" />
</template>
Copyright © 2026