Skip to content

fix(auth): keep remember-me cookies pointing at a live session token - #64572

Open
solracsf wants to merge 2 commits into
masterfrom
fix/remember-me-stale-session-token
Open

solracsf wants to merge 2 commits into
masterfrom
fix/remember-me-stale-session-token

Conversation

@solracsf

@solracsf solracsf commented Sep 19, 2026

Copy link
Copy Markdown
Member

Summary

A stale remember-me cookie logs "Could not find the session token to renew" on every request, so affected instances end up with thousands of these. The cookie points at a session token that no longer exists. This fixes two ways that happens:

  • user_oidc and OC_User::loginWithApache() create the session token as "do not remember" but then set the 15 day remember-me cookies. The cleanup job deletes such tokens after session_lifetime (24h by default), so anyone away for a day hits the loop when they come back. createRememberMeToken() now marks the session token as remembered, which also covers user_oidc without a change there.
  • regenerateId(true, true) (password protected share unlock, Talk password rooms) moves the token to the new session id but never updated nc_session_id. The cookie is now rewritten to the new id.

What is not covered: a token that is revoked or logged out via IdP backchannel logout after the browser session already expired still leaves the cookies behind, and each request will still log the error. Tokens that are already orphaned are not repaired, those users have to log in once more.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The remember-me cookie outlives the session token it refers to in two
cases, and cookie login then fails on every request.

A session token created as DO_NOT_REMEMBER (user_oidc, Apache login) is
removed by the cleanup job after session_lifetime, while the cookies last
remember_login_cookie_lifetime. createRememberMeToken() now marks the
current session token as remembered.

ISession::regenerateId(true, true) moves the token to the new session id
but left nc_session_id pointing at the old one (password protected share
unlock, Talk password rooms). The cookie is now rewritten with the new id.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsf requested a review from a team as a code owner September 19, 2026 18:24
@solracsf
solracsf requested review from Altahrim, come-nc, icewind1991 and provokateurin and removed request for a team September 19, 2026 18:24
@solracsf solracsf added this to the Nextcloud 36 milestone Sep 19, 2026
@solracsf solracsf added the 3. to review Waiting for reviews label Sep 19, 2026
@solracsf solracsf self-assigned this Sep 19, 2026
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: InvalidTokenException Token does not exist: token does not exist Renewing session token failed: Token does not exist: token does not exist

1 participant