CVE-2026-58402

Hugo default code block renderer XSS via unescaped code-fence language

Published Jul 6, 2026 CVSS 4.0 · 5.1 Medium EPSS < 1% KEV · Not listed
Description
Hugo is a static site generator. From 0.60.0 until 0.163.3, Hugo's default code-block renderer wrote the Markdown code-fence language or info-string into the code class="language-…" data-lang="…" wrapper without HTML escaping. A fence info-string containing a quote and a script payload breaks out of the attribute and injects a live script element. This issue is fixed in 0.163.3.

Analysis

AI-generated

Technical impact

Hugo’s default code‑block renderer incorrectly inserts the Markdown fence language or info‑string straight into the class and data‑lang attributes without HTML escaping. A fence containing a quote followed by a script tag breaks out of the attribute and injects executable JavaScript into the rendered page. This result is a classic cross‑site scripting flaw that could let an attacker deliver malicious scripts to visitors, deface the site, steal session cookies or perform other client‑side attacks. The weakness is a typical example of unvalidated input leading to script injection (CWE‑79).

Affected Systems

The vulnerability affects Hugo versions 0.60.0 through 0.163.2, released by gohugoio. Sites that publish Markdown pages using code fences with unsanitized language specifiers are vulnerable. Versions 0.163.3 and later include a fix that sanitises the language string before embedding it in HTML attributes.

Risk and Exploitability

The CVSS score of 5.1 indicates moderate severity, while the EPSS of less than 1% shows a very low probability of exploitation. Because the flaw is only triggered by the rendering of malicious Markdown content, the attack vector is confined to content authors or compromised content repositories rather than network‑level attackers. The vulnerability is not present in the CISA KEV catalog, but because it permits client‑side script execution it can be damaging if exploited, and the low EPSS suggests the threat is not widely present in the wild.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Hugo to version 0.163.3 or newer, which properly escapes the fence language before rendering.
  • If an immediate upgrade is not possible, edit any Markdown code fences to only include safe, alphanumeric language identifiers or strip the language specifier entirely before rendering.
  • Implement a strict Content Security Policy that disallows inline scripts and restricts script execution to trusted origins, thereby reducing the impact of any residual injection.

Generated by OpenCVE AI on August 1, 2026 at 18:21 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
First Time appeared Gohugo
Gohugo hugo
Vendors & Products Gohugo
Gohugo hugo
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description Hugo is a static site generator. From 0.60.0 until 0.163.3, Hugo's default code-block renderer wrote the Markdown code-fence language or info-string into the code class="language-…" data-lang="…" wrapper without HTML escaping. A fence info-string containing a quote and a script payload breaks out of the attribute and injects a live script element. This issue is fixed in 0.163.3.
Title Hugo default code block renderer XSS via unescaped code-fence language
Weaknesses CWE-79
References
Metrics cvssV4_0

{'score': 5.1, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N'}

Weaknesses
  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 6, 2026, 8:54 PM
Reserved
Jun 30, 2026, 6:19 PM
Status
Analyzed
Published
Jul 6, 2026, 8:16 PM
Modified
Oct 25, 2026, 8:10 PM