Read the docs

Path traversal in Hugo lets themes read files on the build host

Priority MEDIUM 45CWE-22Published · Updated

Key facts

Attack vector
Local
Privileges required
None
User interaction
Active
Attack complexity
Low
Attack requirements
None
Impact type
Information disclosure
Confidentiality · integrity · availability
High · None · None
Fix status
Fixed

Attack profile from CVSS 4.0 · GHSA-r48v-r4vw-h9v8. Fix status from GitHub. Impact type from CWE-22 and the CVSS impact.

Summary

Hugo, a static site generator, has a path traversal flaw in vendored module metadata from version 0.56.0 before 0.170.0. Hugo uses an import path from _vendor/modules.txt as a module root without checking that it stays inside the vendor directory (CWE-22). An attacker who supplies an untrusted theme or module can make Hugo read files anywhere on the build host, and those files can be published in the generated site. The attacker needs only that a site builds with the untrusted theme, with no further configuration change.

Written with Claude Haiku 5.5 from the sources below · 2026-12-01

Description from the GitHub advisory

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

Why it matters now

Fix Fixed github.com/gohugoio/hugo (Go): 0.170.0

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—github.com/gohugoio/hugo (Go)0.56.0 to before 0.170.00.170.0Patch availableGHSA-r48v-r4vw-h9v8
  • github.com/gohugoio/hugo (Go) Vendor— Affected 0.56.0 to before 0.170.0 Fixed in 0.170.0 Patch available GHSA-r48v-r4vw-h9v8

Remediation

Upgrade github.com/gohugoio/hugo to version 0.170.0 or later, which rejects non-local module paths in modules.txt.

Written with Claude Haiku 5.5 from the sources below · 2026-12-01

  • Fix · GHSA-r48v-r4vw-h9v8 github.com/gohugoio/hugo (Go) Fixed in 0.170.0 Advisory →

Timeline

  1. 2026-12-01 Threatist record created from GHSA-r48v-r4vw-h9v8

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences