REDHAT-BUG-2497460: Medium severity Hugo Hugo vulnerability
Hugo is a static site generator. From v0.123.0 through v0.163.0, Hugo's virtual filesystem is designed so that files under a mount cannot reach outside the mount tree, but a regression caused RootMappingFs.statRoot to call Stat, which follows symlinks, instead of Lstat, so a direct os.ReadFile "somefile" where somefile was a symlink pointing outside the mount would return the target's contents. This effectively let a symlink planted inside a theme or local mount read arbitrary files reachable to the user running hugo. This issue is fixed in v0.163.1.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in v0.163.1
Event History
Frequently Asked Questions
Who is exposed to this issue?
Users running affected Hugo versions from v0.123.0 through v0.163.0 are exposed when Hugo processes a theme or local mount containing a symlink that points outside its mount tree. The symlink can read files that are reachable by the user account running Hugo.
What does an attacker need to exploit it?
An attacker needs to plant a symlink inside a theme or local mount and have Hugo perform a direct os.ReadFile on that symlink. The symlink target must be readable by the account that runs Hugo.
Are default Hugo installations affected?
The issue depends on Hugo processing a malicious or untrusted symlink within a theme or local mount; the provided information does not establish that a default installation is affected without such content.
What should be done if updating is not immediately possible?
Avoid processing untrusted themes or local mounts, and review mounted content for symlinks that point outside the intended mount tree. Run Hugo with an account that has access only to files required for the build.
How can I tell whether my environment is affected?
Check whether the deployed Hugo version is between v0.123.0 and v0.163.0 inclusive, and inspect themes and local mounts for symlinks targeting paths outside their mount trees. The issue is fixed in v0.163.1.