chi Allows Host Header Injection which Leads to Open Redirect in RedirectSlashes
### Summary The RedirectSlashes function in middleware/strip.go is vulnerable to host header injection which leads to open redirect. We consider this a **lower-severity** open redirect, as it can't be exploited from browsers or email clients (requires manipulation of a Host header). ### Details The RedirectSlashes method uses the Host header to construct the redirectURL at this line https://github.com/go-chi/chi/blob/master/middleware/strip.go#L55 The Host header can be manipulated by a user to be any arbitrary host. This leads to open redirect when using the RedirectSlashes middleware ### PoC Create a simple server which uses the RedirectSlashes middleware ``` package main import ( "fmt" "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" // Import the middleware package ) func main() { // Create a new Chi router r := chi.NewRouter() // Use the built-in RedirectSlashes middleware r.Use(middleware.RedirectSlashes) // Use middleware.RedirectSlashes // Define a route handler r.Get("/", func(w http.ResponseWriter, r *http.Request) { // A simple response w.Write([]byte("Hello, World!")) }) // Start the server fmt.Println("Starting server on :8080") http.ListenAndServe(":8080", r) } ``` Run the server `go run main.go` Once the server is running, send a request that will trigger the RedirectSlashes function with an arbitrary Host header `curl -iL -H "Host: example.com" http://localhost:8080/test/` Observe that the request will be redirected to example.com ``
GHSA-vrw8-fxc6-2r93
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: osv:GHSA-vrw8-fxc6-2r93
github.com/go-chi/chi/v5
Source reference: /affected/0/package/name
- Affected versions
- Not stated in this record
- Fixed versions
- 5.2.2
Source reference:
/affected/0/ranges - Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"ranges": [
{
"type": "SEMVER",
"events": [
{
"introduced": "0"
},
{
"fixed": "5.2.2"
}
]
}
],
"package": {
"name": "github.com/go-chi/chi/v5",
"purl": "pkg:golang/github.com/go-chi/chi/v5",
"ecosystem": "Go"
},
"database_specific": {
"source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/06/GHSA-vrw8-fxc6-2r93/GHSA-vrw8-fxc6-2r93.json",
"last_known_affected_version_range": "<= 5.2.1"
}
}
]- Related CVEs
- CVE-2025-71405
Source reference:
/aliases
Publisher severity
medium
Source reference: /severity/0/score
- Event
- #72768 · Revision 1
- Added to Heist Feed
- Publisher date