GHSA-44xr-mrhh-qm78: CSRF

Published Oct 15, 2026
·
Updated

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):

go 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?clientid=%s&responsetype=code&redirecturi=%s&state=%s&scope=read", endpoint, clientId, encodedRedirectUri, state), }) }

api/user/casdoor.go:24-90 (CasdoorCallback):

go 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 oidcstate cookie, and validates it on the callback. Casdoor has no such check.

Proof of Concept

1. Attacker initiates a Casdoor authorisation flow on their own browser, obtaining an authorisation code for their Casdoor account. 2. Attacker hosts a page that auto-submits the captured code to the victim's nginx-ui:

html <html><body><form action="https://victim.example/api/casdoorcallback" method="POST" enctype="text/plain" id="x"> <input name='{"code":"<attackercode>","state":"<App>","junk":"' value='"}'> </form> <script>document.getElementById('x').submit()</script> </body></html>

3. Server exchanges the attacker's code, looks up the username from claims.Name in the local user table, and mints a JWT for that row. The callback also sets the nginxuisecuresession cookie via middleware.EnsureSecureSessionCookie(c) (casdoor.go:84) — meaning the victim is now silently authenticated as the attacker. 4. 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:

diff + 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("casdoorstate", state, 600, "/", "", + cSettings.ServerSettings.EnableHTTPS, true) ... }

func CasdoorCallback(c gin.Context) { + expected, err := c.Cookie("casdoorstate") + 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.

Affected Software

1 affected component
go/Nginx-UI<1.9.10-0.20260703131214-23d1934099b0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Configuration

    Disable Casdoor SSO until the login-CSRF vulnerability is patched.

    nginx-ui Casdoor SSO Casdoor SSO = disabled
  2. Compensating control

    Implement OAuth state validation in the Casdoor flow by generating a cryptographically random state, storing it in a casdoor_state cookie with SameSite=Lax, and comparing the callback state to the stored value using a constant-time comparison; reject callbacks with a missing or invalid state.

  3. Compensating control

    Use the correctly implemented OIDC integration as a substitute for the vulnerable Casdoor SSO integration.

Event History

Oct 15, 2026
Advisory Published
via GitHub·08:12 PM
Data Sourced
via GitHub·08:12 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed?

Deployments using the Casdoor SSO login flow are exposed. The affected flow generates the OAuth state value from the configured Casdoor application value, which is identical across users and login attempts.

2

What does an attacker need to do to exploit this?

An attacker must cause a victim to interact with a crafted OAuth callback or login flow in the victim's browser. No prior privileges are required, but victim interaction is required.

3

What is the practical impact of a successful attack?

The victim's browser can be logged in as the attacker's account rather than the victim's intended account. Actions the victim subsequently performs may therefore occur in the attacker's session.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203