{"id":"CVE-2026-140394","aliases":["CVE-2026-140394","GHSA-4whp-jx7j-xvrm"],"related":[],"kind":"vulnerability","state":"published","title":"Hugo 0.140.2 before 0.170.0 Stored XSS via highlight shortcode wrapperClass","summary":"Hugo after 0.140.2 and before 0.170.0 contains a stored cross-site scripting vulnerability in the highlight shortcode and transform.Highlight template function, which write the wrapperClass option unescaped into the wrapping div's class attribute. Content authors can supply a wrapperClass value that closes the attribute and appends a script element, executing JavaScript in visitors' browsers under the site's origin.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Hugo after 0.140.2 and before 0.170.0 contains a stored cross-site scripting vulnerability in the highlight shortcode and transform.Highlight template function, which write the wrapperClass option unescaped into the wrapping div's class attribute. Content authors can supply a wrapperClass value that closes the attribute and appends a script element, executing JavaScript in visitors' browsers under the site's origin.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe `wrapperClass` option of the built-in `highlight` shortcode (and the `transform.Highlight` template function) was written unescaped into the wrapping `<div class=\"...\">`, 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 `<script>` 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.","format":"markdown","source":"ghsa"}],"published":"2026-12-01T02:24:46.000Z","modified":"2026-12-01T16:18:19.697Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","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","score":5.1,"rating":"MEDIUM"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","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","score":5.1,"rating":"MEDIUM"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"type":"semver","introduced":"0.140.2","fixed":"0.170.0","status":"affected"},{"type":"semver","version":"0.170.0","status":"unaffected"}],"vendor":"gohugoio","product":"hugo","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.140.2","status":"affected","fixed":"0.170.0"}],"ecosystem":"Go","package":"github.com/gohugoio/hugo","purl":"pkg:golang/github.com/gohugoio/hugo","source":"ghsa"}],"references":[{"url":"https://github.com/gohugoio/hugo/security/advisories/GHSA-4whp-jx7j-xvrm","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/hugo-0.140.2-before-0.170.0-stored-xss-via-highlight-shortcode-wrapperclass","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/gohugoio/hugo/pull/15564","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/gohugoio/hugo/commit/bdde5aa5155c6c349a743e71dc846bef754b6773","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/gohugoio/hugo","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/gohugoio/hugo/releases/tag/v0.170.0","tags":["web"],"sources":["ghsa"]}],"credits":["R0X4R"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-12-01T15:39:53.066Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-140394","url":"https://www.cve.org/CVERecord?id=CVE-2026-140394","licence":"CVE Terms of Use","modified":"2026-12-01T15:41:04.629Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4whp-jx7j-xvrm","url":"https://github.com/advisories/GHSA-4whp-jx7j-xvrm","licence":"CC-BY-4.0","modified":"2026-12-01T16:11:12.093Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-140394","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140394","licence":"Public domain","modified":"2026-12-01T16:18:19.697Z"}],"updatedAt":"2026-12-01T16:32:19.030Z"}