CVE-2026-140394
JSON

5.1medium

Hugo 0.140.2 before 0.170.0 Stored XSS via highlight shortcode wrapperClass

Severity
5.1medium CVSS:4.0 by VulnCheck
Published
Last changed
Assigned by
VulnCheck
Also known as
GHSA-4whp-jx7j-xvrm

Description

Hugo after 0.140.2 and before 0.170.0 contains a stored cross-site scripting vulnerability in the highlight shortcode and transform.Highlight template function, which write the wrapperClass option unescaped into the wrapping div's class attribute. Content authors can supply a wrapperClass value that closes the attribute and appends a script element, executing JavaScript in visitors' browsers under the site's origin.

Affected

Product or packageVersionsReported by
gohugoio hugofrom 0.140.2 before 0.170.0
Not affected: 0.170.0
CVE List
github.com/gohugoio/hugo (Go)from 0.140.2 before 0.170.0GitHub Advisory Database

All scores

VulnCheck5.1medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
VulnCheck5.4medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N

Classification

CWE-79

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

Hugo after 0.140.2 and before 0.170.0 contains a stored cross-site scripting vulnerability in the highlight shortcode and transform.Highlight template function, which write the wrapperClass option unescaped into the wrapping div's class attribute. Content authors can supply a wrapperClass value that closes the attribute and appends a script element, executing JavaScript in visitors' browsers under the site's origin.

GitHub Advisory Database
Summary

The wrapperClass option of the built-in highlight shortcode (and the transform.Highlight template function) was written unescaped into the wrapping <div class="...">, allowing a content author to inject arbitrary HTML/JavaScript into the rendered page.

Details

markup/highlight/highlight.go (writeDivStart) wrote wrapperClass directly between class=" and ", while all other attribute values were HTML-escaped. Because the shortcode's options string is decoded into the highlight config, any content author can set wrapperClass. The Goldmark unsafe setting does not apply, as the value never passes through the Markdown HTML renderer. Markdown code fences are not affected.

Fixed by HTML-escaping the value.

Proof of concept

A content author on a multi-author site adds a highlight shortcode to a page with a wrapperClass option value that closes the class attribute and appends a <script> element. When the site is built, the script ends up in the page body and runs in visitors' browsers under the site's origin.

Impact

Stored XSS for sites that render content from less-trusted authors. The highlight shortcode is built in and enabled by default.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-140394 changed 2026-12-01CVE Terms of Use
GitHub Advisory DatabaseGHSA-4whp-jx7j-xvrm changed 2026-12-01CC-BY-4.0
NVDCVE-2026-140394 changed 2026-12-01Public domain