MEDIUM · CVSS 4.0 CWE-79

GHSA-4whp-jx7j-xvrm: Hugo highlight wrapperClass option allows stored cross-site scripting

Published 2026-12-01 · Updated 2026-12-01

Summary

The Hugo highlight shortcode improperly escapes the wrapperClass option, allowing content authors to inject malicious scripts into generated pages. Administrators of multi-author Hugo sites should update to the patched version to prevent stored cross-site scripting (XSS) attacks.

Who is affected

This vulnerability affects sites using Hugo version 0.140.2 up to 0.169.9. It requires a content author with the ability to define highlight shortcode parameters to inject arbitrary HTML or JavaScript, which then executes in the browsers of visitors viewing the rendered content.

Exploitability

The vulnerability is rated as Medium severity. It requires user interaction and local access or authoring privileges, and is not currently listed in the CISA Known Exploited Vulnerabilities catalog.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-12-01. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
Go github.com/gohugoio/hugo >= 0.140.2, < 0.170.0 0.170.0 go get github.com/gohugoio/[email protected]

CVSS 4.0 vector

CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N

Attack vectorLocal
Attack complexityLow
Attack requirementsNone
Privileges requiredNone
User interactionActive
Confidentiality (vulnerable system)None
Integrity (vulnerable system)Low
Availability (vulnerable system)None
Confidentiality (subsequent systems)Low
Integrity (subsequent systems)Low
Availability (subsequent systems)None

Base score is not computed for CVSS 4.0 vectors; severity is taken from the advisory.

FAQ

Does this affect standard Markdown code fences?

No, the vulnerability is specific to the 'highlight' shortcode and the 'transform.Highlight' template function, not Markdown code fences.

Does disabling the Goldmark 'unsafe' setting mitigate this?

No, the 'wrapperClass' value does not pass through the Markdown HTML renderer, meaning the Goldmark 'unsafe' setting provides no protection against this specific flaw.

Is this vulnerability being actively exploited in the wild?

There is no documentation or CISA KEV data to suggest active exploitation at this time.

Original advisory description
### 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

Source records: GHSA-4whp-jx7j-xvrm (OSV.dev).