Vulnerability GHSA-4whp-jx7j-xvrm

Medium Risk
MEDIUM RISK
CVSS Score: 6.0
Score Range: 4.0–6.9
Medium severity vulnerabilities (CVSS 4.0–6.9). Important issues that meaningfully reduce security confidence.
6 hours ago
December 01, 2026 at 02:24 AM UTC
Hugo highlight wrapperClass option allows stored cross-site scripting
v0.140.2 - v0.169.0
v0.140.2 - v0.169.0

Summary

Hugo highlight wrapperClass option allows stored cross-site scripting

Details

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.

Impacted packages

Timeline

Published
6 hours ago
December 01, 2026 at 02:24 AM UTC
Fixed (v0.170.0)
17 days ago
November 13, 2026 at 02:17 PM UTC
Last Modified
5 hours ago
December 01, 2026 at 02:45 AM UTC