Skip to content

Remove version from live_session#3715

Merged
SteffenDE merged 1 commit intomainfrom
sd-live-session-vsn
Mar 20, 2025
Merged

Remove version from live_session#3715
SteffenDE merged 1 commit intomainfrom
sd-live-session-vsn

Conversation

@SteffenDE
Copy link
Copy Markdown
Collaborator

@SteffenDE SteffenDE commented Mar 19, 2025

Previously, live_sessions had a version field that was generated randomly whenever the router was compiled. We checked the version field on live_redirects and enforce a full redirect (as when a user navigates, that is a good point in time to force a full navigation, right?).

It turns out that live navigation on the client is actually implemented in a way that every reconnect after the first live navigation is also treated as a navigation. Therefore, after a deployment that changed the router, LiveViews that were mounted through a live navigation were never remounted, but always fully reloaded, losing any state and preventing form recovery from working.

As the security mechanism of live_session is primarily based on the live_session name, checking the name is generally enough. There could be a case where previously a live_session called :admin was defined where a user had access to and after deployment, those routes were instead moved to a :semiadmin live session and now super sensitive routes are accessible in the :admin live session. In this case, a user could try to mount a route from this super sensitive section, but even then, those routes SHOULD be protected by on_mount hooks that run and properly check authorization, e.g. based on the user_id in the session.

So to sum this up, the version field of the live session is not needed, causes problems at the moment and is therefore removed.

Previously, live_session's had a version field that was generated randomly
whenever the router was compiled. We checked the version field on
live_redirects and enforce a full redirect (as when a user navigates,
that is a good point in time to force a full navigation, right?).

It turns out that live navigation on the client is actually implemented
in a way that every reconnect after the first live navigation is also
treated as a navigation. Therefore, after a deployment that changed the
router, LiveViews that were mounted through a live navigation were never
remounted, but always fully reloaded, losing any state and preventing
form recovery from working.

As the security mechanism of live_session is primarily based on the
live_session name, checking the name is generally enough. There could be
a case where previously a live_session called `:admin` was defined where
a user had access to and after deployment, those routes were instead
moved to a `:semiadmin` live session and now super sensitive routes are
accessible in the `:admin` live session. In this case, a user could try
to mount a route from this super sensitive section, but even then, those
routes SHOULD be protected by on_mount hooks that run and properly check
authorization, e.g. based on the user_id in the session.

So to sum this up, the version field of the live session is not needed,
causes problems at the moment and is therefore removed.
@SteffenDE SteffenDE merged commit 0b31deb into main Mar 20, 2025
16 checks passed
@SteffenDE SteffenDE deleted the sd-live-session-vsn branch March 20, 2025 09:56
SteffenDE added a commit that referenced this pull request Mar 20, 2025
Previously, live_session's had a version field that was generated randomly
whenever the router was compiled. We checked the version field on
live_redirects and enforce a full redirect (as when a user navigates,
that is a good point in time to force a full navigation, right?).

It turns out that live navigation on the client is actually implemented
in a way that every reconnect after the first live navigation is also
treated as a navigation. Therefore, after a deployment that changed the
router, LiveViews that were mounted through a live navigation were never
remounted, but always fully reloaded, losing any state and preventing
form recovery from working.

As the security mechanism of live_session is primarily based on the
live_session name, checking the name is generally enough. There could be
a case where previously a live_session called `:admin` was defined where
a user had access to and after deployment, those routes were instead
moved to a `:semiadmin` live session and now super sensitive routes are
accessible in the `:admin` live session. In this case, a user could try
to mount a route from this super sensitive section, but even then, those
routes SHOULD be protected by on_mount hooks that run and properly check
authorization, e.g. based on the user_id in the session.

So to sum this up, the version field of the live session is not needed,
causes problems at the moment and is therefore removed.
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 this pull request may close these issues.

2 participants