sanitizeTranslatedHtml bypass via unterminated attribute values
Description
When escapeParameter is enabled (escapeParameterHtml in the Legacy API), Vue I18n passes the translated string through sanitizeTranslatedHtml(). The sanitizer disables javascript: URLs by rewriting them to about:blank — but only for attributes it can recognize. Both recognition passes require a well-formed attribute: the quoted pass needs the closing quote inside the message, and the unquoted pass rejects any value that starts with a quote character. A message that opens an attribute value and never closes it therefore keeps its javascript: URL verbatim.
The HTML tokenizer, however, does not stop at the end of the message. In server-side rendering the unterminated attribute value continues into the rest of the page and closes at the next " in the application's own markup; the element is then emitted with the attacker's javascript: URL as its src/href. A // inside the URL comments out the swallowed page content, so the executed script is exactly attacker-controlled. An <iframe src="javascript:..."> runs without any user interaction, in the origin of the application.
Affected component
sanitizeTranslatedHtml()inpackages/shared/src/sanitize.ts- quoted-attribute pass:
packages/shared/src/sanitize.tsL139-148 (/([\w:-]+)\s*=\s*"([^"]*)"/grequires a closing quote) - unquoted-attribute pass:
packages/shared/src/sanitize.tsL186-189 (value class[^\s"'=<>]+cannot match a value starting with"`) - Sanitization is applied to every translation result when
escapeParameteris on:packages/core-base/src/translate.tsL715-717. - Verified against the released sanitizer at v11.4.18 (the version that fixed GHSA-jrxq-gc2q-9357) and master v12.0.0-alpha.9 (c528b8d) — the relevant regexes are identical in both.
- Affected packages:
vue-i18n,petite-vue-i18n,@intlify/core-base,@intlify/core,@intlify/vue-i18n-core,@intlify/shared(same versions as GHSA-jrxq-gc2q-9357). - Not affected: client-side-only rendering (
innerHTMLof a lone message string drops the unterminated tag token at EOF — verified with parse5), and<i18n-t>(does not render translations as HTML).
PoC
Message (attacker-controlled translation, escapeParameter: true):
<iframe src="javascript:alert(document.domain)//No closing quote. sanitizeTranslatedHtml() returns the string byte-identical (verified with an exact replica of the released code for v11.4.18 and v12.0.0-alpha.9):
import { createSSRApp, h } from 'vue'
import { renderToString } from 'vue/server-renderer'
import { createI18n } from 'vue-i18n'
const i18n = createI18n({
legacy: false,
locale: 'en',
escapeParameter: true,
messages: { en: { hello: '<iframe src="javascript:alert(document.domain)//' } }
})
const app = createSSRApp({
render: () => h('div', { innerHTML: i18n.global.t('hello') })
})
app.use(i18n)
console.log(await renderToString(app))
// the iframe start tag is still unterminated; the server continues writing the pageOn the server, the rest of the page (footer, class="...", scripts) follows. In a browser, the tokenizer keeps src open across the page boundary and closes it at the next "; the element is emitted with src="javascript:alert(document.domain)//</div><footer class=" and the // comments out the swallowed content — alert(document.domain) runs in the application origin when the iframe loads, with no user interaction. Verified with parse5 (spec-compliant HTML parser):
PAGE PARSE: div -> {id="app"}
iframe -> {src="javascript:alert(document.domain)//</div><foo", footer"=""}The click-required variant is <a href="javascript:alert(document.domain)// (same mechanism, anchor emitted with the javascript: URL).
Note: the srcdoc and event-handler neutralizations are string-wide and DO apply to unterminated values (an unterminated <iframe srcdoc="<img src=x onerror=alert(1)// gets its inner onerror neutralized to onerror, and character references are not decoded in attribute names per WHATWG §13.2.5.32), so the javascript:-URL attribute is the surviving vector.
Impact
Applications that enable escapeParameter, render translations as HTML on the server (v-html/innerHTML in SSR, Nuxt, pre-rendered pages), and contain message content that is not fully trusted (crowdsourced or stored translations) are affected. An attacker who can change such a message runs script in the origin of the application for every visitor of a page that shows the message (stored XSS), without any user interaction, despite the sanitizer — the exact impact model of GHSA-jrxq-gc2q-9357.
Suggested CVSS 3.1
7.2 — CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N (same vector as GHSA-jrxq-gc2q-9357)
Suggested fix
Detect unterminated attribute values at the end of sanitization and neutralize them, e.g. escape the < of any start tag whose quoted attribute value is still open at end of string (/<(?=[^<]*=[^"]*"(?:[^"]*)*$)/-class detection, or track quote parity while scanning), so the element degrades to text exactly like the <script>/<base>/<animate>/<set> neutralization. A robust alternative is to tokenize with a spec-compliant HTML tokenizer and re-serialize instead of regex passes. Add test cases for unclosed " and ' attribute values in packages/shared/test/sanitize.test.ts (58 existing cases, none cover unterminated values).
Dedup
- Not any of the 9 published advisories. GHSA-jrxq-gc2q-9357 (SSR
<script>), GHSA-473g-cvf6-mfxj (xlink:href/animate/set), GHSA-83rm-6c8r-g728 (srcdoc) are element/attribute-name specific; this is a value-shape (unterminated attribute) bypass with a distinct root cause. - The private-security fork merges b27a50e (Nov 1 → 11.4.17) and a66ace0 (Nov 3 → 11.4.18) did not modify the quoted- or unquoted-attribute URL passes; their diffs are fully accounted for by the two published advisories.
- Distinct from GHSA-8rc2-428q-7ww3 (escaping gap in
escapeParams), CVE-2025-53892 (pre-sanitizer era), and the prototype-pollution advisories.
Patches
Fixed in vue-i18n 11.4.19 and 12.0.0-alpha.10, and in the same versions of petite-vue-i18n, @intlify/core-base, @intlify/core, @intlify/vue-i18n-core and @intlify/shared.
sanitizeTranslatedHtml() now reads tags and attributes with the rules of the HTML tokenizer, so that it agrees with browsers on where each attribute starts and ends, and it checks every attribute of every start tag. A tag, a comment, or an element like <textarea> that is not closed at the end of a translation is turned into text, so that it cannot take in the rest of the page when the HTML is rendered on the server.
v9 and v10 are not supported, and do not get a fix.
Workarounds
Do not render translation messages from untrusted sources with v-html, even with escapeParameter enabled. Use Component interpolation instead.
References
- GHSA-7356-3q55-jvxm, which is fixed by the same change
- HTML Message - Using the escape parameter option
Affected versions
- vue-i18n9.14.5
- vue-i18n10.0.8
- vue-i18nFrom 11.1.10 · fixed in 11.4.19
- vue-i18nFrom 12.0.0-alpha.4 · fixed in 12.0.0-alpha.10
- petite-vue-i18n9.14.5
- petite-vue-i18n10.0.8
- petite-vue-i18nFrom 11.1.10 · fixed in 11.4.19
- petite-vue-i18nFrom 12.0.0-alpha.4 · fixed in 12.0.0-alpha.10
- @intlify/core-base9.14.5
- @intlify/core-base10.0.8
- @intlify/core-baseFrom 11.1.10 · fixed in 11.4.19
- @intlify/core-baseFrom 12.0.0-alpha.4 · fixed in 12.0.0-alpha.10
- @intlify/core9.14.5
- @intlify/core10.0.8
- @intlify/coreFrom 11.1.10 · fixed in 11.4.19
- @intlify/coreFrom 12.0.0-alpha.4 · fixed in 12.0.0-alpha.10
- @intlify/vue-i18n-core9.14.5
- @intlify/vue-i18n-core10.0.8
- @intlify/vue-i18n-coreFrom 11.1.10 · fixed in 11.4.19
- @intlify/vue-i18n-coreFrom 12.0.0-alpha.4 · fixed in 12.0.0-alpha.10
- @intlify/shared9.14.5
- @intlify/shared10.0.8
- @intlify/sharedFrom 11.1.10 · fixed in 11.4.19
- @intlify/sharedFrom 12.0.0-alpha.4 · fixed in 12.0.0-alpha.10