Hugo theme-defined module replacements bypass mount restrictions and widen the Node.js read sandbox
Published 30 Nov 2026 · Updated 30 Nov 2026
Affected package
- Affected
- >=0.152.0 <0.168.0
- Fixed in
- 0.168.0
go get github.com/gohugoio/hugo@v0.168.0Which github.com/gohugoio/hugo does your project really install?
Works for private projects: the file is read in memory to run the scan and then dropped. Also reads other package files.
Public repo?
Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Details
Summary
A theme or module could define its own module.replacements and mount directories anywhere on the host.
Details
A theme or module could define its own module.replacements. If the project didn't set any replacements, Hugo applied the theme's replacements as if the project had set them. The theme could then import and mount a directory anywhere on the host, either by absolute path or by escaping themesDir with ../. This got around the rule that theme mount sources must be local paths.
Mounting such a directory as assets also added it to the Node.js --allow-fs-read roots. That widened the security.node.permissions sandbox. For example, Node tools such as css.PostCSS could read files from that directory and load JavaScript modules from it.
Only sites that use an untrusted theme or module are affected.
Proof of concept
Create a theme as outlined in the Go test below:
func TestMountRestrictThemeReplacements(t *testing.T) {
files := `
-- hugo.toml --
disableKinds = ["taxonomy", "term", "rss"]
theme = "mytheme"
-- themes/mytheme/hugo.toml --
[module]
replacements = "evil -> ../../secret"
[[module.imports]]
path = "evil"
[[module.imports.mounts]]
source = "."
target = "assets"
-- secret/file1.txt --
file1
-- layouts/all.html --
All.
`
b, err := hugolib.TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `module "evil" not found in "/themes/evil"`)
}Impact
A theme could read files outside its sandbox.
Is GHSA-r73q-gwx2-fpxm in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/gohugoio/hugo, and gives you the command that fixes it.
More advisories for github.com/gohugoio/hugo
- MediumCVE-2026-140394Hugo highlight wrapperClass option allows stored cross-site scripting · 1 Dec 2026
- MediumCVE-2026-140395Hugo: Build-host file disclosure through path traversal in vendored module metadata · 1 Dec 2026
- LowCVE-2026-58403Hugo: Symlink confinement bypass in os.ReadFile in github.com/gohugoio/hugo · 24 Jul 2026
- LowCVE-2026-58402Hugo: XSS via unescaped code-fence language in default code block renderer in github.com/gohugoio/hugo · 24 Jul 2026
- LowCVE-2026-58404Hugo: security.http.urls deny rules bypassed by alternate IPv4 encodings (SSRF) in github.com/gohugoio/hugo · 24 Jul 2026
- LowCVE-2026-44301Hugo's Node tool execution allows file system access outside the project directory in github.com/gohugoio/hugo · 24 Jul 2026
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.