{"id":"GHSA-4whp-jx7j-xvrm","summary":"Hugo highlight wrapperClass option allows stored cross-site scripting","details":"### Summary\n\nThe `wrapperClass` option of the built-in `highlight` shortcode (and the `transform.Highlight` template function) was written unescaped into the wrapping `\u003cdiv class=\"...\"\u003e`, allowing a content author to inject arbitrary HTML/JavaScript into the rendered page.\n\n### Details\n\n`markup/highlight/highlight.go` (`writeDivStart`) wrote `wrapperClass` directly between `class=\"` and `\"`, while all other attribute values were HTML-escaped. Because the shortcode's options string is decoded into the highlight config, any content author can set `wrapperClass`. The Goldmark `unsafe` setting does not apply, as the value never passes through the Markdown HTML renderer. Markdown code fences are not affected.\n\nFixed by HTML-escaping the value.\n\n### Proof of concept\n\nA content author on a multi-author site adds a `highlight` shortcode to a page with a `wrapperClass` option value that closes the `class` attribute and appends a `\u003cscript\u003e` element. When the site is built, the script ends up in the page body and runs in visitors' browsers under the site's origin.\n\n### Impact\n\nStored XSS for sites that render content from less-trusted authors. The `highlight` shortcode is built in and enabled by default.","modified":"2026-12-01T02:45:04.344926753Z","published":"2026-12-01T02:24:46Z","database_specific":{"cwe_ids":["CWE-79"],"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-12-01T02:24:46Z","nvd_published_at":null},"references":[{"type":"WEB","url":"https://github.com/gohugoio/hugo/security/advisories/GHSA-4whp-jx7j-xvrm"},{"type":"WEB","url":"https://github.com/gohugoio/hugo/pull/15564"},{"type":"WEB","url":"https://github.com/gohugoio/hugo/commit/bdde5aa5155c6c349a743e71dc846bef754b6773"},{"type":"PACKAGE","url":"https://github.com/gohugoio/hugo"},{"type":"WEB","url":"https://github.com/gohugoio/hugo/releases/tag/v0.170.0"}],"affected":[{"package":{"name":"github.com/gohugoio/hugo","ecosystem":"Go","purl":"pkg:golang/github.com/gohugoio/hugo"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0.140.2"},{"fixed":"0.170.0"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-4whp-jx7j-xvrm/GHSA-4whp-jx7j-xvrm.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V4","score":"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"}]}