Hugo highlight wrapperClass option allows stored cross-site scripting
GHSA-4whp-jx7j-xvrmPublished 1 Dec 2026, 02:24 UTC
Real-world risk
0.9/ 10Low
Routine
PreliminaryFrom the CVSS vector only · confidence low
CVSS
4.6
scored by GitHub, CVSS 4.0
In plain words
No plain-language summary yet. The original description is below.
Original 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.
Am I affected?
| Product | Affected versions (from the sources) | Fixed in |
|---|---|---|
| github.com/gohugoio/hugoNiche | >= 0.140.2, < 0.170.0 | 0.170.0 |
What to do
Update to a fixed version: 0.170.0.
Why this score
| Factor | Value | Evidence | × |
|---|---|---|---|
| Impact | MinorReflected XSS, CSRF with low effect, open redirect, minor leak | From the CVSS vector | 0.30 |
| Attacker position | LocalMust already run code or have a shell on the machine | From the CVSS vector | 0.50 |
| Privileges needed | NoneNo account | From the CVSS vector | 1.00 |
| Victim interaction | RoutineA normal action: open a file, visit a page, click a link | From the CVSS vector | 0.70 |
| Configuration | DefaultOut-of-the-box installs are vulnerable | From the CVSS vector | 1.00 |
| Reliability | ReliableDeterministic: injection, logic bug, path traversal | From the CVSS vector | 1.00 |
Threat level T1: Nothing known (× 0.85)
The default for a new disclosure
The arithmetic
- Prerequisites multiplied together0.350
- Threat T1: Nothing known0.850
- 10 × impact 0.3 × prerequisites 0.35 × threat 0.850.892
- Rounded to one decimal between 0.1 and 100.9
Exploitation and evidence timeline
- 1 Dec 2026 Published
- 2 Dec 2026 Risk 0.9 (cvss fallback)
Weakness
CWE-79