Skip to content
High 8.7

Hugoに脆弱性、悪意あるテーマやモジュールで任意のファイルを読まれるおそれ

CVE-2026-140395 First seen on SecPulse

Summary

Hugoの0.56.0から0.170.0より前の版に、パストラバーサルの脆弱性があります。悪意のあるテーマやモジュールが_vendor/modules.txtに「..」を含むパスを書くと、ビルドを実行する環境の任意のファイルを読み取り、生成されたサイトに公開されるおそれがあります。修正版の0.170.0以降に更新してください。

AI summary

Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.

Hugoの0.56.0から0.170.0より前の版に、パストラバーサルの脆弱性があります。悪意のあるテーマやモジュールが_vendor/modules.txtに「..」を含むパスを書くと、ビルドを実行する環境の任意のファイルを読み取り、生成されたサイトに公開されるおそれがあります。修正版の0.170.0以降に更新してください。

Affected packages

PackageAffected → Fixed
gohugoiohugo
≥ 0.56.0, < 0.170.0→ 0.170.0
Gogithub.com/gohugoio/hugo
≥ 0.56.0, < 0.170.0→ 0.170.0
Original description The description as published by the source.

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 ha…

Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details