REDHAT-BUG-2541895: Medium severity Hugo Hugo vulnerability
Hugo versions 0.75.0 through 0.165.x contain a stored cross-site scripting vulnerability: the syntax highlighter does not escape the lineAnchors option before passing it to Chroma, which writes the value verbatim into the id and href attributes of the generated line-number markup. A crafted lineAnchors value supplied as a Markdown code fence attribute (or passed to the highlight template function) results in unescaped HTML in the rendered page, allowing arbitrary JavaScript to execute in the browsers of visitors to the generated site. This affects sites that build and publish Markdown from untrusted contributors; Hugo's security model otherwise considers content trusted input. Fixed in 0.166.0, where the lineAnchors value is HTML-escaped before being passed to Chroma.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Hugoto a version that resolves this vulnerability.Fixed in 0.166.0
Event History
Frequently Asked Questions
Which sites are realistically exposed to exploitation?
Sites that build and publish Markdown supplied by untrusted contributors are exposed. Hugo otherwise treats content as trusted input, so sites where only trusted authors can modify Markdown have a different risk profile.
What must an attacker be able to control?
An attacker needs to supply a crafted lineAnchors value in a Markdown code fence attribute or through use of the highlight template function. The resulting page must then be published and viewed by a visitor for the injected JavaScript to execute.
How can I determine whether a site is affected?
Check the Hugo version used to build the site: versions from 0.75.0 through 0.165.x are affected, while 0.166.0 includes escaping for lineAnchors. Also review whether untrusted parties can contribute Markdown or otherwise influence code-fence attributes or highlight template parameters.
What is the remediation?
Upgrade Hugo to version 0.166.0, which HTML-escapes lineAnchors before passing it to Chroma. If upgrading is not immediately possible, do not build or publish untrusted Markdown that can set code-fence attributes or influence highlight template parameters.