Group
  • Security

    Kill other sessions when the password changes

    Invalidates all existing sessions after a password change or reset, so stolen sessions die with the old password.

    • Improve quality
    • Intermediate
    • General

Free Prompt

Make password changes and resets invalidate existing sessions in my app. Look at the password change and password reset completion handlers and the session storage mechanism. Implement: when a user's password changes (whether via settings or a reset link), every existing session for that account is destroyed server-side except, optionally, the current session performing the change, which should be rotated to a fresh identifier. The user gets an email notification that their password was changed (this doubles as an intrusion alarm: if they didn't do it, they know immediately). If the app supports it, show active sessions in account settings with a "sign out everywhere" option. Do not log the user out of the browser they're actively using to change the password; that's just annoying. Use the session store already in the project; if sessions are stateless JWTs that can't be revoked, tell me and implement a server-side token version or denylist as the smallest workable fix. Give me the changes plus a verification: sign in on two browsers, change the password on one, and confirm the other browser's session is dead while the current one keeps working.

What This Does / How This Helps

Makes a password change actually kick everyone out: all existing sessions die, the current one rotates, and the user gets an email saying it happened. Without this, changing the password after a compromise is theater. The attacker's stolen session keeps working because nothing told it to stop. Users reasonably believe the reset fixed things, and it didn't. The notification email matters too, since an unexpected "your password changed" email is often the first sign of account takeover. The two-browser verification proves the behavior: one session survives (yours), the other is dead.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts