{"id":"CVE-2026-140395","aliases":["CVE-2026-140395","GHSA-r48v-r4vw-h9v8"],"related":[],"kind":"vulnerability","state":"published","title":"Hugo 0.56.0 before 0.170.0 Path Traversal via _vendor/modules.txt","summary":"Hugo from 0.56.0 before 0.170.0 contains a path traversal vulnerability that allows malicious themes or modules to read arbitrary build host files by supplying '..' segments in _vendor/modules.txt import paths. Attackers can make Hugo treat any directory as a module root and use readFile or static mounts to publish secrets, credentials, and system files in the generated site.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Hugo from 0.56.0 before 0.170.0 contains a path traversal vulnerability that allows malicious themes or modules to read arbitrary build host files by supplying '..' segments in _vendor/modules.txt import paths. Attackers can make Hugo treat any directory as a module root and use readFile or static mounts to publish secrets, credentials, and system files in the generated site.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nA 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.\n\n### Details\n\n`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).\n\nThe fix rejects any `modules.txt` path that is not local (`filepath.IsLocal`), so the build fails with an `invalid module path` error.\n\n### Proof of concept\n\nA 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.\n\n\n### Impact\n\nAnyone 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.","format":"markdown","source":"ghsa"}],"published":"2026-12-01T02:23:54.000Z","modified":"2026-12-01T16:11:17.277Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","rating":"MEDIUM"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"type":"semver","introduced":"0.56.0","fixed":"0.170.0","status":"affected"},{"type":"semver","version":"0.170.0","status":"unaffected"}],"vendor":"gohugoio","product":"hugo","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.56.0","status":"affected","fixed":"0.170.0"}],"ecosystem":"Go","package":"github.com/gohugoio/hugo","purl":"pkg:golang/github.com/gohugoio/hugo","source":"ghsa"}],"references":[{"url":"https://github.com/gohugoio/hugo/security/advisories/GHSA-r48v-r4vw-h9v8","tags":["vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/hugo-0.56.0-before-0.170.0-path-traversal-via-vendor-modules-txt","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/gohugoio/hugo/pull/15564","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/gohugoio/hugo/commit/d41a8a196e6b2fd5e5aa886c790d6c679dd73be0","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/gohugoio/hugo","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/gohugoio/hugo/releases/tag/v0.170.0","tags":["web"],"sources":["ghsa"]}],"credits":["R0X4R"],"assigner":"VulnCheck","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-140395","url":"https://www.cve.org/CVERecord?id=CVE-2026-140395","licence":"CVE Terms of Use","modified":"2026-12-01T14:29:10.962Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-r48v-r4vw-h9v8","url":"https://github.com/advisories/GHSA-r48v-r4vw-h9v8","licence":"CC-BY-4.0","modified":"2026-12-01T16:11:17.277Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-140395","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140395","licence":"Public domain","modified":"2026-12-01T15:18:05.003Z"}],"updatedAt":"2026-12-01T16:27:08.948Z"}