GHSA-MQQF-5WVP-8FH8

Vulnerability from github – Published: 2026-01-14 21:18 – Updated: 2026-01-14 21:18
VLAI?
Summary
chi has an open redirect vulnerability in the RedirectSlashes middleware
Details

Summary

The RedirectSlashes function in middleware/strip.go does not perform correct input validation and can lead to an open redirect vulnerability.

Details

The RedirectSlashes function performs a Trim to all forward slash (/) characters, while prepending a single one at the begining of the path (Line 52).

However, it does not trim backslashes (\).

File: middleware/strip.go
41: func RedirectSlashes(next http.Handler) http.Handler {
...
51:             // Trim all leading and trailing slashes (e.g., "//evil.com", "/some/path//")
52:             path = "/" + strings.Trim(path, "/")
...
62: }

Also, from version 5.2.2 onwards the RedirectSlashes function does not take into consideration the Host Header in the redirect response returned. This was done in order to combat another [vulnerability](https://github.com/go-chi/chi/security/advisories/GHSA-vrw8-fxc6-2r93).

The above make it possible for a response in the following form:

HTTP/1.1 301 Moved Permanently
Location: /\evil.com

The /\evil.com will be transformed by most browsers (Chrome, Firefox, etc. not Safari) into //evil.com which is a protocol relative URL and will result in a redirect to evil.com, essentially making it an open redirect vulnerability.

PoC

A minimal working example can be seen below.

package main

import (
    "fmt"
    "net/http"

    "github.com/go-chi/chi/v5"
    "github.com/go-chi/chi/v5/middleware"
)



func main() {
    r := chi.NewRouter()

    r.Use(middleware.RedirectSlashes)

    r.Get("/*", func(w http.ResponseWriter, r *http.Request) {
        w.WriteHeader(http.StatusOK)
    })

    fmt.Println("Server starting on port 8081...")
    if err := http.ListenAndServe(":8081", r); err != nil {
        fmt.Printf("Error starting server: %v\n", err)
    }
}

And when we request the path /\evil.com (needs a second backslash or URL encoding in the terminal), the HTTP Redirect Location is just /\evil.com without any domain/Host information.

$ curl -I  localhost:8081/\\evil.com/
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: /\evil.com
$ curl -I  localhost:8081/%5Cevil.com/
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: /\evil.com

This opened in a browser (Chrome, Firefox) will result in a transformation to //evil.com which in turn will result in a redirect to evil.com. image-20250829115619807

image-20250829115632067

Impact

This essentially consists of an open redirect vulnerability, provided that victim users use the most popular browsers (Chrome, Firefox, etc. It does not work in e.g. Safari).

The attacker can construct a malicious URL on a domain of a legitimate website and send it to the victim user. The victim users thinking that they will click on a legitimate website's URL, they will unknowingly be reidrected to an attacker controlled website.

This can lead to credential theft if the victim gets redirected to a phishing website, to malware that is hosted on the attacker controlled website etc. Also, it has a greate reputation / business impact for the affected legitimate website.

In order to exploit this vulnerability the attacker does not need to be authenticated or have ay other priviledge / knowledge regarding the affected application.

CVSS Score: 4.7 (Medium)

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/go-chi/chi"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "5.2.2"
            },
            {
              "fixed": "5.2.4"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [
      "CWE-601"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-01-14T21:18:06Z",
    "nvd_published_at": null,
    "severity": "MODERATE"
  },
  "details": "### Summary\n\nThe `RedirectSlashes` function in middleware/strip.go does not perform correct input validation and can lead to an open redirect vulnerability.\n\n### Details\n\nThe `RedirectSlashes` function performs a `Trim` to all forward slash (`/`) characters, while prepending a single one at the begining of the path (Line 52).\n\nHowever, it does not trim backslashes (`\\`).\n\n```go\nFile: middleware/strip.go\n41: func RedirectSlashes(next http.Handler) http.Handler {\n...\n51: \t\t\t// Trim all leading and trailing slashes (e.g., \"//evil.com\", \"/some/path//\")\n52: \t\t\tpath = \"/\" + strings.Trim(path, \"/\")\n...\n62: }\n```\n\nAlso, from version 5.2.2 onwards the `RedirectSlashes` function does not take into consideration the `Host` Header in the redirect response returned. This was done in order to combat another [[vulnerability](https://github.com/go-chi/chi/security/advisories/GHSA-vrw8-fxc6-2r93)](https://github.com/go-chi/chi/security/advisories/GHSA-vrw8-fxc6-2r93).\n\nThe above make it possible for a response in the following form:\n\n```\nHTTP/1.1 301 Moved Permanently\nLocation: /\\evil.com\n```\n\nThe `/\\evil.com` will be transformed by most browsers (Chrome, Firefox, etc. not Safari) into `//evil.com` which is a protocol relative URL and will result in a redirect to `evil.com`, essentially making it an open redirect vulnerability.\n\n### PoC\n\nA minimal working example can be seen below.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/go-chi/chi/v5/middleware\"\n)\n\n\n\nfunc main() {\n\tr := chi.NewRouter()\n\n\tr.Use(middleware.RedirectSlashes)\n\n\tr.Get(\"/*\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(http.StatusOK)\n\t})\n\n\tfmt.Println(\"Server starting on port 8081...\")\n\tif err := http.ListenAndServe(\":8081\", r); err != nil {\n\t\tfmt.Printf(\"Error starting server: %v\\n\", err)\n\t}\n}\n\n```\n\nAnd when we request the path `/\\evil.com` (needs a second backslash or URL encoding in the terminal), the HTTP Redirect Location is just `/\\evil.com` without any domain/Host information.\n\n```bash\n$ curl -I  localhost:8081/\\\\evil.com/\nHTTP/1.1 301 Moved Permanently\nContent-Type: text/html; charset=utf-8\nLocation: /\\evil.com\n```\n\n```bash\n$ curl -I  localhost:8081/%5Cevil.com/\nHTTP/1.1 301 Moved Permanently\nContent-Type: text/html; charset=utf-8\nLocation: /\\evil.com\n```\n\nThis opened in a browser (Chrome, Firefox) will result in a transformation to `//evil.com` which in turn will result in a redirect to `evil.com`.\n\u003cimg width=\"200\" alt=\"image-20250829115619807\" src=\"https://github.com/user-attachments/assets/44aedad1-64b6-4660-8b26-fad9b4eca036\" /\u003e\n\n\n\u003cimg width=\"200\" alt=\"image-20250829115632067\" src=\"https://github.com/user-attachments/assets/b976d47d-1975-469c-abd3-deb907a68db2\" /\u003e\n\n\n### Impact\n\nThis essentially consists of an open redirect vulnerability, provided that victim users use the most popular browsers (Chrome, Firefox, etc. It does not work in e.g. Safari).\n\nThe attacker can construct a malicious URL on a domain of a legitimate website and send it to the victim user. The victim users thinking that they will click on a legitimate website\u0027s URL, they will unknowingly be reidrected to an attacker controlled website.\n\nThis can lead to credential theft if the victim gets redirected to a phishing website, to malware that is hosted on the attacker controlled website etc. Also, it has a greate reputation / business impact for the affected legitimate website.\n\nIn order to exploit this vulnerability the attacker does not need to be authenticated or have ay other priviledge / knowledge regarding the affected application.\n\nCVSS Score: [4.7 (Medium)](https://www.first.org/cvss/calculator/3-0#CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N)",
  "id": "GHSA-mqqf-5wvp-8fh8",
  "modified": "2026-01-14T21:18:06Z",
  "published": "2026-01-14T21:18:06Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/go-chi/chi/security/advisories/GHSA-mqqf-5wvp-8fh8"
    },
    {
      "type": "WEB",
      "url": "https://github.com/go-chi/chi/issues/1037"
    },
    {
      "type": "WEB",
      "url": "https://github.com/go-chi/chi/commit/6eb35881c0e438ffb663ddbad3a61babaa5e5d8a"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/go-chi/chi"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "chi has an open redirect vulnerability in the RedirectSlashes middleware"
}


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…