Hugo: Build-host file disclosure through path traversal in vendored module metadataGHSA-r48v-r4vw-h9v8
Fix: gohugoio/hugo#15564GHSA-r48v-r4vw-h9v8 is a security vulnerability in github.com/gohugoio/hugo. A fix is available for github.com/gohugoio/hugo — see the affected versions and patch details below.
Real-World Exposure
github.com/gohugoio/hugoReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Go packages — download data is not available via public APIs for these ecosystems.
Description
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐹Go | github.com/gohugoio/hugo | ≥ 0.56.0&&< 0.170.0 | 0.170.0go get github.com/gohugoio/hugo@v0.170.0 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for github.com/gohugoio/hugo, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update github.com/gohugoio/hugo to 0.170.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-r48v-r4vw-h9v8 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Frequently Asked Questions
Is GHSA-r48v-r4vw-h9v8 in your dependencies?
Find it across Go, including transitive dependencies.