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

Cookie token should be marked as "secure" when created in an https connection #14606

Open
1 task
temtemy opened this issue Sep 22, 2024 · 1 comment
Open
1 task
Labels
⚠️bug? This might be a bug

Comments

@temtemy
Copy link

temtemy commented Sep 22, 2024

💡 Summary

Currently the cookie being generated in /packages/frontend/src/account.ts when you sign in is not marked as secure:

document.cookie = `token=${token}; path=/; max-age=31536000`; // bull dashboardの認証とかで使う

This can result in the cookie token being sent unencrypted by the browser over http if the webmaster didn't setup HSTS.

Note that Chrome and Firefox (since version 52 for both browsers) will not set a cookie when secure is used in an http scheme, according to MDN. So make sure secure is only added as a directive when https is the scheme so as to not break Misskey instances which serve the frontend over secure hidden networks like Tor and Yggdrasil (which usually don't use https).

🥰 Expected Behavior

The cookie token should be marked as "secure" in the document.cookie. For example, Mastodon does it and my browser does note that the cookie will only be sent over HTTPS:

image

🤬 Actual Behavior

There's no secure directive in the document.cookie, and as noted by my browser it can be sent over any type of connection instead of just HTTPS:

image

📝 Steps to Reproduce

No response

💻 Frontend Environment

No response

🛰 Backend Environment (for server admin)

No response

Do you want to address this bug yourself?

  • Yes, I will patch the bug myself and send a pull request
@temtemy temtemy added the ⚠️bug? This might be a bug label Sep 22, 2024
@kakkokari-gtyih
Copy link
Contributor

Related to #14528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️bug? This might be a bug
Projects
None yet
Development

No branches or pull requests

2 participants