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

Improve Token Security #42

Closed
type1fool opened this issue Feb 13, 2023 · 3 comments · Fixed by #50
Closed

Improve Token Security #42

type1fool opened this issue Feb 13, 2023 · 3 comments · Fixed by #50
Labels
help wanted Extra attention is needed security
Milestone

Comments

@type1fool
Copy link
Collaborator

type1fool commented Feb 13, 2023

At the Denver Elixir meetup, one of the attendees (@RGENT) raised a concern about token security (video link).

In short, the token saved in sessionStorage may be accessed by 3rd party JS dependencies. Suggested mitigations include cookie storage and/or adding content security policy (CSP).

Because these component interact exclusively via WebSockets, cookies may not be an option here. CSP is likely the better solution, though other alternatives may exist.

Resources

@type1fool type1fool added help wanted Extra attention is needed enhancement New feature or request security and removed enhancement New feature or request labels Feb 13, 2023
@type1fool type1fool added this to the Beta milestone Feb 13, 2023
@richard-giraud
Copy link

richard-giraud commented Feb 17, 2023

Upon reflection:

I don't think that CSP would do much to solve the issue. It's capable of stopping XSS reflection attacks but generally little else. It's also a pain to work with and often not used. In this use case, it falls short of the Secure and HttpOnly cookies in terms of practical security.

Is it possible to teardown and rebuild Websocket connections transparent to the user? If this is the case, then it might be possible to use session cookies via AJAX.

@type1fool
Copy link
Collaborator Author

@RGENT Interesting. I read through the Okta blog article about browser storage methods, and it seems like Web Workers would be the solution for this LiveView implementation. Have you dealt with Web Workers for this type of problem?

@type1fool
Copy link
Collaborator Author

From #47:

Instead of setting the token in JS SessionStorage, add a session controller which saves the token in a cookie.

This may eliminate the need for connected?(socket) checks.

Update the demo app to test & document usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed security
Projects
Development

Successfully merging a pull request may close this issue.

2 participants