GHSA-rf68-8gjr-36q7: Nezha OAuth2 Redirect_uri Host Header Injection Vulnerability

LOW
CWE-601
Published
Advisory Summary

GHSA-rf68-8gjr-36q7 is a LOW oauth2 redirect_uri host header injection vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Nezha libraries in the Go ecosystem. The issue involves oauth2 redirect_uri host header injection regression when dashboard_host is empty. Remediation is available in the latest vendor maintenance releases.

GHSA-rf68-8gjr-36q7 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-rf68-8gjr-36q7
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Nezha
Package Ecosystem Go
Published Date
Last Updated

How to Fix GHSA-rf68-8gjr-36q7

To remediate this vulnerability, upgrade all affected Nezha 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/nezhahq/nezha fixed: Latest secure release
Upgrade github.com/nezhahq/nezha to Latest secure release
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/nezhahq/nezha

How to Check if You Are Affected

To determine whether your application is affected by GHSA-rf68-8gjr-36q7, inspect your project dependencies for Nezha:

inspect dependencies for github.com/nezhahq/nezha

Analyze the terminal output to locate any version of Nezha in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), 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-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Nezha, 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 Nezha v2.2.3 regresses the GHSA-9rc6-8cjv-rcvx host header injection fix for deployments where the new `dashboard_host` setting is empty. In that configuration, `/api/v1/oauth2/{provider}` again reflects the request `Host` header into the OAuth2 `redirect_uri` sent to the identity provider, even if `install_host` is configured. ## Impact An attacker who can get a victim to start OAuth2 login through a request that reaches Nezha with a forged `Host` header can make Nezha send an attacker-controlled callback URL as the OAuth2 `redirect_uri`. If the configured OAuth2 provider accepts that redirect URI, the victim's authorization code is sent to the attacker origin. The attacker can then complete the OAuth2 binding or login flow described in GHSA-9rc6. This is configuration-dependent, but it affects a realistic upgrade/default state because `dashboard_host` is a new optional field. The original v2.2.0 fix fell back to `install_host`; current v2.2.3 only falls back when `dashboard_host` is non-empty. ## Reproduction On current v2.2.3 / master commit `3d74cd9431a48fa89c6489689eac82a872799ea0`, configure OAuth2 and set an existing dashboard host only through `install_host`, leaving `dashboard_host` empty. Then send the OAuth2 redirect request with a forged Host header: ```http GET /api/v1/oauth2/github?type=1 HTTP/1.1 Host: evil.attacker.test X-Forwarded-Proto: https ``` The generated OAuth2 authorization URL contains: ```text redirect_uri=https%3A%2F%2Fevil.attacker.test%2Fapi%2Fv1%2Foauth2%2Fcallback ``` A minimal route-level unit test demonstrating the issue is: ```go func TestOAuth2Redirect_RegressionWhenDashboardHostEmptyReflectsForgedHost(t *testing.T) { defer setupOAuth2Test(t)() singleton.Conf.InstallHost = "legit-dashboard.example.com" singleton.Conf.DashboardHost = "" singleton.Conf.Oauth2["github"] = &model.Oauth2Config{ ClientID: "client-id", ClientSecret: "client-secret", Endpoint: model.Oauth2Endpoint{AuthURL: "https://idp.example.test/authorize", TokenURL: "https://idp.example.test/token"}, Scopes: []string{"openid"}, } c, _ := newOAuth2Ctx(t) c.Params = gin.Params{{Key: "provider", Value: "github"}} c.Request.Host = "evil.attacker.test" c.Request.URL.RawQuery = "type=1" c.Request.Header.Set("X-Forwarded-Proto", "https") resp, err := oauth2redirect(c) require.NoError(t, err) parsed, err := url.Parse(resp.Redirect) require.NoError(t, err) require.Equal(t, "https://evil.attacker.test/api/v1/oauth2/callback", parsed.Query().Get("redirect_uri")) } ``` The corresponding control with `DashboardHost = "panel.example.com"` pins the same forged request to `https://panel.example.com/api/v1/oauth2/callback`, so the issue is specifically the empty `dashboard_host` fallback. ## Root cause Current `cmd/dashboard/controller/oauth2.go` chooses the request Host unless `DashboardHost` is non-empty: ```go host := c.Request.Host if !singleton.IsReservedDashboardHost(host) && singleton.Conf != nil && singleton.Conf.DashboardHost != "" { host = singleton.Conf.DashboardHost } return scheme + host + "/api/v1/oauth2/callback" ``` The v2.2.0 fix used `InstallHost` as the fallback for untrusted request hosts. After `DashboardHost` was introduced, empty `dashboard_host` now disables host pinning and reintroduces the original Host header injection behavior for those deployments. ## Remediation Build the OAuth2 callback URL from a deterministic configured origin. For example: 1. Use `DashboardHost` when it is set. 2. Otherwise fall back to `InstallHost` if it is set, preserving the v2.2.0 invariant for existing deployments. 3. If neither value is set, reject OAuth2 redirect initiation with a configuration error instead of reflecting request Host. Please also add a regression test that `InstallHost` plus empty `DashboardHost` does not reflect a forged Host into `redirect_uri`.

GHSA-rf68-8gjr-36q7 Affected Nezha Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
github.com/nezhahq/nezha
Go
2.2.3
All 1 versions
2.2.3
None specified

References

Frequently Asked Questions

What is GHSA-rf68-8gjr-36q7?
GHSA-rf68-8gjr-36q7 is a security vulnerability in Nezha involving OAuth2 redirect_uri Host header injection regression when dashboard_host is empty under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Nezha versions are affected?
Affected versions include releases prior to current release patches across affected packages: github.com/nezhahq/nezha.
What version fixes GHSA-rf68-8gjr-36q7?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/nezhahq/nezha affected?
Yes, github.com/nezhahq/nezha is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with GHSA-rf68-8gjr-36q7?
GHSA-rf68-8gjr-36q7 is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check Go dependencies for GHSA-rf68-8gjr-36q7?
Run the dependency tree command: 'inspect dependencies for github.com/nezhahq/nezha'. 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-rf68-8gjr-36q7",
  "modified" : "2026-09-15T19:50:08Z",
  "published" : "2026-09-15T19:50:08Z",
  "aliases" : [ ],
  "summary" : "Nezha: OAuth2 redirect_uri Host header injection regression when dashboard_host is empty",
  "details" : "## Summary\n\nNezha v2.2.3 regresses the GHSA-9rc6-8cjv-rcvx host header injection fix for deployments where the new `dashboard_host` setting is empty. In that configuration, `/api/v1/oauth2/{provider}` again reflects the request `Host` header into the OAuth2 `redirect_uri` sent to the identity provider, even if `install_host` is configured.\n\n## Impact\n\nAn attacker who can get a victim to start OAuth2 login through a request that reaches Nezha with a forged `Host` header can make Nezha send an attacker-controlled callback URL as the OAuth2 `redirect_uri`. If the configured OAuth2 provider accepts that redirect URI, the victim's authorization code is sent to the attacker origin. The attacker can then complete the OAuth2 binding or login flow described in GHSA-9rc6.\n\nThis is configuration-dependent, but it affects a realistic upgrade/default state because `dashboard_host` is a new optional field. The original v2.2.0 fix fell back to `install_host`; current v2.2.3 only falls back when `dashboard_host` is non-empty.\n\n## Reproduction\n\nOn current v2.2.3 / master commit `3d74cd9431a48fa89c6489689eac82a872799ea0`, configure OAuth2 and set an existing dashboard host only through `install_host`, leaving `dashboard_host` empty. Then send the OAuth2 redirect request with a forged Host header:\n\n```http\nGET /api/v1/oauth2/github?type=1 HTTP/1.1\nHost: evil.attacker.test\nX-Forwarded-Proto: https\n```\n\nThe generated OAuth2 authorization URL contains:\n\n```text\nredirect_uri=https%3A%2F%2Fevil.attacker.test%2Fapi%2Fv1%2Foauth2%2Fcallback\n```\n\nA minimal route-level unit test demonstrating the issue is:\n\n```go\nfunc TestOAuth2Redirect_RegressionWhenDashboardHostEmptyReflectsForgedHost(t *testing.T) {\n    defer setupOAuth2Test(t)()\n    singleton.Conf.InstallHost = \"legit-dashboard.example.com\"\n    singleton.Conf.DashboardHost = \"\"\n    singleton.Conf.Oauth2[\"github\"] = &model.Oauth2Config{\n        ClientID: \"client-id\",\n        ClientSecret: \"client-secret\",\n        Endpoint: model.Oauth2Endpoint{AuthURL: \"https://idp.example.test/authorize\", TokenURL: \"https://idp.example.test/token\"},\n        Scopes: []string{\"openid\"},\n    }\n\n    c, _ := newOAuth2Ctx(t)\n    c.Params = gin.Params{{Key: \"provider\", Value: \"github\"}}\n    c.Request.Host = \"evil.attacker.test\"\n    c.Request.URL.RawQuery = \"type=1\"\n    c.Request.Header.Set(\"X-Forwarded-Proto\", \"https\")\n\n    resp, err := oauth2redirect(c)\n    require.NoError(t, err)\n\n    parsed, err := url.Parse(resp.Redirect)\n    require.NoError(t, err)\n    require.Equal(t, \"https://evil.attacker.test/api/v1/oauth2/callback\", parsed.Query().Get(\"redirect_uri\"))\n}\n```\n\nThe corresponding control with `DashboardHost = \"panel.example.com\"` pins the same forged request to `https://panel.example.com/api/v1/oauth2/callback`, so the issue is specifically the empty `dashboard_host` fallback.\n\n## Root cause\n\nCurrent `cmd/dashboard/controller/oauth2.go` chooses the request Host unless `DashboardHost` is non-empty:\n\n```go\nhost := c.Request.Host\nif !singleton.IsReservedDashboardHost(host) && singleton.Conf != nil && singleton.Conf.DashboardHost != \"\" {\n    host = singleton.Conf.DashboardHost\n}\nreturn scheme + host + \"/api/v1/oauth2/callback\"\n```\n\nThe v2.2.0 fix used `InstallHost` as the fallback for untrusted request hosts. After `DashboardHost` was introduced, empty `dashboard_host` now disables host pinning and reintroduces the original Host header injection behavior for those deployments.\n\n## Remediation\n\nBuild the OAuth2 callback URL from a deterministic configured origin. For example:\n\n1. Use `DashboardHost` when it is set.\n2. Otherwise fall back to `InstallHost` if it is set, preserving the v2.2.0 invariant for existing deployments.\n3. If neither value is set, reject OAuth2 redirect initiation with a configuration error instead of reflecting request Host.\n\nPlease also add a regression test that `InstallHost` plus empty `DashboardHost` does not reflect a forged Host into `redirect_uri`.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/nezhahq/nezha"
    },
    "versions" : [ "2.2.3" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nezhahq/nezha/security/advisories/GHSA-rf68-8gjr-36q7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nezhahq/nezha/commit/38824dbc11a63964c5b9296ae4c68e62b34fa04b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nezhahq/nezha"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-601" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-15T19:50:08Z",
    "nvd_published_at" : null
  }
}