# GHSA-4WHP-JX7J-XVRM: Hugo highlight wrapperClass option allows stored cross-site scripting

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-12-01
- Modified: 2026-12-01

## Tracked as

- [CVE-2026-140394](https://cve.now/CVE-2026-140394.md): Hugo stored XSS in highlight shortcode wrapperClass

## Affected versions

- github.com/gohugoio/hugo (Go): from 0.140.2, fixed in 0.170.0

## 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

- https://github.com/gohugoio/hugo/security/advisories/GHSA-4whp-jx7j-xvrm
- https://github.com/gohugoio/hugo/pull/15564
- https://github.com/gohugoio/hugo/commit/bdde5aa5155c6c349a743e71dc846bef754b6773
- https://github.com/gohugoio/hugo
- https://github.com/gohugoio/hugo/releases/tag/v0.170.0

Page: https://cve.now/GHSA-4WHP-JX7J-XVRM

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
