--- title: "Security and Sanitization in Vue 3" description: "See which unsafe markup the Vue 3 editor sanitizer removes, why v-model HTML must be sanitized again on the server, and how to render it with v-html." head: - - meta - name: robots content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' - - meta - name: googlebot content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' - - meta - name: bingbot content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' --- # Security and HTML Sanitization in Vue 3 `@erag/text-editor-vue` runs a browser-side allowlist sanitizer, built on `DOMParser` and `TreeWalker`, over content before it is inserted into the editor or shown in preview. It strips common unsafe markup, but it is not a complete XSS boundary, so HTML submitted from a Vue form bound with `v-model` must be sanitized again on the server. --- ## Built-in Sanitization Mechanics The internal sanitizer inspects HTML strings before inserting, previewing, or exporting content: - โŒ **Script Stripping**: Removes ` ``` `sanitizeHtml` returns an empty string when DOM APIs are not available, such as during server-side rendering, so keep server-side sanitization in place. See [media and embeds](./media-and-embeds.html) for iframe rules. --- ## Content Security Policy (CSP) For maximum protection against XSS vulnerabilities, enforce a strict Content Security Policy (CSP) header in your web application: ```http Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; ```