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.
Published: 2026-07-06
Score: 5.1 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

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.

Generated by OpenCVE AI on July 26, 2026 at 20:19 UTC.

Remediation

No vendor fix or workaround currently provided.

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 July 26, 2026 at 20:19 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Mon, 06 Jul 2026 22:45:00 +0000

Type Values Removed Values Added
First Time appeared Gohugo
Gohugo hugo
Vendors & Products Gohugo
Gohugo hugo

Mon, 06 Jul 2026 21:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

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


Mon, 06 Jul 2026 19:45:00 +0000

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'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-06T20:54:38.775Z

Reserved: 2026-06-30T18:19:58.378Z

Link: CVE-2026-58402

cve-icon Vulnrichment

Updated: 2026-07-06T20:54:16.440Z

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-07-26T20:30:03Z

Weaknesses
  • CWE-79

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