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

Set session cookie as HttpOnly by default to protect against cookie theft #37

Open
villekuosmanen opened this issue Sep 2, 2021 · 1 comment

Comments

@villekuosmanen
Copy link

I noticed that the session cookies written in the SetCookie headers are not set by default. If this field is not set, the end users of this library are vulnerable to cookie theft by potential XSS attacks. OWASP recommends HttpOnly to be set for session cookies, which is why in my opinion it would be good practice to set the cookie by default in the library code.

Of course, you can set the flag manually by calling session.Options.HttpOnly = true before session.Save(r, w), but I doubt most users remember or understand that the field should be set by them (I only discovered this after doing some digging).

If you think this sounds like something the library should do, I don't mind sending out a PR for it, should be a one-line fix.

PS: Thanks for all the work you've done on the library :)

@antonlindstrom
Copy link
Owner

Hey! Thank you so much for taking the time to look at this and so sorry for the incredibly late reply.

As long as this doesn't break anything for existing users I am happy to take any PR to fix it.

Again, thank you so much!

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