/

CVE-2026-40611

Severity:

HIGH RISK

(8.8)

Path Traversal in Lego ACME Webroot HTTP-01 Provider

CVE-2026-40611

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write and Deletion

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The Lego ACME client's webroot HTTP-01 challenge provider allowed crafted challenge tokens to perform path traversal, leading to arbitrary file write and deletion wherever the lego process had filesystem permissions.

Under a malicious or compromised ACME server, this can be abused to overwrite or remove files outside the intended webroot directory, enabling configuration tampering, site defacement, or further compromise.

Affected context

This vulnerability affects deployments that:

  • Use the Lego ACME client/library in versions prior to 4.34.0
  • Rely on the webroot HTTP-01 challenge provider to write HTTP-01 challenge files
  • Trust ACME challenge tokens coming from an ACME server without additional validation

The issue is most relevant where the lego process runs with permissions to write to sensitive directories (e.g., webroot, configuration paths, or shared volumes).

Exploit preconditions

  • Attack surface: Interaction between lego and an ACME server using the HTTP-01 webroot provider.
  • Required access: Control over or ability to impersonate the ACME server, or a scenario where the ACME server itself is compromised or malicious.
  • Trigger point: Submission of a crafted HTTP-01 challenge token containing ../ path traversal sequences, which lego then uses to construct filesystem paths for challenge files.
  • Why exploitation is possible: The webroot provider constructs file paths directly from the ACME-supplied token without canonicalization or restriction to the intended webroot directory, allowing traversal outside the target directory.

Why this happens

The core issue is improper neutralization of path traversal sequences when building filesystem paths from untrusted input.

The HTTP-01 webroot provider takes the challenge token received from the ACME server and concatenates it to the configured webroot path to create challenge files.

Without cleaning, normalizing, or validating the resulting path, ../ sequences in the token allow the resulting path to escape the intended webroot directory.

This behavior corresponds to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controllable path components are not constrained to a safe, expected directory tree.

Potential impact

  • Overwriting existing files within any directory writable by the lego process
  • Creating new files in unintended locations, potentially enabling web shell drops or configuration backdoors
  • Deleting files that lego is permitted to remove, potentially causing denial of service or application misconfiguration
  • Tampering with web content, leading to site defacement or phishing content injection
  • Indirect elevation of impact if overwritten files include scripts, configuration, or access control metadata

General mitigation guidance

Effective mitigation focuses on constraining filesystem access patterns and treating all externally influenced path components as untrusted.

Recommended defensive patterns include:

  • Normalizing and validating constructed paths, then enforcing that they remain within the configured webroot (e.g., checking prefix after path canonicalization).
  • Rejecting challenge tokens or filename components that contain path traversal markers such as ../, absolute paths, or null bytes.
  • Using filesystem abstractions or helpers that implement "chroot-like" behavior at the application layer, restricting all writes to a bounded directory tree.
  • Running lego with the least filesystem privileges necessary, ideally under a dedicated user with write access only to a tightly scoped webroot directory.
  • Segregating webroot challenge directories from sensitive configuration, logs, and application code to reduce the blast radius of any incorrect writes.

How teams detect issues like this

Detection typically combines code-level inspection with runtime monitoring:

  • Static analysis: Rules that flag usages where untrusted tokens or request data are concatenated into filesystem paths without sanitization or canonicalization.
  • Code review cues: Any path constructed using external protocol data (such as ACME challenge tokens) should be reviewed for:
  • Missing checks for .., absolute paths, or illegal characters
  • Absence of path canonicalization and "stay within root" enforcement
  • Runtime monitoring: File integrity monitoring around webroot and nearby directories to detect unexpected file creations or modifications by the lego process.
  • Policy enforcement: CI/CD checks that enforce secure path handling patterns for modules dealing with file I/O based on external or remote inputs.

Sources

SourceLink
github.comgithub.com/go-acme/lego/security/advisories/GHSA-qqx8-2xmm-jrv8
access.redhat.comaccess.redhat.com/errata/RHSA-2026:21772
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-40611
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2460233
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40611.json

Frequently asked

questions

Yes, in the sense that it can be triggered via remote interaction if an attacker can control, impersonate, or compromise the ACME server that lego communicates with. The attack traffic rides over the normal ACME protocol rather than direct HTTP requests to the vulnerable host.

An attacker needs influence over the ACME challenge tokens provided to lego's webroot HTTP-01 provider. This typically means full or partial control of the ACME server, a man-in-the-middle position on the ACME connection, or use of an intentionally malicious ACME endpoint.

The robust fix pattern is to strictly constrain all challenge file paths to a predefined directory by canonicalizing the path and verifying that it remains within the configured webroot. Any token that would result in a path outside this directory should be rejected.

Treat all external strings used for filesystem operations as untrusted, apply defensive path normalization and validation, enforce directory boundaries, and incorporate static analysis and security-focused code review for any logic that constructs file paths from protocol or user inputs.

Find out what's already
exploitable in your codebase.