GHSA-M3C2-496V-CW3V

Vulnerability from github – Published: 2026-02-24 20:51 – Updated: 2026-02-24 20:51
VLAI?
Summary
Fiber has an Arbitrary File Read in Static Middleware on Windows
Details

Summary

Description A Path Traversal (CWE-22) vulnerability in Fiber allows a remote attacker to bypass the static middleware sanitizer and read arbitrary files on the server file system on Windows. This affects Fiber v3 through version 3.0.0. This has been patched in Fiber v3 version 3.1.0.

Details

The vulnerability resides in middleware/static/static.go within the sanitizePath function. This function attempts to sanitize the requested path by checking for backslashes, decoding the URL, and then cleaning the path.

The vulnerability stems from two combined issues: - The check for backslash characters happens before the URL decoding loop. If an attacker sends a double-encoded backslash, the initial check sees %255C and passes. The loop then decodes this into a single backslash. - The function uses path.Clean to clean the resulting string. path.Clean is designed for slash-separated paths and does not recognize backslashes as directory separators. Consequently, sequences like ..\..\ are treated as valid filenames.

When this sanitized path is later used, the backslashes are interpreted as valid separators, allowing the attacker to traverse up the directory tree.

// pkg/static/static.go
func sanitizePath(p []byte, filesystem fs.FS) ([]byte, error) {
    ...
    // this check happens BEFORE decoding
    if bytes.IndexByte(p, '\\') >= 0 {
        ...
    } 
    // This loop decodes %255C to %5C to \
    for strings.IndexByte(s, '%') >= 0 {
        us, err := url.PathUnescape(s)
        ...
        s = us
    }
    // path.Clean only understands forward slashes (/)
    s = pathpkg.Clean("/" + s)
    ...
    return utils.UnsafeBytes(s), nil
}

Impact

This impacts Fiber v3 prereleases through stable release version 3.0.0.

Successful exploitation requires the server to be using the static middleware on Windows, as this is the only OS where backslashes are treated as directory separators by the file system.

Exploitation allows directory traversal on the host server. An attacker can read arbitrary files within the scope of the application server context. Depending on permissions and deployment conditions, attackers may access sensitive files outside the web root, such as configuration files, source code, or system files. Leaking application secrets often leads to further compromise.

Patches

This has been patched in Fiber v3 version 3.0.1. Users are strongly encouraged to update to the latest available release.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 3.0.0"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/gofiber/fiber/v3"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "3.1.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-25891"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-22"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-02-24T20:51:01Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "### Summary\n\n**Description**\nA Path Traversal (CWE-22) vulnerability in Fiber allows a remote attacker to bypass the static middleware sanitizer and read arbitrary files on the server file system on Windows. This affects Fiber v3 through version 3.0.0. This has been patched in Fiber v3 version 3.1.0.\n \n### Details\nThe vulnerability resides in `middleware/static/static.go` within the `sanitizePath` function. This function attempts to sanitize the requested path by checking for backslashes, decoding the URL, and then cleaning the path.\n\nThe vulnerability stems from two combined issues:\n- The check for backslash characters happens before the URL decoding loop. If an attacker sends a double-encoded backslash, the initial check sees `%255C` and passes. The loop then decodes this into a single backslash.\n- The function uses `path.Clean` to clean the resulting string. `path.Clean` is designed for slash-separated paths  and does not recognize backslashes as directory separators. Consequently, sequences like `..\\..\\` are treated as valid filenames.\n\nWhen this sanitized path is later used, the backslashes are interpreted as valid separators, allowing the attacker to traverse up the directory tree.\n```go\n// pkg/static/static.go\nfunc sanitizePath(p []byte, filesystem fs.FS) ([]byte, error) {\n    ...\n    // this check happens BEFORE decoding\n    if bytes.IndexByte(p, \u0027\\\\\u0027) \u003e= 0 {\n        ...\n    } \n    // This loop decodes %255C to %5C to \\\n    for strings.IndexByte(s, \u0027%\u0027) \u003e= 0 {\n        us, err := url.PathUnescape(s)\n        ...\n        s = us\n    }\n    // path.Clean only understands forward slashes (/)\n    s = pathpkg.Clean(\"/\" + s)\n    ...\n    return utils.UnsafeBytes(s), nil\n}\n```\n\n### Impact\n\nThis impacts Fiber v3 prereleases through stable release version 3.0.0.\n\nSuccessful exploitation requires the server to be using the static middleware on Windows, as this is the only OS where backslashes are treated as directory separators by the file system.\n\nExploitation allows directory traversal on the host server. An attacker can read arbitrary files within the scope of the application server context. Depending on permissions and deployment conditions, attackers may access sensitive files outside the web root, such as configuration files, source code, or system files. Leaking application secrets often leads to further compromise.\n\n### Patches\n\nThis has been [patched](https://github.com/gofiber/fiber/pull/4064) in Fiber v3 version 3.0.1.  Users are strongly encouraged to update to the latest available release.",
  "id": "GHSA-m3c2-496v-cw3v",
  "modified": "2026-02-24T20:51:01Z",
  "published": "2026-02-24T20:51:01Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/gofiber/fiber/security/advisories/GHSA-m3c2-496v-cw3v"
    },
    {
      "type": "WEB",
      "url": "https://github.com/gofiber/fiber/pull/4064"
    },
    {
      "type": "WEB",
      "url": "https://github.com/gofiber/fiber/commit/59133702301c2ab7b776dd123b474cbd995f2c86"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/gofiber/fiber"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Fiber has an Arbitrary File Read in Static Middleware on Windows"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…