MediumGHSA-r48v-r4vw-h9v8CVE-2026-140395

Hugo: Build-host file disclosure through path traversal in vendored module metadata

Published 1 Dec 2026 · Updated 1 Dec 2026

Affected package

Affected
>=0.56.0 <0.170.0
Fixed in
0.170.0
Update to the fixed version for your release line, for example:go get github.com/gohugoio/hugo@v0.170.0

We confirm your address first. See our privacy policy.

Which github.com/gohugoio/hugo does your project really install?

Drop your go.mod hereWe find the exact github.com/gohugoio/hugo version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

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 can ship a _vendor/modules.txt with an import path containing .. segments. Hugo used this path as the module's root directory without checking that it stays inside _vendor, so a malicious theme can make Hugo treat any directory on the build host (up to /) as its module root and read files from it.

Details

collectModulesTXT in modules/collect.go builds the vendored module directory with filepath.Join(vendorDir, path), where path comes straight from _vendor/modules.txt. When an import resolves through the vendor list, Hugo uses that directory as is and skips the checks that normally keep a theme under themesDir. The resulting root is added to Hugo's filesystem overlay, which makes files outside the project available to readFile, resources.Get, os.ReadFile and mounts (e.g. a static mount that publishes the directory).

The fix rejects any modules.txt path that is not local (filepath.IsLocal), so the build fails with an invalid module path error.

Proof of concept

A site uses an untrusted theme (theme = "evil"). The theme imports ../../../.. and lists the same path in its _vendor/modules.txt. A template then calls readFile on a path relative to the escaped root, e.g. a file outside the project or a system file such as etc/passwd. Its content ends up in the generated site.

Impact

Anyone building a site with an untrusted theme or module, for example in CI or on a hosted build service, can have files on the build host read and published in the site. This includes secrets, credentials and system files. No change to the site configuration beyond importing the theme is needed.

Is GHSA-r48v-r4vw-h9v8 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
  • MediumGHSA-r73q-gwx2-fpxmHugo theme-defined module replacements bypass mount restrictions and widen the Node.js read sandbox · 30 Nov 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
All 24 advisories for github.com/gohugoio/hugo

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.