CVE-2026-10618: Hugo 0.93.0 through 0.165.0 Stored Cross-Site Scripting via Unescaped Code-Fence Attribute Values
Hugo's default fenced-code-block renderer writes attribute values taken from the code-fence info string into the rendered HTML without escaping them. New in markup/internal/attributes/attributes.go converts every attribute value from a byte slice to a string as it is stored, deliberately dropping the escaping that used to happen there, and RenderAttributes in the same file escapes only values that are still byte slices, so its escaping branch is never reached and every value is written verbatim. The function's documentation states that it performs HTML escaping of string attributes, which it does not. A quote inside an attribute value in the info string therefore terminates the attribute and allows a further attribute, including an event handler, to be placed on the wrapper element, and the script runs for every visitor who loads the page. This path is reached under the default configuration, with code fences enabled and without goldmark's unsafe setting or any custom render hook. Attribute names beginning with on are filtered when the attributes are parsed, so injection is achieved through the value rather than the name.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Hugoto a version that resolves this vulnerability.Fixed in 0.93.0 through 0.165.0
Event History
Frequently Asked Questions
Who is exposed to this issue?
Sites built with affected Hugo versions are exposed if untrusted users can influence fenced code-block info strings or their attribute values. Any visitor who loads a page containing a maliciously crafted code fence can have script executed in their browser.
Does exploitation require a non-default Hugo or Goldmark configuration?
No. The vulnerable rendering path is reachable with Hugo's default configuration, code fences enabled, and no Goldmark unsafe setting or custom render hook.
What does an attacker need to control?
The attacker needs to supply a code-fence info string containing an attribute value with a quote. The quote can terminate the intended HTML attribute and add another attribute, such as an event handler, to the rendered wrapper element.
Are event-handler attribute names blocked?
Attribute names beginning with "on" are filtered during parsing. However, that filtering does not prevent exploitation because the injection is performed through an unescaped attribute value rather than a malicious attribute name.
How can I determine whether a page is affected?
Review rendered pages containing fenced code blocks whose info strings include attributes, especially content originating from untrusted contributors. A page is affected if a quote in an attribute value is emitted verbatim into the code-block wrapper's HTML attributes.