Home/Research/Post

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

  • Severity: MEDIUM
  • Ecosystems: go
  • Packages: github.com/gohugoio/hugo

### Summary

The `wrapperClass` option of the built-in `highlight` shortcode (and the `transform.Highlight` template function) was written unescaped into the wrapping “, 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 “ 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.

Source: GitHub Security Advisories · 2026-12-01