Overview
CVE-2026-140394 documents a stored cross-site scripting (XSS) flaw inside Hugo, the popular Go-based static site generator. The vulnerability lies in two related rendering paths — the highlight shortcode and the transform.Highlight template function — used to render syntax-highlighted code blocks in generated pages.
The advisory records an affected range of Hugo versions after 0.140.2 and before 0.170.0. The vendor boundary of 0.170.0 represents the first release in which the issue is fixed. The base CVSS score listed for this entry is 5.4, with a network attack vector.
Affected systems
- Hugo releases after 0.140.2 and before 0.170.0.
- Sites that use the
highlightshortcode or calltransform.Highlightfrom a Hugo template, particularly with a non-default or externally suppliedwrapperClassoption.
- Multi-author sites, projects that import third-party Markdown, or any build pipeline that lets untrusted input reach the highlight rendering.
Root cause
Both the highlight shortcode and the transform.Highlight template function accept a wrapperClass option that is appended to the class attribute of the outer <div> that wraps the highlighted code block. The advisory states that this value is written into the attribute without HTML escaping.
A content author who controls the wrapperClass value can therefore supply text that closes the attribute and appends markup, including a <script> element. When Hugo renders the page, the injected markup is serialized into the generated HTML and served to visitors. The browser then parses and executes the injected script under the site's origin.
Because the payload is persisted in the site's content or templates and replayed on every page load, this is a stored XSS rather than a reflected one. The injection is rendered server-side at build time for static sites, which means the malicious content remains in the published output until the site is rebuilt with sanitized input.
Real-world impact
The capability of injected JavaScript is bounded by whatever the site's origin can do. Typical outcomes for a successful exploit include reading data accessible from that origin (cookies, session storage, or same-origin page content), modifying visible page content, or performing actions that a logged-in visitor could perform. Nothing in the source material indicates that the issue escalates to code execution on the Hugo build host or to compromise of the publishing pipeline itself.
Exploitation requires the ability to set or influence the wrapperClass option of the affected highlight features. On a single-author static site where the content source is fully trusted, the practical exposure is limited. On sites that allow less-trusted contributors, aggregate content from external sources, or render Markdown supplied through community pipelines, the exposure widens meaningfully.
Exploitation status
The provided intelligence does not list CVE-2026-140394 in the CISA KEV catalog and contains no evidence of active exploitation, public proof-of-concept code, or widespread in-the-wild abuse. The decision to upgrade and harden therefore rests on architectural exposure rather than immediate threat activity.
Mitigation
- Upgrade Hugo to 0.170.0 or later, then rebuild and redeploy to flush any previously generated pages that may contain injected markup.
- Until the upgrade lands, restrict or review use of the
highlightshortcode andtransform.Highlightfor content originating from untrusted sources, and validatewrapperClassvalues so they cannot contain characters that break out of an HTML attribute or introduce markup.
- Audit stored content, templates, and configuration for suspicious
wrapperClassvalues, including any that contain quotes, angle brackets, orscriptsubstrings, and inspect generated HTML for unexpected inline script elements near highlighted blocks.
- Where compatible, apply a restrictive Content Security Policy that disallows inline script execution as a defense-in-depth layer; this reduces the impact of stored XSS but does not substitute for patching the renderer.
- For repository-driven static sites, add pre-deployment checks that diff rendered HTML in staging, especially for content affecting highlight-related templates.
Detection guidance
Detection can lean on two signals: the source side and the output side.
- Source side: search templates, Markdown front matter, and content imports for
wrapperClassoccurrences and review them for unexpected characters such as",',>, or<.
- Output side: scan published HTML for
class="segments near syntax-highlighted blocks that contain characters which terminate the attribute, or for inline<script>elements appearing inside what should be a highlight wrapper div.
Reporting and further reading
The full advisory text for this issue is available through the National Vulnerability Database entry linked in the references.