VYPR
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.

PackageAffected versionsPatched versions
github.com/gohugoio/hugoGo
>= 0.123.0, < 0.125.30.125.3

Patches

2
15a4b9b33715

tpl: Escape .Title in built-in image and link render hooks

https://github.com/gohugoio/hugoBjørn Erik PedersenApr 22, 2024via ghsa
4 files changed · +52 2
  • .hugo_build.lock+0 0 added
  • hugolib/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: ![alt-"<>&](/destination-"<> 'title-"<>&')
    +{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-&#34;&lt;&gt;&amp;\">text-&quot;&lt;&gt;&amp;</a>",
    +					"img alt=\"alt-&quot;&lt;&gt;&amp;\" src=\"/destination-%22%3C%3E\" title=\"title-&#34;&lt;&gt;&amp;\">",
    +					"&gt;&lt;script&gt;",
    +				)
    +			} else {
    +				b.AssertFileContent("public/index.html",
    +					"Link: <a href=\"/destination-%22%3C%3E\" title=\"title-&quot;&lt;&gt;&amp;\">text-&quot;&lt;&gt;&amp;</a>",
    +					"Image: <img src=\"/destination-%22%3C%3E\" alt=\"alt-&quot;&lt;&gt;&amp;\" title=\"title-&quot;&lt;&gt;&amp;\">",
    +				)
    +			}
    +		})
    +	}
    +}
    
  • 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

News mentions

0

No linked articles in our index yet.