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

Turbo signed-stream-name never expires #85

Open
eliotsykes opened this issue Sep 11, 2023 · 1 comment
Open

Turbo signed-stream-name never expires #85

eliotsykes opened this issue Sep 11, 2023 · 1 comment

Comments

@eliotsykes
Copy link
Owner

eliotsykes commented Sep 11, 2023

Turbo's signed stream names provided by turbo_stream_from never expire: hotwired/turbo-rails#61

Example of how this could be a problem

  • Turbo stream is generated for a @team of users:
<%= turbo_stream_from @team %>
  • A team member saves the generated signed-stream-name, or keeps a page open containing the generated <turbo-cable-stream-source signed-stream-name=...> tag in their browser.
  • This team member is removed from the @team.
  • The removed team member can still receive data from the turbo stream as they have the signed-stream-name.

Potential mitigations?

@lu-x
Copy link

lu-x commented May 22, 2024

This team member is removed from the @team.
The removed team member can still receive data from the turbo stream as they have the signed-stream-name.

I think as a first step you can add authentication on the ActionCable level, this will prevent the user from connecting and subscribing to any channel without a valid session.
If the user has a valid session (for example with a new account) i guess authorization has to take place during the subscription to the specific channel.

Example: https://github.com/hotwired/turbo-rails/blob/main/app/channels/turbo/streams_channel.rb#L11
However, i'm not sure what's a good way to authorise the user, maybe it's possible to include a user id in the stream name and then compare it to the user id retrieved from the session (?).

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