CVE-2026-25766: Github.com/labstack/echo/v5 Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-pgvm-wxw2-hrv9
CVSS 5.3
CWE-22
Published
Advisory Summary

CVE-2026-25766 is a MODERATE (CVSS 5.3) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Github.com/labstack/echo/v5 libraries in the Go ecosystem. The issue involves echo has a windows path traversal via backslash in middleware.static default filesystem. Remediation is available by upgrading affected packages to version 5.0.3.

CVE-2026-25766 at a Glance

CVE Identifier CVE-2026-25766
GHSA Identifier GHSA-pgvm-wxw2-hrv9
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Github.com/labstack/echo/v5
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-25766

To remediate this vulnerability, upgrade all affected Github.com/labstack/echo/v5 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/labstack/echo/v5 fixed: 5.0.3
Upgrade github.com/labstack/echo/v5 to 5.0.3
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/labstack/echo/v5

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-25766, inspect your project dependencies for Github.com/labstack/echo/v5:

inspect dependencies for github.com/labstack/echo/v5

Analyze the terminal output to locate any version of Github.com/labstack/echo/v5 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.0.3), 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 Github.com/labstack/echo/v5, 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 On Windows, Echo’s `middleware.Static` using the default filesystem allows path traversal via backslashes, enabling unauthenticated remote file read outside the static root. ### Details In `middleware/static.go`, the requested path is unescaped and normalized with `path.Clean` (URL semantics). `path.Clean` does **not** treat `\` as a path separator, so `..\` sequences remain in the cleaned path. The resulting path is then passed to `currentFS.Open(...)`. When the filesystem is left at the default (nil), Echo uses `defaultFS` which calls `os.Open` (`echo.go:792`). On Windows, `os.Open` treats `\` as a path separator and resolves `..\`, allowing traversal outside the static root. Relevant code: - `middleware/static.go` (path unescape + `path.Clean` + `currentFS.Open`) - `echo.go` `defaultFS.Open` → `os.Open` This is the same class as CVE-2020-36565 (fixed in v4 by switching to OS-aware cleaning), but in v5 the `path.Clean` + defaultFS combination reintroduces the Windows backslash traversal. ### PoC Windows only. **Sample code (main.go):** ```go package main import ( "log" "net/http" "github.com/labstack/echo/v5" "github.com/labstack/echo/v5/middleware" ) func main() { e := echo.New() // Important: use middleware.Static with default filesystem (nil) e.Use(middleware.Static("public")) e.GET("/healthz", func(c *echo.Context) error { return c.String(http.StatusOK, "ok") }) addr := ":1323" log.Printf("listening on %s", addr) if err := e.Start(addr); err != nil && err != http.ErrServerClosed { log.Fatal(err) } } ``` Static file: public/index.html (content can be any HTML) **Run:** go run . **Verify:** curl http://localhost:1323/index.html curl --path-as-is "http://localhost:1323/..%5c..%5cWindows%5cSystem32%5cdrivers%5cetc%5chosts" Expected: 404 **Screenshot:** <img width="884" height="689" alt="image" src="https://github.com/user-attachments/assets/acb14d70-2a43-47c1-8927-2f3da491a853" /> <img width="1022" height="162" alt="image" src="https://github.com/user-attachments/assets/f2b92aa2-541e-461d-81a2-8a5907d7a447" /> ### Impact Path traversal leading to arbitrary file read outside the static root. Any unauthenticated remote user can read local files that the Echo process has access to on Windows, if `middleware.Static` is used with the default filesystem.

CVE-2026-25766 Affected Github.com/labstack/echo/v5 Versions

1 component(s)
Fixed Versions:
5.0.3
Product / Package Ecosystem Affected Versions Fixed Version
github.com/labstack/echo/v5
Go
≥ 5.0.0
< 5.0.3
5.0.3

References

Frequently Asked Questions

What is CVE-2026-25766?
CVE-2026-25766 is a security vulnerability in Github.com/labstack/echo/v5 involving Echo has a Windows path traversal via backslash in middleware.Static default filesystem under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Github.com/labstack/echo/v5 versions are affected?
Affected versions include releases prior to 5.0.3 across affected packages: github.com/labstack/echo/v5.
What version fixes CVE-2026-25766?
Upgrading to 5.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/labstack/echo/v5 affected?
Yes, github.com/labstack/echo/v5 is affected in releases prior to 5.0.3. Upgrade your dependency to 5.0.3 or later.
What is the CVSS score of CVE-2026-25766?
CVE-2026-25766 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2026-25766?
CVE-2026-25766 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-25766?
Run the dependency tree command: 'inspect dependencies for github.com/labstack/echo/v5'. 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-pgvm-wxw2-hrv9",
  "modified" : "2026-02-27T22:07:05Z",
  "published" : "2026-02-17T18:53:58Z",
  "aliases" : [ "CVE-2026-25766" ],
  "summary" : "Echo has a Windows path traversal via backslash in middleware.Static default filesystem",
  "details" : "### Summary\nOn Windows, Echo’s `middleware.Static` using the default filesystem allows path traversal via backslashes, enabling\nunauthenticated remote file read outside the static root.\n\n### Details  \n\n  In `middleware/static.go`, the requested path is unescaped and normalized with `path.Clean` (URL semantics).\n  `path.Clean` does **not** treat `\\` as a path separator, so `..\\` sequences remain in the cleaned path. The resulting\n  path is then passed to `currentFS.Open(...)`. When the filesystem is left at the default (nil), Echo uses `defaultFS`\n  which calls `os.Open` (`echo.go:792`). On Windows, `os.Open` treats `\\` as a path separator and resolves `..\\`,\n  allowing traversal outside the static root.\n\n  Relevant code:\n  - `middleware/static.go` (path unescape + `path.Clean` + `currentFS.Open`)\n  - `echo.go` `defaultFS.Open` → `os.Open`\n\n  This is the same class as CVE-2020-36565 (fixed in v4 by switching to OS-aware cleaning), but in v5 the `path.Clean`\n  + defaultFS combination reintroduces the Windows backslash traversal.\n\n\n### PoC\n Windows only.\n\n  **Sample code (main.go):**\n  ```go\n  package main\n\n  import (\n        \"log\"\n        \"net/http\"\n\n        \"github.com/labstack/echo/v5\"\n        \"github.com/labstack/echo/v5/middleware\"\n  )\n\n  func main() {\n        e := echo.New()\n\n        // Important: use middleware.Static with default filesystem (nil)\n        e.Use(middleware.Static(\"public\"))\n\n        e.GET(\"/healthz\", func(c *echo.Context) error {\n                return c.String(http.StatusOK, \"ok\")\n        })\n\n        addr := \":1323\"\n        log.Printf(\"listening on %s\", addr)\n        if err := e.Start(addr); err != nil && err != http.ErrServerClosed {\n                log.Fatal(err)\n        }\n  }\n ```\n  Static file:\n\n  public/index.html\n\n  (content can be any HTML)\n\n  **Run:**\n  go run .\n\n  **Verify:**\n\n  curl http://localhost:1323/index.html\n  curl --path-as-is \"http://localhost:1323/..%5c..%5cWindows%5cSystem32%5cdrivers%5cetc%5chosts\"\n  Expected: 404  \n\n  **Screenshot:**\n<img width=\"884\" height=\"689\" alt=\"image\" src=\"https://github.com/user-attachments/assets/acb14d70-2a43-47c1-8927-2f3da491a853\" />\n<img width=\"1022\" height=\"162\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f2b92aa2-541e-461d-81a2-8a5907d7a447\" />\n\n\n\n  ### Impact\n  Path traversal leading to arbitrary file read outside the static root. Any unauthenticated remote user can\n  read local files that the Echo process has access to on Windows, if `middleware.Static` is used with the default\n  filesystem.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/labstack/echo/v5"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/labstack/echo/security/advisories/GHSA-pgvm-wxw2-hrv9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-25766"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/labstack/echo/pull/2891"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/labstack/echo/commit/b1d443086ea27cf51345ec72a71e9b7e9d9ce5f1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/labstack/echo"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2026-4502"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-17T18:53:58Z",
    "nvd_published_at" : "2026-02-19T16:27:15Z"
  }
}