Skip to content

An admin user's password change leaves its access tokens valid until they expire #3202

Open

Description

@pournasserian

What happens

When an admin user's password changes, the user gets a new security stamp. That ends the sign-in cookie, the authorization codes and the refresh tokens (the token endpoint compares the stamp, ConnectEndpoints.cs), but the user's authorizations are not revoked, so every access token already issued keeps working until it expires: one hour by default (ClientOptions.AccessTokenLifetime).

The member pool does revoke: MemberAccountService.ResetPasswordAsync and ChangePasswordAsync call sessions.RevokeAllAsync, and the server validates token and authorization entries (EnableTokenEntryValidation, EnableAuthorizationEntryValidation), so a member's access tokens stop at once. The admin pool's two-factor reset does the same (backend spec, the two-factor paragraph: "then revokes every session of the user through UserSessions, so its access tokens stop at once too").

Places of the admin pool that give a new stamp and do not revoke, to be checked one by one:

  • the change-password page (Api/Account/ChangePasswordModel.cs), which then refreshes the cookie of the browser that made the change;
  • the password reset (PasswordResetService.ResetAsync);
  • UserAdministration.SetPasswordAsync (the command line), whose comment says it "ends the user's sessions with a new security stamp";
  • removing an external login, a new name or address set by an admin, and turning two-factor on, where the specification says the stamp "ends the user's sessions" or "the user's codes and refresh tokens".

Someone who changes a password because it leaked expects the other party to be out now, and for up to an hour it is not.

Expected

Settle one rule and hold both pools to it. The conservative one: a password change or reset revokes every session of the user through UserSessions.RevokeAllAsync, as the member pool does; the browser that made the change on the change-password page keeps its cookie (it has the new stamp), and its own tokens end with the rest, so its tabs sign in again silently. For the other stamp changes, either revoke too or make the specification say "refresh tokens and cookie; access tokens run out within their lifetime".

Acceptance

  • After a password change and after a reset of an admin user, an access token issued before it is refused by the Management API at the next request.
  • users set-password on the command line does the same.
  • Each other place that gives a new stamp either revokes or is described exactly in the backend specification.
  • Tests for each, with one that shows the browser that changed the password is not signed out of the hosted pages.
  • Release notes say what a password change ends.

Found in the review of #3199 (#3198).

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions