CVE-2026-84312: Nginx UI: Casdoor SSO callback uses a constant `state` parameter (login CSRF)
Summary In the Casdoor SSO flow, the OAuth state parameter is hard-coded to settings.CasdoorSettings.Application — a value identical for every user and every login. The callback handler accepts whatever state the client sends without comparing it to anything stored in the user agent, enabling a login-CSRF: an attacker can force the victim's browser to authenticate as the attacker.
Published Oct 15, 2026 · Updated Oct 28, 2026
Affected packages
github.com/0xJacky/Nginx-UI
- Ecosystem
- Go
- Affected
- < 1.9.10-0.20260703131214-23d1934099b0
- Fixed in
- 1.9.10-0.20260703131214-23d1934099b0
- Check
go list -m github.com/0xJacky/Nginx-UI
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
In the Casdoor SSO flow, the OAuth state parameter is hard-coded to settings.CasdoorSettings.Application — a value identical for every user and every login. The callback handler accepts whatever state the client sends without comparing it to anything stored in the user agent, enabling a login-CSRF: an attacker can force the victim's browser to authenticate as the *attacker*.
Details
api/user/casdoor.go:92-117 (GetCasdoorUri):
func GetCasdoorUri(c *gin.Context) {
clientId := settings.CasdoorSettings.ClientId
redirectUri := settings.CasdoorSettings.RedirectUri
state := settings.CasdoorSettings.Application // ← constant
...
c.JSON(http.StatusOK, gin.H{
"uri": fmt.Sprintf(
"%s/login/oauth/authorize?client_id=%s&response_type=code&redirect_uri=%s&state=%s&scope=read",
endpoint, clientId, encodedRedirectUri, state),
})
}api/user/casdoor.go:24-90 (CasdoorCallback):
type CasdoorLoginUser struct {
Code string `json:"code" binding:"required,max=255"`
State string `json:"state" binding:"required,max=255"`
}
func CasdoorCallback(c *gin.Context) {
var loginUser CasdoorLoginUser
if !cosy.BindAndValid(c, &loginUser) { return }
...
// state is NEVER compared to a per-session value
token, err := casdoorsdk.GetOAuthToken(loginUser.Code, loginUser.State)
...
u, err := user.GetUser(claims.Name) // username from Casdoor's JWT
...
userToken, err := user.GenerateJWT(u) // JWT minted for whatever user came back
}Compare with the OIDC implementation in api/user/oidc.go:35-48, which generates a random state, stores it in an oidc_state cookie, and validates it on the callback. Casdoor has no such check.
Proof of Concept
- Attacker initiates a Casdoor authorisation flow on their own browser, obtaining an authorisation
codefor *their* Casdoor account. - Attacker hosts a page that auto-submits the captured
codeto the victim's nginx-ui:
<html><body><form action="https://victim.example/api/casdoor_callback" method="POST"
enctype="text/plain" id="x">
<input name='{"code":"<attacker_code>","state":"<App>","junk":"' value='"}'>
</form>
<script>document.getElementById('x').submit()</script>
</body></html>- Server exchanges the attacker's
code, looks up the username fromclaims.Namein the local user table, and mints a JWT for *that* row. The callback also sets the_nginx_ui_secure_sessioncookie viamiddleware.EnsureSecureSessionCookie(c)(casdoor.go:84) — meaning the victim is now silently authenticated as the attacker. - Victim, believing they are using their own account, configures sites / TLS keys; the attacker reads them.
Impact
Login CSRF — the victim is forced to authenticate as the attacker, leading to data exfiltration of anything the victim subsequently uploads or configures. Particularly dangerous when nginx-ui is used by an organisation where Casdoor maps internal identities — the attacker can attribute their changes to the victim.
Patches
Mirror the OIDC implementation:
+ import (
+ "crypto/rand"
+ "crypto/subtle"
+ "encoding/hex"
+ ...
+ )
func GetCasdoorUri(c *gin.Context) {
...
- state := settings.CasdoorSettings.Application
+ b := make([]byte, 16)
+ if _, err := rand.Read(b); err != nil {
+ cosy.ErrHandler(c, err); return
+ }
+ state := hex.EncodeToString(b)
+ c.SetSameSite(http.SameSiteLaxMode)
+ c.SetCookie("casdoor_state", state, 600, "/", "",
+ cSettings.ServerSettings.EnableHTTPS, true)
...
}
func CasdoorCallback(c *gin.Context) {
+ expected, err := c.Cookie("casdoor_state")
+ if err != nil {
+ c.AbortWithStatusJSON(http.StatusBadRequest,
+ gin.H{"message":"missing state cookie"}); return
+ }
var loginUser CasdoorLoginUser
if !cosy.BindAndValid(c, &loginUser) { return }
+ if subtle.ConstantTimeCompare([]byte(expected), []byte(loginUser.State)) != 1 {
+ c.AbortWithStatusJSON(http.StatusBadRequest,
+ gin.H{"message":"invalid state"}); return
+ }
...
}Workarounds
Disable Casdoor SSO until patched. The OIDC integration in api/user/oidc.go is correctly implemented and can be used as a substitute.
References
- `api/user/casdoor.go:92-117`
- `api/user/casdoor.go:24-90`
- `api/user/oidc.go:35-48` (correct implementation for comparison)
Credits
Vishal Shukla (@shukla304) and Sechub.dev AI Agent.
Credited to therawdev, nonkronk, cyberxyz-security.
References
- https://github.com/0xJacky/nginx-ui/security/advisories/GHSA-44xr-mrhh-qm78
- https://nvd.nist.gov/vuln/detail/CVE-2026-84312
- https://github.com/0xJacky/nginx-ui/commit/23d1934099b05b2a01589b48129dc3d3159d91c2
- https://github.com/0xJacky/nginx-ui/releases/tag/v2.4.1
- https://github.com/advisories/GHSA-44xr-mrhh-qm78
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-84313
Nginx UI: TOTP / passkey enrolment requires no re-authentication, enabling persistent account takeover
high8.8Oct 15, 2026CVE-2026-84314
Nginx UI: Account Takeover via Missing `RequireSecureSession` on User Management Endpoint
high8.7Oct 15, 2026CVE-2026-84315
Nginx UI OTP secure-session step-up is missing on sensitive mutation routes
high8.3Oct 15, 2026CVE-2026-84316
Nginx UI: nginx config directive denylist (ValidateConfigFile) is bypassable via same-line ";" separation → authenticated directive injection (RCE on the official image)
high8.8Oct 15, 2026CVE-2026-84317
Nginx UI: MCP nginx_config_add skips config directive validation → authenticated nginx directive injection (RCE on the official image)
high8.8Oct 15, 2026CVE-2026-84318
Nginx UI: MCP `nginx_config_add` Bypasses Directive Validation — Authenticated RCE
high8.8Oct 15, 2026
