MediumGHSA-4whp-jx7j-xvrmCVE-2026-140394

Hugo highlight wrapperClass option allows stored cross-site scripting

Published 1 Dec 2026 · Updated 1 Dec 2026

Affected package

Affected
>=0.140.2 <0.170.0
Fixed in
0.170.0
Update to the fixed version for your release line, for example:go get github.com/gohugoio/hugo@v0.170.0

We confirm your address first. See our privacy policy.

Which github.com/gohugoio/hugo does your project really install?

Drop your go.mod hereWe find the exact github.com/gohugoio/hugo version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

Works for private projects: the file is read in memory to run the scan and then dropped. Also reads other package files.

Public repo?

Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

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.

Is GHSA-4whp-jx7j-xvrm in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/gohugoio/hugo, and gives you the command that fixes it.

More advisories for github.com/gohugoio/hugo

  • MediumCVE-2026-140395Hugo: Build-host file disclosure through path traversal in vendored module metadata · 1 Dec 2026
  • MediumGHSA-r73q-gwx2-fpxmHugo theme-defined module replacements bypass mount restrictions and widen the Node.js read sandbox · 30 Nov 2026
  • LowCVE-2026-58403Hugo: Symlink confinement bypass in os.ReadFile in github.com/gohugoio/hugo · 24 Jul 2026
  • LowCVE-2026-58402Hugo: XSS via unescaped code-fence language in default code block renderer in github.com/gohugoio/hugo · 24 Jul 2026
  • LowCVE-2026-58404Hugo: security.http.urls deny rules bypassed by alternate IPv4 encodings (SSRF) in github.com/gohugoio/hugo · 24 Jul 2026
  • LowCVE-2026-44301Hugo's Node tool execution allows file system access outside the project directory in github.com/gohugoio/hugo · 24 Jul 2026
All 24 advisories for github.com/gohugoio/hugo

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.