Medium severity6.1NVD Advisory· Published Apr 23, 2024· Updated Apr 15, 2026
CVE-2024-32875
CVE-2024-32875
Description
Hugo is a static site generator. Starting in version 0.123.0 and prior to version 0.125.3, title arguments in Markdown for links and images not escaped in internal render hooks. Hugo users who are impacted are those who have these hooks enabled and do not trust their Markdown content files. The issue is patched in v0.125.3. As a workaround, replace the templates with user defined templates or disable the internal templates.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/gohugoio/hugoGo | >= 0.123.0, < 0.125.3 | 0.125.3 |
Patches
2474c4c02212c15a4b9b33715tpl: Escape .Title in built-in image and link render hooks
4 files changed · +52 −2
.hugo_build.lock+0 −0 addedhugolib/content_render_hooks_test.go+50 −0 modified@@ -14,6 +14,7 @@ package hugolib import ( + "fmt" "strings" "testing" ) @@ -241,3 +242,52 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA "p1|<p><a href=\"p2\">P2</a>", "<img src=\"pixel.png\" alt=\"Pixel\">") }) } + +func TestRenderHooksDefaultEscape(t *testing.T) { + files := ` +-- hugo.toml -- +[markup.goldmark.renderHooks] +[markup.goldmark.renderHooks.image] + enableDefault = ENABLE +[markup.goldmark.renderHooks.link] +enableDefault = ENABLE +[markup.goldmark.parser] +wrapStandAloneImageWithinParagraph = false +[markup.goldmark.parser.attribute] +block = true +title = true +-- content/_index.md -- +--- +title: "Home" +--- +Link: [text-"<>&](/destination-"<> 'title-"<>&') + +Image:  +{class="><script>alert()</script>" id="baz"} + +-- layouts/index.html -- +{{ .Content }} +` + + for _, enabled := range []bool{true, false} { + enabled := enabled + t.Run(fmt.Sprint(enabled), func(t *testing.T) { + t.Parallel() + b := Test(t, strings.ReplaceAll(files, "ENABLE", fmt.Sprint(enabled))) + + // The escaping is slightly different between the two. + if enabled { + b.AssertFileContent("public/index.html", + "Link: <a href=\"/destination-%22%3C%3E\" title=\"title-"<>&\">text-"<>&</a>", + "img alt=\"alt-"<>&\" src=\"/destination-%22%3C%3E\" title=\"title-"<>&\">", + "><script>", + ) + } else { + b.AssertFileContent("public/index.html", + "Link: <a href=\"/destination-%22%3C%3E\" title=\"title-"<>&\">text-"<>&</a>", + "Image: <img src=\"/destination-%22%3C%3E\" alt=\"alt-"<>&\" title=\"title-"<>&\">", + ) + } + }) + } +}
tpl/tplimpl/embedded/templates/_default/_markup/render-image.html+1 −1 modified@@ -5,7 +5,7 @@ {{- $src = .RelPermalink -}} {{- end -}} {{- end -}} -{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" .Title) -}} +{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" (.Title | transform.HTMLEscape)) -}} <img {{- range $k, $v := $attributes -}} {{- if $v -}}
tpl/tplimpl/embedded/templates/_default/_markup/render-link.html+1 −1 modified@@ -17,7 +17,7 @@ {{- end -}} {{- end -}} {{- end -}} -{{- $attributes := dict "href" $href "title" .Title -}} +{{- $attributes := dict "href" $href "title" (.Title | transform.HTMLEscape) -}} <a {{- range $k, $v := $attributes -}} {{- if $v -}}
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-ppf8-hhpp-f5hjghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-32875ghsaADVISORY
- github.com/gohugoio/hugo/commit/15a4b9b33715887001f6eff30721d41c0d4cfdd1ghsaWEB
- github.com/gohugoio/hugo/releases/tag/v0.125.3nvdWEB
- github.com/gohugoio/hugo/security/advisories/GHSA-ppf8-hhpp-f5hjnvdWEB
- gohugo.io/getting-started/configuration-markup/nvdWEB
- pkg.go.dev/vuln/GO-2024-2747ghsaWEB
News mentions
0No linked articles in our index yet.