Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing csrf protection on kitspace_auth endpoints #21

Open
kasbah opened this issue Feb 6, 2022 · 2 comments
Open

Missing csrf protection on kitspace_auth endpoints #21

kasbah opened this issue Feb 6, 2022 · 2 comments

Comments

@kasbah
Copy link
Member

kasbah commented Feb 6, 2022

It doesn't seem to be implemented. These endpoints should also be setting a new csrf token, one that only works for the newly logged in user, in their responses (and the frontend should replace the csrf it uses from then on).

@AbdulrhmnGhanem
Copy link
Member

It doesn't seem to be implemented.

I think it's enabled by default for all POST endpoints

if !options.SignOutRequired && !options.DisableCSRF && ctx.Req.Method == "POST" {
Validate(ctx, ctx.csrf)
if ctx.Written() {
return
}
}

and disabled for specific routes by using ignSignInAndCsrf

ignSignInAndCsrf := context.Toggle(&context.ToggleOptions{DisableCSRF: true})

gitea/routers/web/web.go

Lines 346 to 351 in 7e9ecfe

m.Group("/login/oauth", func() {
m.Get("/authorize", bindIgnErr(forms.AuthorizationForm{}), auth.AuthorizeOAuth)
m.Post("/grant", bindIgnErr(forms.GrantApplicationForm{}), auth.GrantApplicationOAuth)
// TODO manage redirection
m.Post("/authorize", bindIgnErr(forms.AuthorizationForm{}), auth.AuthorizeOAuth)
}, ignSignInAndCsrf, reqSignIn)

@AbdulrhmnGhanem
Copy link
Member

Also, a new CSRF is set after a successful login

logged out logged in
image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants