Skip to content

Conversation

renovate-sh-app[bot]
Copy link
Contributor

@renovate-sh-app renovate-sh-app bot commented Aug 6, 2025

This PR contains the following updates:

Package Change Age Confidence
github.com/go-chi/chi/v5 v5.1.0 -> v5.2.2 age confidence

GitHub Vulnerability Alerts

GHSA-vrw8-fxc6-2r93

Summary

The RedirectSlashes function in middleware/strip.go is vulnerable to host header injection which leads to open redirect.

Details

The RedirectSlashes method uses the Host header to construct the redirectURL at this line https://github.com/go-chi/chi/blob/v5.2.1/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

curl -L -H "Host: example.com" http://localhost:8080/test/

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
... snipped ...

Without the host header, the response is returned from the test server

curl -L http://localhost:8080/test/

404 page not found

Impact

An open redirect vulnerability allows attackers to trick users into visiting malicious sites. This can lead to phishing attacks, credential theft, and malware distribution, as users trust the application’s domain while being redirected to harmful sites.

Potential mitigation

It seems that the purpose of the RedirectSlashes function is to redirect within the same application. In that case r.RequestURI can be used instead of r.Host by default. If there is a use case to redirect to a different host, a flag can be added to use the Host header instead. As this flag will be controlled by the developer they will make the decision of allowing redirects to arbitrary hosts based on their judgement.


Host Header Injection which Leads to Open Redirect in RedirectSlashes in github.com/go-chi/chi

GHSA-vrw8-fxc6-2r93 / GO-2025-3770

More information

Details

Host Header Injection which Leads to Open Redirect in RedirectSlashes in github.com/go-chi/chi

Severity

Unknown

References

This data is provided by OSV and the Go Vulnerability Database (CC-BY 4.0).


chi Allows Host Header Injection which Leads to Open Redirect in RedirectSlashes

GHSA-vrw8-fxc6-2r93 / GO-2025-3770

More information

Details

Summary

The RedirectSlashes function in middleware/strip.go is vulnerable to host header injection which leads to open redirect.

Details

The RedirectSlashes method uses the Host header to construct the redirectURL at this line https://github.com/go-chi/chi/blob/v5.2.1/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

curl -L -H "Host: example.com" http://localhost:8080/test/

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
... snipped ...

Without the host header, the response is returned from the test server

curl -L http://localhost:8080/test/

404 page not found
Impact

An open redirect vulnerability allows attackers to trick users into visiting malicious sites. This can lead to phishing attacks, credential theft, and malware distribution, as users trust the application’s domain while being redirected to harmful sites.

Potential mitigation

It seems that the purpose of the RedirectSlashes function is to redirect within the same application. In that case r.RequestURI can be used instead of r.Host by default. If there is a use case to redirect to a different host, a flag can be added to use the Host header instead. As this flag will be controlled by the developer they will make the decision of allowing redirects to arbitrary hosts based on their judgement.

Severity

  • CVSS Score: 5.1 / 10 (Medium)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

References

This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).


Release Notes

go-chi/chi (github.com/go-chi/chi/v5)

v5.2.2

Compare Source

What's Changed

Security fix

  • Fixes GHSA-vrw8-fxc6-2r93 - "Host Header Injection Leads to Open Redirect in RedirectSlashes" commit
    • a lower-severity Open Redirect that can't be exploited in browser or email client, as it requires manipulation of a Host header
    • reported by Anuraag Baishya, @​anuraagbaishya. Thank you!

New Contributors

Full Changelog: go-chi/chi@v5.2.1...v5.2.2

v5.2.1

Compare Source

⚠️ Chi supports Go 1.20+

Starting this release, we will now support the four most recent major versions of Go. See https://github.com/go-chi/chi/issues/963 for related discussion.

What's Changed

Full Changelog: go-chi/chi@v5.2.0...v5.2.1

v5.2.0

Compare Source

What's Changed

New Contributors

Full Changelog: go-chi/chi@v5.1.0...v5.2.0


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Renovate Bot.

@renovate-sh-app renovate-sh-app bot requested a review from a team as a code owner August 6, 2025 08:24
@renovate-sh-app renovate-sh-app bot enabled auto-merge (squash) August 6, 2025 08:24
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch 2 times, most recently from 892c885 to a773250 Compare August 13, 2025 15:51
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch 3 times, most recently from b8e18c9 to 49fec8e Compare August 25, 2025 12:08
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch from 49fec8e to 0fe80b8 Compare September 3, 2025 18:09
@renovate-sh-app renovate-sh-app bot changed the title fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] - autoclosed Sep 4, 2025
@renovate-sh-app renovate-sh-app bot closed this Sep 4, 2025
auto-merge was automatically disabled September 4, 2025 06:10

Pull request was closed

@renovate-sh-app renovate-sh-app bot deleted the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch September 4, 2025 06:10
@renovate-sh-app renovate-sh-app bot changed the title fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] - autoclosed fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] Sep 4, 2025
@renovate-sh-app renovate-sh-app bot reopened this Sep 4, 2025
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch from 9b35337 to 0fe80b8 Compare September 4, 2025 09:09
@renovate-sh-app renovate-sh-app bot enabled auto-merge (squash) September 4, 2025 09:22
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch from 0fe80b8 to efee20c Compare September 4, 2025 18:07
@renovate-sh-app renovate-sh-app bot changed the title fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] - autoclosed Sep 5, 2025
@renovate-sh-app renovate-sh-app bot closed this Sep 5, 2025
auto-merge was automatically disabled September 5, 2025 09:08

Pull request was closed

@renovate-sh-app renovate-sh-app bot changed the title fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] - autoclosed fix(deps): update module github.com/go-chi/chi/v5 to v5.2.2 [security] Sep 5, 2025
@renovate-sh-app renovate-sh-app bot reopened this Sep 5, 2025
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch from 5892ee0 to efee20c Compare September 5, 2025 12:11
| datasource | package                  | from   | to     |
| ---------- | ------------------------ | ------ | ------ |
| go         | github.com/go-chi/chi/v5 | v5.1.0 | v5.2.2 |


Signed-off-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
@renovate-sh-app renovate-sh-app bot force-pushed the renovate/go-github.202132.xyz-go-chi-chi-v5-vulnerability branch from efee20c to 4e48848 Compare September 5, 2025 12:28
@renovate-sh-app renovate-sh-app bot enabled auto-merge (squash) September 5, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants