Skip to content

End-session does not revoke the session's authorization, so a refresh token outlives a sign-out #3198

Closed

Description

@pournasserian

Problem

/connect/logout clears only the cookie of the server session (src/FluentCMS.Core/Identity/Oidc/ConnectEndpoints.cs around lines 331 to 358). The authorization and its refresh tokens stay valid until they expire, 14 days for a refresh token, unless the client also revoked the refresh token at /connect/revoke.

The admin revokes at sign-out, but gives the server three seconds at most before it clears the tab and goes to the logout page (#3146), so that a slow or unreachable token endpoint cannot keep a signed-out user looking at a spinner. When that revocation is cut off or fails, the user is signed out everywhere they can see, the tab has forgotten the token, and the token is still good on the server for anyone who copied it earlier. Any other client of the authorization server has the same gap whenever its own revocation call fails.

Found by the review of #3197 (#3146). Read from the code; not reproduced.

Proposal

End-session revokes the authorization of the session it ends, with its tokens, so that a completed logout leaves nothing redeemable; decide and write down what it does for the other authorizations of the same user (another browser, another device), which the account page (#3147) lists and ends one by one.

Acceptance

  • After /connect/logout for a session, a refresh token issued under that session's authorization is refused, in a test
  • The specification says what end-session revokes and what it leaves
  • The decision record of the admin's sign-in (0007) no longer names an unrevoked token after a completed logout as a known gap, or says what remains

Size: S. Goes to main, as bugs do.

Activity

  1. pournasserian commented on Nov 16, 2026

    @pournasserian
    MemberAuthor

    Reproduced. A test against the test host signs in on the hosted login page, runs the code flow with PKCE for the test client, confirms the logout on the logout page (the POST to /connect/logout with its antiforgery token) and then redeems the refresh token: the token endpoint answers 200 with new tokens. /connect/logout cleared only the Identity cookie. The cookie and the OpenIddict authorizations had nothing in common: a "session" of /me/sessions is an authorization, and the cookie held no id that an authorization carried, so the logout could not tell which authorizations were its own.

    Decision (conservative):

    • Every new sign-in cookie, of either pool, carries a server session id in its properties (.fcms.server_session). Renewals, the stamp check and the second-factor page keep it, as they keep .fcms.signed_in_at. The authorize endpoint issues the code of a client without a consent step under an ad-hoc authorization marked with that id (fcms_server_session in the authorization's properties, so no migration).
    • A logout that ends a sign-in revokes, through UserSessions, every valid authorization of the signed-in user marked with that session, with its tokens. The refresh tokens are refused at once. The access tokens are refused from the next request on, since the bearer scheme checks the token and its authorization entries on every request.
    • Several clients signed in through one server session: all of their authorizations in that session end, whichever client asked for the logout.
    • The user's other sessions (another browser, another device) stay; the account page ends those one by one.
    • A third-party client's consent is a permanent authorization of no server session, so it stays, along with the tokens issued under it. It ends on the account page, as today. Revoking it would end that client on every device.
    • A logout without id_token_hint goes to the confirmation page as before. Nothing is revoked until the confirmed POST, so a link can neither sign a user out nor revoke anything.
    • A logout the user does not confirm (leaves the page) changes nothing.
    • A request without the cookie ends no session and revokes nothing, a valid hint included. Nothing is guessed from a hint.
    • A cookie issued before this change carries no session id, so its logout ends the cookie alone, as before.

    The response does not change, so it says nothing about whether a session existed. Sign-outs write no activity row today, and the revocation adds none.

    Corrected after the security review of #3199: where the points below and the list above differ, the points below hold.

    Every place a sign-in ends now ends its session's authorizations. These are:

    • the confirmed logout
    • a logout with the session's own hint
    • the member logout page
    • the remote sign-out of the SSO provider the sign-in came from (/account/sso/{name}/signout), which before ended the cookie alone; the member providers do not serve that path (404), so they have no such entry point
    • the authorize endpoint, where it ends the sign-in for prompt=login, max_age, AbsoluteSessionLifetime or a required second factor

    A sign-in that replaces a live one. I weighed the two ways and took this one:

    • (a) The same user signing in again on the login page over a live cookie keeps that cookie's server session id. Nothing is revoked early, and the later logout finds everything issued in that browser session. This is cheap, since the old cookie is still there to read.
    • (b) A different user signing in over a live cookie ends the first user's session in that browser, as a logout would. The first user is no longer signed in there.
    • (b) The authorize endpoint's re-authentications (prompt=login, max_age, absolute lifetime, second factor) end the replaced session's authorizations at that moment. The endpoint deletes the cookie before the user signs in again, so the old id cannot be carried into the new sign-in without putting it in the login URL. Leaving those authorizations alive would orphan them: no logout could find them again. The cost is that another tab working under that session has its refresh token refused, and it goes through the authorize endpoint once more with the new cookie. For the second factor and the absolute lifetime, the token endpoint already refuses those refresh tokens, so (b) changes little there.

    A hint skips the confirmation only when it is tied to this browser's session, as RP-Initiated Logout says (section 2: the OP must ask if the hint "does not belong to the current OP session").

    • An identity token issued under a session's authorization carries that session as sid.
    • A hint with the cookie's user and the cookie's sid ends the session.
    • A hint from another session of the same user, another device, an earlier sign-in, or one without sid goes to the logout page, which asks, and nothing is revoked.
    • A third-party client's identity token has no sid: its consent belongs to no session. So its hint is always asked about, and it cannot revoke a first-party session without the user confirming.

    A repeated logout with the same hint (a second tab, a double click), where the first logout revoked the hint's token, finds no cookie and returns to the client without asking, as before #3199.

    A browser logout now ends every client without a consent step that signed in through that browser session: a host-registered CLI, a native app using the system browser, a first-party MCP client, whatever offline_access it holds. A client that must outlive a browser logout is registered with RequireConsent, since a consented authorization belongs to no server session. The specification and the release notes say this.

  2. pournasserian commented on Nov 16, 2026

    @pournasserian
    MemberAuthor

    Correction to the decision above, after the second security review of #3199.

    The earlier comment said that prompt=login, max_age, AbsoluteSessionLifetime and the provider's remote sign-out revoke the session's authorizations. They no longer do. Each of them can be caused by one unconfirmed GET from another site:

    • An authorize request with prompt=login or max_age=0 carries nothing secret.
    • Any authorize request past the absolute lifetime carries nothing secret either.
    • /account/sso/{name}/signout is not authenticated: the cookie holds no sid or iss of the provider to match.

    On main, each of these ended the cookie at most. With the revocation, another site could also end the tabs' tokens, so each is back to ending the cookie alone.

    The earlier comment also said that the token endpoint already refuses refresh tokens past the absolute lifetime. That is wrong. fcms_session_start is the time of the authorize request, not of the sign-in, so a code flow late in the lifetime gives a refresh token that rotates past it. That is #3205.

    The follow-ups are #3203 (carry the session across a re-authentication), #3204 (authenticate the provider's remote sign-out) and #3205 (count the absolute lifetime from the sign-in).

    A session's authorizations end at:

    • a confirmed logout, or one with a hint of the session's own sid
    • the member logout page
    • another user's sign-in over the cookie
    • the authorize endpoint's sign-out of a user whose role now requires a second factor (the token endpoint refuses those refresh tokens anyway)

    Two more changes:

    • A GET without the cookie returns to the client without asking only when its hint is an identity token signed by this server: an expired one, or one a first logout revoked, still counts. Any other hint goes to the logout page, as RP-Initiated Logout section 4 asks.
    • A logout whose hint lacks the session's sid is asked to confirm. That covers a third-party client's token and one from a sign-in before this change.
  3. pournasserian commented on Nov 16, 2026

    @pournasserian
    MemberAuthor

    Correction after the third review of #3199:

    • A required second factor at the authorize endpoint no longer revokes anything. It ends the cookie alone, as prompt=login, max_age and the absolute lifetime do. One session can hold tokens with amr=mfa, from a sign-in with the second factor, beside a later password-only sign-in over the same cookie on a remembered device. A cross-site authorize GET would have revoked the mfa tokens too, and the token endpoint would still have rotated them. The token endpoint still refuses refresh tokens without mfa once the role requires it. The access tokens live until they expire, as on main; that is added to A re-authentication asked for at the authorize endpoint ends the sign-in cookie on a cross-site request #3203.
    • A logout without the cookie now checks the client of a hint it cannot read. It returns to the client without asking only for an identity token signed by this server with its algorithm, issued to the client that client_id names, whose post_logout_redirect_uri is registered for that client. Any other hint goes to the logout page.

    The authorize endpoint therefore revokes nothing. A session's authorizations end at a confirmed logout or one with the session's own hint, at the member logout page, and when another user signs in over the cookie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:identityUsers, authorization server, API keys and memberstype:bugDefect

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions