Identity, sessions, and phishing-resistant sign-in

Most modern intrusions borrow a real login. This lesson is about sessions, factors, and the controls that make stolen passwords less useful.

Lesson 1 of 29 · 13 min read · practice only with authorization

Diagram

A session’s life

Follow the path. One example at a time.

Step 1 of 4

Sign-in

Password plus a factor, ideally a passkey.

Illustration: Sign-in
# Sign-in
# Password plus a factor, ideally a passkey.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Bearer tokens

    What fails
    Whoever holds the session token is the user.
    Who is affected
    Account owners.
    What you would notice
    Tokens readable by scripts or logged in URLs.
    What you change
    HttpOnly, Secure cookies; never tokens in URLs.
  2. Factor strength

    What fails
    SMS and push are phishable; passkeys are not.
    Who is affected
    Users targeted by phishing proxies.
    What you would notice
    Admins using SMS codes.
    What you change
    Passkeys or FIDO2 for privileged users first.
  3. Revocation

    What fails
    Logout that only deletes the browser cookie leaves the session valid.
    Who is affected
    Users on shared or stolen devices.
    What you would notice
    Old tokens still accepted after logout.
    What you change
    Invalidate sessions server-side.

A session is a bearer capability

After a successful login the server, or the identity provider, hands the client a cookie or a token. Anyone who copies it can present it. That is session hijacking in one sentence. The copy might come from malware on the endpoint, a backup of a browser profile, a leaked log, or a proxy that sat in the middle of the login.

Defend the token like a password that expires. TLS on every hop. Cookies marked Secure and HttpOnly. Short lifetimes, refresh that rotates, and revocation that actually drops existing sessions when a user reports a theft. A password reset that leaves the stolen refresh token alive did not end the incident.

Factors are not equal

SMS codes and push notifications stop casual reuse of a leaked password. They do not stop a real-time proxy that asks the person for the code and forwards it, and they do not stop a person who taps Approve to make the prompts stop. That second story is MFA fatigue. The first is adversary-in-the-middle.

Phishing-resistant factors, passkeys and other FIDO2 authenticators, bind the login to the real site. A lookalike domain does not get a usable assertion. They are the control to prefer for administrators, finance, and anyone who can move production. App-based one-time codes are a step up from SMS and still phishable in real time. Say that plainly when you advise a team.

The directory is the crown jewel

Cloud admin, email admin, and the identity provider's global admin are not normal users with a different icon. A token for those roles can create users, add factors, and read mail that resets everything else. Separate admin accounts, require phishing-resistant MFA, alert on new factors and new OAuth grants, and do not leave standing global admin in a daily browser profile.

Service accounts and OAuth apps are users too. An integration granted mailbox read for a feature nobody remembers is a standing incident. Review grants. Expire them. Name an owner.

What to watch

Useful identity signals are impossible travel that is actually impossible, a new device on a privileged account, a consent grant to an unfamiliar application, a burst of failures across many accounts with one password, and a successful login immediately after those failures. Password spraying and credential stuffing leave different shapes. Your identity provider can show both if someone is looking.

Practice in a lab tenant you own. Create two users, enroll a factor, sign in from a second place, and find the event in the log. Then write the sentence a responder would want: who, what changed, and how to revoke. The older lessons on sessions and phishing describe the older mechanics. Pair them with this operational view.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

After logout, an old session cookie still works. What is missing?

Go deeper

Specific techniques, exercises, and glossary cards for this topic.

  1. 01Rotate the session when sign-in succeedsA session id that survives sign-in was known before the person proved who they are. Includes the diagram and a defensive fix.
  2. 02Where a bearer token lives in the browserA token in local storage is readable by any script on the page. Includes the diagram and a defensive fix.
  3. 03Passkeys are bound to the originA passkey signs a challenge for a specific site. Includes the diagram and a defensive fix.
  4. 04Recovery that bypasses the passkeyA passkey on the front door does not help if email reset, SMS, or the help desk can still replace it with a phishable factor. Includes the diagram and a defensive fix.
  5. 05Exact redirect URI matchingThe redirect URI is where the authorization code goes. Includes the diagram and a defensive fix.
  6. 06Token audience and the smallest scopeA token is a capability for a specific API, for a specific set of actions, for a limited time. Includes the diagram and a defensive fix.
  7. 07Real-time phishing of a sessionA one-time code can be relayed as the person types it. Includes the diagram and a defensive fix.

Exercises

  1. 01Terminal lab: sign-in logThe sign-in log records prompts that continued until a new session appeared. Name that failure.
  2. 02Control benchPrompts continued until one was approved. Choose a factor that does not depend on a bare approve tap.
  3. 03Cookie flag simulatorSix Set-Cookie headers, six kinds of request. See which cookies the browser sends, which scripts can read, and which it rejects outright.
  4. 04OAuth redirect URI matcherTest attacker-chosen redirect URIs against exact, prefix, host, and wildcard matching, and see which strategies leak an authorization code.
  5. 05Terminal mission: Oslo, then Lagos, 26 minutes laterRead an Entra ID sign-in export with jq. Find the sign-in from a country the user could not have reached, the app it opened, and why MFA did not stop it.

Glossary

  1. 01PhishingA message imitates a trusted sender and persuades someone to hand over credentials or run a file.