Skip to main content
HighClient-sideOWASP A03:2021CWE-79

How to fix: Vue v-html Directive with Dynamic Content

The Vue v-html directive was found in the page with a dynamic binding. v-html renders raw HTML without Vue's template escaping, creating XSS risk if the bound value includes any user-controlled content.

Why it matters

v-html bypasses Vue's HTML escaping. If the bound variable contains user-generated content, the browser will render it as HTML, executing any injected script tags, event handlers, or javascript: URLs.

Vue's template system escapes HTML by default: {{ userContent }} is always rendered as text. v-html explicitly renders HTML, which is safe only for fully trusted content (e.g., pre-sanitized CMS content).

How to fix it

  1. 1Avoid v-html with user-generated content.
  2. 2If HTML rendering is needed, sanitize with DOMPurify before binding: :v-html='sanitize(content)'.
  3. 3Prefer {{ content }} (text interpolation) which always escapes HTML.
  4. 4Consider a component-based rich text renderer instead of raw HTML.

Code examples

Safe v-html with DOMPurify

HTML
<!-- Bad -->
<div v-html="userContent"></div>

<!-- Good -->
<div v-html="sanitized(userContent)"></div>

<!-- In script -->
import DOMPurify from 'dompurify';
const sanitized = (html) => DOMPurify.sanitize(html);

References

Detected automatically by VulnRadar. The check id is vue-v-html-directive, stable across every scan so you can filter or diff on it.

See every client-side check

Questions

How severe is Vue v-html Directive with Dynamic Content?
VulnRadar rates this high severity in the client-side category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id vue-v-html-directive, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Vue v-html Directive with Dynamic Content map to?
It maps to CWE-79. In the OWASP Top 10 it falls under A03:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for vue v-html directive with dynamic content

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Vue v-html Directive with Dynamic Content fix | VulnRadar