CVE-2026-140394: Hugo 0.140.2 before 0.170.0 Stored XSS via highlight shortcode wrapperClass
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 Software
Event History
Frequently Asked Questions
Who can exploit this issue?
An attacker needs the ability to author or modify Hugo content that uses the highlight shortcode or the transform.Highlight template function and can set its wrapperClass option. The resulting JavaScript executes in the browsers of visitors viewing the generated affected content.
Which Hugo versions are affected?
The affected range is after Hugo 0.140.2 and before 0.170.0. Hugo 0.170.0 is outside the stated affected range.
What can be done if upgrading is not immediately possible?
Restrict who can create or modify Hugo content and templates, and do not allow untrusted authors to set wrapperClass values. Review existing uses of the highlight shortcode and transform.Highlight for wrapperClass input that may contain attribute-breaking characters or markup.
How can I determine whether a site may already contain an exploit payload?
Search content and templates for highlight shortcode or transform.Highlight usage with the wrapperClass option. A suspicious value may attempt to close the HTML class attribute and add markup such as a script element.