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

default cookies to httpOnly #1449

Closed
plentz opened this issue Jun 1, 2011 · 11 comments
Closed

default cookies to httpOnly #1449

plentz opened this issue Jun 1, 2011 · 11 comments

Comments

@plentz
Copy link
Contributor

plentz commented Jun 1, 2011

For security reasons(session hijacking, for example), I think that it could be a good idea to default cookies to httpOnly: https://www.owasp.org/index.php/HttpOnly

(any reason for not doing that - apart of being 'kind of' backwards incompatible?)

related:
https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/response.rb#L136
https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/cookies.rb#L220
rack/rack#184

@sikachu
Copy link
Member

sikachu commented Jun 1, 2011

Let's hear feedback from @josh? As long as this cookie would work on both http and https, I'm fine.

@plentz
Copy link
Contributor Author

plentz commented Jun 1, 2011

the main point is that setting cookies to httponly, they can't be read by javascript (so we have a better protection against session hijacking).

HttpOnly is a an option which specifies that the cookie (session identifiers included) should not be accessed from the application DOM. In that case the attacker cannot hijack the session because document.cookie will not return anything useful.

btw, I said that it is 'kind of' backwards incompatible because the only thing I can image that could break is if someone is reading cookies with javascript intentionally in his app.

@josevalim
Copy link
Contributor

The session is already httponly. So is there a strong reason to set all cookies httponly?

@plentz
Copy link
Contributor Author

plentz commented Jun 8, 2011

I think that the question should be "why not?".

@josh
Copy link
Contributor

josh commented Jun 8, 2011

Backwards incompat.

@josh josh closed this as completed Jun 8, 2011
@stouset
Copy link
Contributor

stouset commented Jan 3, 2013

Now that Rails 4 is on the horizon, and backwards incompatibilities can be expected, is this something that should be reconsidered?

@steveklabnik
Copy link
Member

Rails 4 is a backwards-compatible (as much as possible) release, and feature requests don't belong on the issues tracker anyway.

@joevandyk
Copy link
Contributor

Seems like there should be a way to tell Rails to make all cookies httponly by default, right? Instead of having to remember to set the httponly flag each time you save a cookie.

@robin850
Copy link
Member

@joevandyk : Please talk about feature requests on the mailing list. It looks like there is still a topic about your proposal ; unfortunately, it hasn't been commented yet.

@chancancode
Copy link
Member

Maybe we can get @xuchu to think about this one for his gsoc project

@xuchu
Copy link

xuchu commented Apr 23, 2014

@chancancode I can work on it when building the expiring signed cookie jar.

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

No branches or pull requests

10 participants