Skip to content

github.com/gohugoio/hugo

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?

ProductAffected versions (from the sources)Fixed in
github.com/gohugoio/hugoNiche>= 0.140.2, < 0.170.00.170.0

What to do

Update to a fixed version: 0.170.0.

Why this score

FactorValueEvidence×
ImpactMinorReflected XSS, CSRF with low effect, open redirect, minor leakFrom the CVSS vector0.30
Attacker positionLocalMust already run code or have a shell on the machineFrom the CVSS vector0.50
Privileges neededNoneNo accountFrom the CVSS vector1.00
Victim interactionRoutineA normal action: open a file, visit a page, click a linkFrom the CVSS vector0.70
ConfigurationDefaultOut-of-the-box installs are vulnerableFrom the CVSS vector1.00
ReliabilityReliableDeterministic: injection, logic bug, path traversalFrom the CVSS vector1.00

Threat level T1: Nothing known (× 0.85)

The default for a new disclosure

The arithmetic
  1. Prerequisites multiplied together0.350
  2. Threat T1: Nothing known0.850
  3. 10 × impact 0.3 × prerequisites 0.35 × threat 0.850.892
  4. Rounded to one decimal between 0.1 and 100.9

How the score works

Exploitation and evidence timeline

  1. 1 Dec 2026 Published
  2. 2 Dec 2026 Risk 0.9 (cvss fallback)

Weakness

CWE-79

References

Get alerts for github.com/gohugoio/hugo

Free email or text alerts when a vulnerability in github.com/gohugoio/hugo reaches risk 8 or higher. Nothing else.

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