GHSA-ff38-p3qj-4pmf: Astro: XSS via unescaped code for unsupported languages in @astrojs/prism
Astro is a web framework for content-driven websites. Prior to @astrojs/prism 4.1.2, and from @astrojs/markdoc 0.3.0 until 2.1.2, runHighlighterWithAstro() returned code unchanged when Prism had no grammar for the requested language, and callers inserted that result as raw HTML. A code block labeled with an unsupported language could therefore render embedded HTML and script instead of displaying it as text. The Prism component was affected when applications supplied untrusted code with an unsupported or attacker-controlled lang, and the @astrojs/markdoc prism() extension was affected for less-trusted content authors even when Markdoc's ordinary HTML rendering was disabled. This issue is fixed in @astrojs/prism 4.1.2 and @astrojs/markdoc 2.1.2.
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/@astrojs/prismto a version that resolves this vulnerability.Fixed in 4.1.2 - Upgrade
Upgrade
npm/@astrojs/markdocto a version that resolves this vulnerability.Fixed in 2.1.2
Event History
Frequently Asked Questions
Which uses are exposed to this issue?
The @astrojs/prism Prism component is affected when an application passes untrusted code together with an unsupported or attacker-controlled language value. The @astrojs/markdoc prism() extension is affected when less-trusted content authors can provide code blocks, including where ordinary Markdoc HTML rendering is disabled.
What input is required to trigger the cross-site scripting behavior?
An attacker needs a code block whose language has no Prism grammar and whose code contains HTML or script content. The unsupported-language path returns the code unchanged, and raw-HTML insertion causes it to render rather than display as text.
What versions contain the fix?
Upgrade @astrojs/prism to 4.1.2 or later. Upgrade @astrojs/markdoc to 2.1.2 or later; affected Markdoc versions begin at 0.3.0.