GHSA-R73Q-GWX2-FPXM: GHSA-r73q-gwx2-fpxm: Arbitrary Host Directory Mount and Sandbox Bypass via Theme Module Replacements in…
GHSA-r73q-gwx2-fpxm: Arbitrary Host Directory Mount and Sandbox Bypass via Theme Module Replacements in Hugo Vulnerability ID: GHSA-R73Q-GWX2-FPXM CVSS Score: 6.8 Published: 2026-11-30 Hugo versions 0.152.0 through
GHSA-r73q-gwx2-fpxm: Arbitrary Host Directory Mount and Sandbox Bypass via Theme Module Replacements in Hugo
Vulnerability ID: GHSA-R73Q-GWX2-FPXM
CVSS Score: 6.8
Published: 2026-11-30
Hugo versions 0.152.0 through 0.167.x contain a path traversal and sandbox bypass vulnerability in the module configuration loader. When a root project does not define module replacements, Hugo permits imported themes or modules to define their own module.replacements directives. Because replaced module imports are internally marked as project-replaced, they bypass theme directory path restrictions, allowing an untrusted theme to mount arbitrary host filesystem directories and expand the Node.js read sandbox.
TL;DR
A flaw in Hugo's module configuration parser allows untrusted themes to define module.replacements when the root project leaves them unset. This marks theme imports as trusted project replacements, bypassing directory traversal checks (CWE-22) and allowing arbitrary host paths to be mounted into the site build and Node.js asset pipeline. Upgrade to Hugo v0.168.0 to remediate.
⚠️ Exploit Status: POC
Technical Details
- Advisory ID: GHSA-r73q-gwx2-fpxm
- Weakness Class: CWE-22 (Path Traversal) / CWE-552
- CVSS v4.0 Score: 6.8 Medium (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)
- Attack Vector: Local / Build-time via Untrusted Hugo Theme or Module
- Affected Versions: >= 0.152.0, < 0.168.0
- Patched Version: v0.168.0
- Primary Impact: Arbitrary Host Directory Mount & Node.js Read Sandbox Escape
- Exploit Status: Proof-of-Concept (Regression Test in Upstream Patch)
Affected Systems
- github.com/gohugoio/hugo (>= 0.152.0, < 0.168.0)
-
Hugo: >= 0.152.0, < 0.168.0 (Fixed in:
0.168.0)
Code Analysis
Commit: 6883b55
modules: Ignore module.replacements defined in themes
diff --git a/hugofs/hugofs_integration_test.go b/hugofs/hugofs_integration_test.go
index 4988f2d8c3c..4f24f124e67 100644
--- a/hugofs/hugofs_integration_test.go
+++ b/hugofs/hugofs_integration_test.go
@@ -147,3 +147,26 @@ Title: {{ .Title }}|
b.AssertFileContent("public/fr/page/index.html", "Title: Page Française|")
b.AssertLogContains("! deprecated")
}
+
+func TestMountRestrictThemeReplacements(t *testing.T) {
+ files := `
+-- hugo.toml --
+disableKinds = ["taxonomy", "term", "rss"]
+theme = "mytheme"
+-- themes/mytheme/hugo.toml --
+[module]
+replacements = "evil -> ../../secret"
+[[module.imports]]
+path = "evil"
+[[module.imports.mounts]]
+source = "."
+target = "assets"
+-- secret/file1.txt --
+file1
+-- layouts/all.html --
+All.
+`
+ b, err := hugolib.TestE(t, files)
+ b.Assert(err, qt.IsNotNil)
+ b.Assert(err.Error(), qt.Contains, `module "evil" not found`)
+}
diff --git a/modules/collect.go b/modules/collect.go
index 5680f065c01..04d9c19ad79 100644
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -527,7 +527,12 @@ LOOP:
}
}
- config, err := decodeConfig(c.logger.Logger(), tc.cfg, c.moduleConfig.replacementsMap)
+ // Only the project can define replacements.
+ replacements := c.moduleConfig.replacementsMap
+ if replacements == nil {
+ replacements = map[string]string{}
+ }
+ config, err := decodeConfig(c.logger.Logger(), tc.cfg, replacements)
if err != nil {
return err
}
Exploit Details
- GitHub Security Advisory: Official security advisory detailing the theme module.replacements sandbox bypass and Node.js read permission expansion.
- GitHub Commit (Regression Test PoC): Upstream fix commit containing TestMountRestrictThemeReplacements in hugofs/hugofs_integration_test.go demonstrating the exploit configuration.
Mitigation Strategies
- Upgrade Hugo to v0.168.0 or later to enforce strict isolation of module.replacements to the root project configuration.
- Configure a dummy module.replacements entry in the root project's hugo.toml if running a vulnerable version (v0.152.0 to v0.167.x) to ensure c.moduleConfig.replacementsMap is non-nil.
- Audit all third-party theme configuration files (hugo.toml, config.toml, config.yaml, config.json) under themes/ and _vendor/ for unexpected module.replacements directives.
- Execute automated Hugo builds inside isolated container environments with minimal host filesystem access and no persistent secrets stored on disk.
Remediation Steps:
- Check the active Hugo version in local and CI/CD environments by running 'hugo version'.
- If the version is between v0.152.0 and v0.167.x inclusive, update the Hugo binary or container image to v0.168.0 or newer.
- Inspect third-party themes using 'grep -rn "replacements" themes/' to verify that no external theme attempts to use module replacement directives.
- Verify the remediation by running 'hugo config mounts' to confirm all mounted source paths resolve strictly within the project root or expected theme directories.
References
- GitHub Security Advisory: GHSA-r73q-gwx2-fpxm
- Upstream Pull Request #15426
- Official Fix Commit: modules: Ignore module.replacements defined in themes
- Hugo v0.168.0 Release Notes
- Hugo Official GitHub Repository
Read the full report for GHSA-R73Q-GWX2-FPXM on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.