Nezha: OAuth2 redirect_uri Host header injection regression when dashboard_host is emptyGHSA-rf68-8gjr-36q7
Fix: nezhahq/nezha@38824dbGHSA-rf68-8gjr-36q7 is a Open Redirect vulnerability in github.com/nezhahq/nezha. No vendor fix is recorded yet; mitigation options are listed below.
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for GHSA-rf68-8gjr-36q7.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
Real-World Exposure
github.com/nezhahq/nezhaReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Go packages — download data is not available via public APIs for these ecosystems.
Description
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:
GET /api/v1/oauth2/github?type=1 HTTP/1.1
Host: evil.attacker.test
X-Forwarded-Proto: https
The generated OAuth2 authorization URL contains:
redirect_uri=https%3A%2F%2Fevil.attacker.test%2Fapi%2Fv1%2Foauth2%2Fcallback
A minimal route-level unit test demonstrating the issue is:
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:
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:
- Use
DashboardHostwhen it is set. - Otherwise fall back to
InstallHostif it is set, preserving the v2.2.0 invariant for existing deployments. - 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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐹Go | github.com/nezhahq/nezha | all versions | No fix |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for github.com/nezhahq/nezha, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Remediation status
No patched version of github.com/nezhahq/nezha has shipped for GHSA-rf68-8gjr-36q7 yet. Where your build allows, override or pin the dependency away from the vulnerable range, and apply any maintainer-recommended mitigation.
Mitigate without a patch
Stop reflecting attacker-controlled destinations: resolve every redirect target against an allowlist of paths or hosts you own, prefer a server-side key over a full URL in the request, and reject absolute URLs entirely where the flow only ever needs a relative one.
Frequently Asked Questions
Is GHSA-rf68-8gjr-36q7 in your dependencies?
Find it across Go, including transitive dependencies.