CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-4WHP-JX7J-XVRM

GHSA-4whp-jx7j-xvrm: Stored Cross-Site Scripting in Hugo Syntax Highlighter via wrapperClass

Alon Barad
Alon Barad
Software Engineer

Dec 1, 2026·9 min read·4 visits

Executive Summary (TL;DR)

Hugo versions 0.140.2 through 0.169.x fail to escape the `wrapperClass` attribute during syntax highlighting, enabling stored XSS via the `highlight` shortcode, Markdown code fences, or the `transform.Highlight` template function. Upgrade to Hugo v0.170.0 to remediate.

A stored Cross-Site Scripting (XSS) vulnerability in the Hugo static site generator (versions 0.140.2 prior to 0.170.0) allows content authors to inject arbitrary HTML and JavaScript into generated pages. The flaw resides in the syntax highlighting component (`markup/highlight/highlight.go`), where the `wrapperClass` option is concatenated directly into an HTML `<div class="...">` attribute without HTML entity escaping. Because shortcodes and code fence attributes bypass Goldmark's raw HTML sanitization rules, untrusted contributors in multi-author workflows can achieve client-side script execution in the browsers of site visitors.

Vulnerability Overview

Hugo is an open-source static site generator written in Go (github.com/gohugoio/hugo). It compiles Markdown content, HTML templates, and configuration assets into static HTML files for web deployment. In many deployment architectures—such as public documentation portals, headless Content Management System (CMS) pipelines, and multi-author blogs—Hugo processes Markdown files authored by semi-trusted or untrusted contributors.

To secure multi-author environments against script injection, Hugo uses the Goldmark Markdown parser with raw HTML rendering disabled by default (markup.goldmark.renderer.unsafe = false). This configuration strips inline HTML tags and script elements from standard Markdown body text during compilation. However, Hugo also provides native syntax highlighting powered by the Chroma library (markup/highlight), which operates outside the standard Goldmark text sanitization pass.

Tracked as GHSA-4whp-jx7j-xvrm, a stored Cross-Site Scripting (XSS) vulnerability (CWE-79 / CWE-116) exists in Hugo versions 0.140.2 up to 0.170.0. The vulnerability resides in the writeDivStart function within markup/highlight/highlight.go, which constructs the outer HTML container for syntax-highlighted code blocks.

When generating the wrapping <div class="..."> element, the renderer writes the user-configurable wrapperClass parameter directly into the output stream without HTML entity encoding. An attacker who can submit or modify Markdown content or page front matter can supply a crafted wrapperClass value containing double-quote and angle-bracket characters, breaking out of the class attribute context and injecting arbitrary HTML and JavaScript into the compiled static site.

Root Cause Analysis

Hugo integrates the Chroma syntax highlighter through its internal markup/highlight package. When rendering a highlighted code block, Hugo wraps the generated <pre><code>...</code></pre> structure inside a container <div> element. By default, this container uses the CSS class highlight, but users and templates can override or append to this class name using the wrapperClass configuration option.

The root cause of GHSA-4whp-jx7j-xvrm is an improper output encoding flaw (CWE-116) in markup/highlight/highlight.go inside the writeDivStart helper function. This function accepts a hugio.FlexiWriter, a slice of structured attributes ([]attributes.Attribute), and the wrapperClass string. To construct the opening tag, the function writes the literal string <div class=" to the buffer and immediately appends the raw wrapperClass string via w.WriteString(wrapperClass).

While additional attributes passed in the attrs slice undergo structured iteration and handling, wrapperClass is treated as a trusted constant despite being populated directly from content-level arguments. Because w.WriteString performs no character substitution, any double quote (") present in wrapperClass prematurely closes the class attribute delimiter in the resulting HTML document. A subsequent greater-than character (>) closes the opening <div> tag altogether.

Crucially, this code path bypasses Hugo's primary Markdown security controls. Shortcodes (such as {{< highlight >}}) and fenced code block attribute maps (```go {wrapperClass="..."}) are parsed and evaluated by Hugo's shortcode and highlight renderers rather than Goldmark's standard inline HTML filter. Even when an administrator enforces unsafe = false in hugo.toml to prevent contributors from embedding raw HTML, the output generated by writeDivStart is trusted unconditionally by the build pipeline and emitted verbatim into the final .html artifact.

Code Analysis

In vulnerable versions of Hugo (0.140.2 through 0.169.x), the writeDivStart function in markup/highlight/highlight.go wrote wrapperClass directly to the output buffer before processing additional attributes.

// Vulnerable implementation in markup/highlight/highlight.go (prior to v0.170.0)
func writeDivStart(w hugio.FlexiWriter, attrs []attributes.Attribute, wrapperClass string) {
	w.WriteString(`<div class="`)
	// VULNERABILITY: wrapperClass is written directly without HTML escaping.
	// An input containing '"' and '>' breaks out of the attribute and tag context.
	w.WriteString(wrapperClass)
	if attrs != nil {
		for _, attr := range attrs {
			if attr.Name == "class" {
				w.WriteString(" ")
				w.WriteString(attr.ValueString())
			}
		}
	}
	w.WriteString(`"`)
	if attrs != nil {
		attributes.RenderAttributes(w, true, attrs...)
	}
	w.WriteString(`>`)
}

The vulnerability was remediated in commit bdde5aa5155c6c349a743e71dc846bef754b6773 (merged via Pull Request #15564 for release v0.170.0). The patch wraps wrapperClass in a call to Go's standard library html.EscapeString (aliased as gohtml.EscapeString in the package) before writing it to the FlexiWriter.

diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go
index 467a4a2a5f0..4d1a83efe32 100644
--- a/markup/highlight/highlight.go
+++ b/markup/highlight/highlight.go
@@ -312,7 +312,7 @@ func (s startEnd) End(code bool) string {
 
 func writeDivStart(w hugio.FlexiWriter, attrs []attributes.Attribute, wrapperClass string) {
 	w.WriteString(`<div class="`)
-	w.WriteString(wrapperClass)
+	w.WriteString(gohtml.EscapeString(wrapperClass))
 	if attrs != nil {
 		for _, attr := range attrs {
 			if attr.Name == "class" {

Go's html.EscapeString replaces the five sensitive HTML characters (<, >, &, ', and ") with their corresponding character references (&lt;, &gt;, &amp;, &#39;, and &#34;). Because the injection sink is located inside a double-quoted HTML attribute (class="..."), converting " to &#34; is sufficient to prevent an attacker from breaking out of the attribute value context.

> [!NOTE] > To assess fix completeness, examine the adjacent loop in writeDivStart where attr.Name == "class" is handled via w.WriteString(attr.ValueString()), as well as attributes.RenderAttributes. In Hugo's AST parser, code block attributes in attrs are parsed and escaped or restricted by grammar tokenization rules, whereas wrapperClass can be supplied as an arbitrary raw string inside shortcode parameters or template dictionaries. The integration test TestHighlightWrapperClassIsEscaped added in markup/highlight/highlight_integration_test.go verifies that both shortcode and code fence invocations properly render " as &#34; and < as &lt;.

Exploitation

Exploitation of GHSA-4whp-jx7j-xvrm requires the ability to supply or modify content processed by a vulnerable Hugo build pipeline. No authentication or special flags are required on the Hugo CLI itself; default build commands (hugo or hugo server) trigger the vulnerable code path whenever syntax highlighting is invoked with the wrapperClass parameter.

There are three distinct entry points through which an attacker can reach the vulnerable sink in writeDivStart:

Vector 1: The Built-in highlight Shortcode

An attacker submitting a Markdown article or documentation Pull Request can invoke the built-in highlight shortcode and pass a quote-breaking payload inside the option string:

{{< highlight go "wrapperClass=x\"><script>alert(document.domain)</script>" >}}
package main
 
func main() {
    println("Exploit")
}
{{< /highlight >}}

Vector 2: Markdown Fenced Code Block Attributes

In configurations where code fence attributes are enabled (default in Hugo), an attacker can attach an attribute map directly to a standard Markdown code block without using shortcode tags:

```go &#123;wrapperClass="highlight-box\"&gt;&lt;img src=x onerror=alert(1)&gt;"&#125;
package main
```

Vector 3: The transform.Highlight Template Function

If a site layout or theme dynamically passes page front matter parameters or external data dicts into the transform.Highlight template function, an attacker who controls front matter metadata (e.g., via a headless CMS interface or YAML/TOML header) can inject the payload through the parameter dictionary:

{{ transform.Highlight $code "go" (dict "wrapperClass" .Params.customWrapper) }}

When Hugo compiles any of these inputs on versions &gt;= 0.140.2, &lt; 0.170.0, it emits the following unescaped HTML structure into the output file (e.g., public/index.html):

<div class="x"><script>alert(document.domain)</script>"><pre class="chroma"><code class="language-go" data-lang="go">...</code></pre></div>

When a visitor loads the compiled page, the browser parses &lt;div class="x"&gt;, immediately encounters and executes &lt;script&gt;alert(document.domain)&lt;/script&gt;, and renders the trailing "&gt;&lt;pre... as residual text and code block elements.

Impact Assessment

The security impact of GHSA-4whp-jx7j-xvrm depends on the content governance and deployment model of the Hugo project. For single-author static sites where the developer has full control over both the repository and the hosting server, the practical risk is minimal because the author already controls the site's HTML templates and assets.

However, Hugo is frequently deployed in multi-tenant or collaborative architectures where content creation is separated from site administration:

  • Open-Source Documentation Portals: Visitors and external contributors submit Markdown changes via GitHub Pull Requests. Automated CI/CD services (such as Netlify, Vercel, or Cloudflare Pages) automatically build and deploy preview environments or merge changes into production.
  • Headless CMS Workflows: Non-technical editors or external writers author Markdown posts through web-based CMS platforms that commit Markdown files to a repository while restricting access to layout templates (layouts/) and site configuration (hugo.toml).
  • Aggregator and Community Platforms: Sites that ingest external Markdown feeds or user-submitted documentation.

In these scenarios, an untrusted contributor can achieve persistent client-side code execution within the origin of the deployed web application. The injected JavaScript executes in the browser session of every visitor viewing the rendered page, allowing the attacker to steal session tokens or cookies scoped to the domain (or parent domain), perform unauthorized actions via authenticated API endpoints sharing the same origin, or deface the rendered DOM.

Under CVSS v4.0 (CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N), the vulnerability is rated Medium. The Attack Vector is scored as Local (AV:L) because the payload must be introduced into the local file tree or build pipeline processed by the Hugo binary. Vulnerable System Integrity (VI:L) reflects the modification of the generated HTML output during compilation, while Subsequent System Confidentiality and Integrity (SC:L/SI:L) represent the impact on the victim's browser session upon active user interaction (UI:A).

Remediation & Mitigation

The primary remediation is to upgrade Hugo to version v0.170.0 or later, which incorporates commit bdde5aa5155c6c349a743e71dc846bef754b6773 to escape wrapperClass output.

Upgrading Hugo

For projects building or importing Hugo as a Go module dependency, update the module version in go.mod:

go get -u github.com/gohugoio/hugo@v0.170.0
go mod tidy

For standalone binary deployments and CI/CD pipelines (such as GitHub Actions, Netlify, or Cloudflare Pages), update the pinned Hugo version environment variable (e.g., HUGO_VERSION=0.170.0) or upgrade the binary via your system package manager.

Auditing Existing Content Repositories

Security teams managing multi-author Hugo repositories should audit existing Markdown files and template directories to verify that no malicious wrapperClass payloads have been committed prior to upgrading. Execute the following ripgrep command across the content/ and layouts/ directories:

rg -i '(wrapperClass\s*=\s*["'\'']?[^"'\''>]*["'\''>]|wrapperClass=.*[<"\x27>])' content/ layouts/

Workarounds and Defense-in-Depth

If an immediate upgrade of the Hugo build binary is not possible in legacy CI/CD pipelines, implement the following compensating controls:

  1. Pre-Build CI/CD Linting: Add a pre-build validation step in your CI pipeline that scans incoming Pull Requests and Markdown files for occurrences of wrapperClass containing quotes (", ') or HTML bracket characters (<, >), failing the build if detected.
  2. Content Security Policy (CSP): Configure the web server or CDN serving the compiled static files to emit a strict Content-Security-Policy header that disables inline JavaScript execution (e.g., script-src 'self'; object-src 'none';), mitigating the execution of injected <script> tags and inline event handlers (onerror=).

Official Patches

gohugoioHugo v0.170.0 Official Release
gohugoioPull Request #15564: markup/highlight: Escape wrapperClass
GitHubGitHub Advisory Database Entry for GHSA-4whp-jx7j-xvrm

Fix Analysis (1)

Technical Appendix

CVSS Score
5.1/ 10
CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N

Affected Systems

Hugo Static Site Generator (github.com/gohugoio/hugo)

Affected Versions Detail

Product
Affected Versions
Fixed Version
Hugo
gohugoio
>= 0.140.2, < 0.170.00.170.0
AttributeDetail
Vulnerability IDGHSA-4whp-jx7j-xvrm
Weakness ClassCWE-79 (Cross-Site Scripting) / CWE-116 (Improper Output Encoding)
Affected Componentmarkup/highlight/highlight.go (writeDivStart)
Affected Versions>= 0.140.2, < 0.170.0
Patched Version0.170.0
CVSS v4.0 VectorCVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N (Medium)
Exploit StatusProof-of-Concept Available
CISA KEV StatusNot Listed (No CVE Assigned)

MITRE ATT&CK Mapping

T1059.007Command and Scripting Interpreter: JavaScript
Execution
T1189Drive-by Compromise
Initial Access
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.

Known Exploits & Detection

GitHub Security AdvisoryOfficial vendor security advisory detailing the stored XSS mechanism via wrapperClass.
GitHub Commit Integration TestOfficial patch commit containing TestHighlightWrapperClassIsEscaped which demonstrates PoC payloads for both shortcode and code fence vectors.

Vulnerability Timeline

Fix committed by Bjørn Erik Pedersen (bdde5aa5155c6c349a743e71dc846bef754b6773) via Pull Request #15564.
2026-11-10
GitHub Security Advisory GHSA-4whp-jx7j-xvrm published and synchronized to OSV.
2026-12-01

References & Sources

  • [1]GitHub Advisory Database: GHSA-4whp-jx7j-xvrm
  • [2]Hugo Repository Security Advisory: GHSA-4whp-jx7j-xvrm
  • [3]Fix Commit bdde5aa5155c6c349a743e71dc846bef754b6773: markup/highlight: Escape wrapperClass
  • [4]Hugo Pull Request #15564
  • [5]Hugo v0.170.0 Release Notes

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 1 hour ago•CVE-2026-137191
7.8

CVE-2026-137191: Arbitrary Code Execution via Unverified Package Manager Bootstrap in Vite+ (vp)

Vite+ (vp) versions 0.2.9 through 1.5.0 contain an integrity verification flaw (CWE-494) in the internal package manager bootstrap mechanism. When initializing in an environment where the pinned pnpm distribution is not cached, the runtime queries the registry specified in the local workspace's .npmrc file and validates the downloaded tarball exclusively against the self-reported integrity digest provided by that same registry. An attacker who supplies a repository with a malicious .npmrc pointing to an attacker-controlled registry can achieve arbitrary code execution when a developer or CI runner invokes basic vp commands.

Alon Barad
Alon Barad
0 views•9 min read
•about 2 hours ago•CVE-2026-137190
7.0

CVE-2026-137190: Shell Command Injection in Vite+ Global CLI via Unvalidated Registry Version String

A local OS command injection and dynamic code evaluation vulnerability (CWE-78 / CWE-95) exists in the Vite+ global command-line interface (vp) across versions 0.3.3 through 1.5.0. When resolving package manager dist-tags such as 'latest' with the '--no-install' flag enabled, Vite+ queries the npm registry defined in the local workspace's '.npmrc' file and returns the raw version string without semantic version validation. Because this unvalidated string is interpolated directly into shell environment export statements evaluated by the user's shell wrapper, an attacker controlling the registry can inject shell metacharacters to achieve arbitrary command execution in the developer's local terminal context.

Alon Barad
Alon Barad
4 views•10 min read
•about 3 hours ago•CVE-2026-137196
6.3

CVE-2026-137196: Synchronous Event-Loop Denial of Service via Unbounded Ignore Pattern Expansion in node-glob

CVE-2026-137196 (also tracked as GHSA-qxr8-q827-836c) is an asymmetric resource consumption and denial-of-service vulnerability affecting the npm package glob (node-glob) in versions 13.0.5 through 14.0.5. When processing primary search patterns, node-glob relies on the minimatch engine with a default safeguard parameter (braceExpandMax: 10_000) to prevent combinatorial explosions during shell brace and directory traversal expansion. However, the Ignore class in src/ignore.ts instantiated its internal minimatch options with optimizationLevel: 2 while omitting the braceExpandMax configuration property. Consequently, applications that pass untrusted input into the ignore option allow attackers to trigger unbounded pattern expansion and quadratic O(n^2) preprocessing loops inside secondPhasePreProcess(), leading to single-threaded Node.js event-loop starvation.

Alon Barad
Alon Barad
5 views•10 min read
•about 4 hours ago•GHSA-R48V-R4VW-H9V8
5.5

GHSA-r48v-r4vw-h9v8: Arbitrary Build-Host File Disclosure via Path Traversal in Hugo Vendored Module Metadata

Hugo versions prior to 0.170.0 contain a path traversal and improper symlink resolution vulnerability in the module resolution and vendoring subsystem. By supplying relative traversal sequences in `_vendor/modules.txt` or crafting symbolic links within vendored directory hierarchies, an untrusted third-party theme or Hugo module can bind its module root to an arbitrary directory on the build host. During site compilation, template functions such as `readFile` can access and render sensitive files from the host filesystem into the generated static output.

Alon Barad
Alon Barad
5 views•9 min read
•about 7 hours ago•CVE-2026-139994
4.7

CVE-2026-139994: Cross-Site Scripting via Context-Mismatched HTML Escaping in React Router RSC Streaming Redirects

CVE-2026-139994 (GHSA-mjj8-rxh9-q8f5) is a Cross-Site Scripting (XSS) vulnerability in React Router affecting versions 7.11.0 through 7.18.3 and 8.0.0 through 8.3.1. The flaw resides in the server-side streaming handler for the unstable React Server Components (RSC) Data mode and RSC Framework mode. When a server-side redirect is triggered during an HTML stream, the framework injects an inline <meta http-equiv="refresh"> element into the response stream. Because the redirect destination URL is sanitized using an HTML body escaping utility (escapeHtml) rather than an attribute-specific encoding function, double-quote characters (") are left unescaped. An attacker who can influence the redirect URL can break out of the content attribute context, inject arbitrary attributes or HTML elements, and execute arbitrary JavaScript within the victim's browser session.

Alon Barad
Alon Barad
8 views•11 min read
•about 8 hours ago•CVE-2026-139996
7.4

CVE-2026-139996: Prototype Pollution in React Router via Vendored turbo-stream Deserializer

CVE-2026-139996 is a prototype pollution vulnerability (CWE-1321) in React Router's vendored turbo-stream deserializer, utilized in Framework mode for single-fetch transitions and client-server hydration. When unflattening serialized streams, the decoder assigns object properties using direct bracket notation (object[key] = value) rather than defining own properties via Object.defineProperty. Furthermore, the deserializer lacks integer and bounds validation on stream reference indices. An attacker capable of supplying crafted turbo-stream payloads to the deserializer can pollute Object.prototype or trigger arbitrary index dereferences, compromising application integrity and confidentiality.

Amit Schendel
Amit Schendel
6 views•9 min read