CVE Professor
/
All CVEs
CVE-2026-140395

CVE-2026-140395 — CWE-22

HIGH CVSS 7.5 NVD

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.

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.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Attack Vector Network AV:N
Attack Complexity Low AC:L
Privileges Req. None PR:N
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity None I:N
Availability None A:N
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE-2026-140395 is a Path Traversal (CWE-22) vulnerability in the Hugo static site generator. The flaw resides in how Hugo processes module imports defined in the _vendor/modules.txt file.

Technical Flaw Analysis

1. Missing Input Validation: Hugo fails to sanitize or restrict the file paths specified in the import statements within _vendor/modules.txt. Specifically, it does not prevent the use of relative path traversal sequences (..) that escape the intended module directory. 2. Arbitrary Directory Resolution: By supplying .. segments, an attacker can manipulate Hugo’s internal file resolution logic to treat any directory on the build host as a valid "module root." 3. Privileged File Access: Once an arbitrary directory is treated as a module root, Hugo’s standard module functionality (such as readFile in templates or static file mounting) can be abused to read files from that directory. 4. Data Exfiltration via Static Site: The critical impact mechanism is that Hugo is a static site generator. When it "reads" a sensitive file (e.g., /etc/passwd, ~/.ssh/id_rsa, or environment variable files) during the build process, it can embed the contents of that file into the generated HTML/CSS/JS assets. These assets are then served to any visitor of the website, effectively publishing the secrets to the public internet.

CVSS Vector Interpretation

  • AV:N (Network): Exploitable remotely.
  • AC:L (Low Complexity): No special conditions required; standard file path manipulation.
  • PR:N (No Privileges): The attacker does not need to be authenticated to Hugo or the web server. However, they must have the ability to influence the content of _vendor/modules.txt (e.g., via a compromised theme, a malicious module dependency, or a CI/CD pipeline that pulls untrusted modules).
  • UI:N (No User Interaction): No victim interaction required.
  • C:H (High Confidentiality): Full access to arbitrary files on the build host.
  • I:N / A:N: No direct integrity or availability impact on the target* system, though the published site may contain malicious content if the attacker controls the theme.
    Critical Note: The PR:N vector implies that the vulnerability is triggered during the build process. In a typical deployment, the "attacker" is not a remote user hitting an HTTP endpoint, but rather a malicious dependency (theme/module) that is pulled into the build environment. The "network" aspect refers to the fact that the malicious module is fetched over the network (e.g., from a Git repository), and the resulting static site is served over the network.

    ⚡ Attack Chain

    1. Discovery & Reconnaissance

  • Identify Hugo Site: Use tools like wappalyzer, whatweb, or manual inspection of HTML comments (<!-- Generated by Hugo vX.Y.Z -->) to confirm the target uses Hugo.
  • Version Fingerprinting: Check the Hugo version in the footer, meta tags, or build logs if accessible. Confirm the version is between 0.56.0 and 0.169.x.
  • Identify Build Pipeline: Determine if the site is built in a CI/CD environment (GitHub Actions, GitLab CI, Jenkins) or locally. The vulnerability is exploited during the build, not at runtime.
  • 2. Exploitation

    The attacker must inject a malicious _vendor/modules.txt file or a malicious module that modifies it. This is typically achieved by:
  • Malicious Theme/Module: Publishing a malicious theme or module to a public repository (e.g., GitHub) that contains a crafted _vendor/modules.txt.
  • Supply Chain Attack: Compromising a legitimate module dependency to include the malicious import path.
  • Illustrative PoC (Conceptual):

    Assume the attacker has control over a module named evil-module that is imported by the target site. The attacker creates a file evil-module/_vendor/modules.txt with the following content:

    # Illustrative malicious _vendor/modules.txt
    # This attempts to traverse to the root directory and treat it as a module
    import /etc

    Or, more realistically, using relative traversal to escape the module directory:

    # If the module is located at /build/site/themes/evil-module
    # This attempts to traverse up to /build/site and then to /etc
    import ../../../../etc

    Hugo Build Command (Attacker-controlled or compromised CI/CD):

    hugo --source /build/site --destination /build/public

    Template Exploitation (in the malicious theme):
    In the malicious theme’s layouts/index.html, the attacker uses Hugo’s readFile function to read a sensitive file from the traversed directory:

    <!-- Illustrative template code in malicious theme -->
    <div class="hidden">
      {{ readFile "passwd" }}
    </div>
    Note: The exact syntax of readFile and the path resolution behavior depend on the specific Hugo version and configuration. The above is an illustrative example of the vulnerability class. The key is that readFile or static mounts will resolve the path relative to the (traversed) module root.

    3. Post-Exploitation

    1. Build Execution: The CI/CD pipeline or local developer runs hugo. 2. File Reading: Hugo processes _vendor/modules.txt, resolves the .. paths, and treats /etc (or another sensitive directory) as a module root. 3. Content Injection: The template’s readFile call reads /etc/passwd (or ~/.ssh/id_rsa, .env, etc.) and embeds the content into the generated index.html. 4. Deployment: The static site is deployed to a web server. 5. Exfiltration: Any visitor to the site can view the sensitive data in the HTML source. The attacker can also monitor the site for the published secrets.

    🌍 Real World Impact

  • Confidentiality (High):
  • * Build Host Secrets: Exposure of environment variables (.env), API keys, database credentials, and SSH private keys stored on the build host. * System Files: Exposure of /etc/passwd, /etc/shadow (if readable), and other system configuration files. * Source Code: Exposure of the site’s source code, including any hardcoded secrets.
  • Integrity (None): The vulnerability does not allow modification of files on the build host. However, the generated site may contain malicious content if the attacker controls the theme.
  • Availability (None): No direct impact on the availability of the build host or the web server.
  • Practical Consequences:

  • Credential Theft: Attackers can steal credentials used in the CI/CD pipeline, leading to further compromise of the organization’s infrastructure.

  • Lateral Movement: Stolen SSH keys or API tokens can be used to move laterally within the network.

  • Reputation Damage: Public exposure of sensitive data can lead to significant reputational harm and regulatory penalties (e.g., GDPR, HIPAA).
  • 🛡️ Remediation & Mitigation

    1. Upgrade (Primary Fix)

  • Affected Versions: Hugo 0.56.0 through 0.169.x.
  • Fixed Version: Hugo 0.170.0 and later.
  • Action: Immediately upgrade Hugo to the latest stable version (0.170.0+).
  • 2. Workarounds (If Upgrade is Not Immediately Possible)

  • Restrict Module Sources: Only import modules from trusted, internal repositories. Avoid pulling modules from public, untrusted sources.
  • Sanitize _vendor/modules.txt: Implement a pre-build check that scans _vendor/modules.txt for .. sequences and rejects the build if found.
  • * Example Bash Script:
    if grep -q '\.\.' _vendor/modules.txt; then
                echo "ERROR: Path traversal detected in _vendor/modules.txt"
                exit 1
            fi
  • Run Builds in a Sandboxed Environment: Use Docker or a similar containerization technology to isolate the build process. Ensure the container has minimal permissions and does not have access to sensitive host files (e.g., mount only the necessary source code directory).
  • Disable readFile in Templates: If possible, configure Hugo to disable the readFile function in templates, or restrict its usage to trusted templates only.
  • 3. Detection

  • Web Server Logs: Look for requests to the generated site that reveal sensitive data in the HTML source. This is difficult to detect automatically, but manual review of the generated HTML for unexpected content (e.g., base64-encoded SSH keys, environment variables) is recommended.
  • Build Logs: Monitor build logs for errors or warnings related to file path resolution.
  • File Integrity Monitoring (FIM): Implement FIM on the build host to detect unauthorized changes to _vendor/modules.txt or other critical files.
  • IoCs:
  • * Presence of .. in _vendor/modules.txt. * Unexpected large files or sensitive data in the generated static site. * Unusual network connections from the build host to external repositories.

    ⚠️ Urgency

  • CVSS Score: 7.5 (HIGH)
  • CISA KEV: No
  • Exploit Complexity: Low (if the attacker can control the module source)
  • Patching Priority: HIGH
Recommendation: 1. Immediate: Upgrade Hugo to 0.170.0 or later. 2. Short-term: Audit all modules and themes for malicious _vendor/modules.txt files. 3. Long-term: Implement strict supply chain security practices, including code signing for modules and sandboxed build environments.
Note: While the CVSS score is 7.5, the real-world impact can be significantly higher if the build host has access to sensitive credentials. Treat this as a critical vulnerability in any environment where the build host is not fully isolated.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)
PoC & Exploit Intelligence (GitHub)
Technical reference / advisory repository for CVE-2026-140395
CVSS Score
7.5 / 10 · CVSS HIGH
Weakness Types (CWE)
References & Advisories (2)
Related CVEs
9.9
CVE-2026-77526
FacturaScripts is an open source accounting and invoicing software. From version 2025 to before version 2026.3
9.8
CVE-2026-145055
PraisonAI pip praisonai before 4.8.0, praisonaiagents and npm praisonai before 1.8.0, and praisonai-bot, prais
9.4
CVE-2026-129109
Calico installations managed by the Tigera Operator install a FlexVolume driver (nodeagent~uds/uds) on every L
9.4
CVE-2026-64883
Path traversal in the WebDAV interface (DotWebdavHelper and the WebDAV temporary-file COPY and MOVE handling)
8.6
CVE-2026-115524
Path traversal in the push-publish bundle receiver (BundlePublisherResource, /api/bundlePublisher/publish) in
8.3
CVE-2026-144679
Thanos through 0.42.5 contains a path traversal vulnerability in Receive that allows unauthenticated remote-wr
8.3
CVE-2026-118326
Improper limitation of a pathname to a restricted directory in attendance photo upload workflow in ZKTeco BioT