Stored cross-site scripting in Hugo highlight wrapperClass option
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- Active
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- Cross-site scripting
- Confidentiality · integrity · availability
- None · Low · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · GHSA-4whp-jx7j-xvrm. Fix status from GitHub. Impact type from CWE-79.
Summary
The wrapperClass option of the built-in highlight shortcode and the transform.Highlight template function is written into the page without HTML escaping, which is an improper neutralization of input during web page generation (CWE-79). A content author on a site with multiple authors can inject HTML and JavaScript that runs in visitors' browsers under the site's origin. The highlight shortcode is built in and enabled by default.
Written with Claude Haiku 5.5 from the sources below · 2026-12-01
Description from the GitHub advisory
### 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.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | github.com/gohugoio/hugo (Go) | 0.140.2 to before 0.170.0 | 0.170.0 | Patch available | GHSA-4whp-jx7j-xvrm |
- github.com/gohugoio/hugo (Go) Vendor— Affected 0.140.2 to before 0.170.0 Fixed in 0.170.0 Patch available GHSA-4whp-jx7j-xvrm
Remediation
Upgrade github.com/gohugoio/hugo (Go) to version 0.170.0, which fixes the flaw. Versions from 0.140.2 before 0.170.0 are affected.
Written with Claude Haiku 5.5 from the sources below · 2026-12-01
- Fix · GHSA-4whp-jx7j-xvrm github.com/gohugoio/hugo (Go) Fixed in 0.170.0 Advisory →
Timeline
- 2026-12-01 Threatist record created from GHSA-4whp-jx7j-xvrm
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences