Limiting what stolen access can do
Some stolen sessions and tokens will get through, however good the sign-in. This lesson looks at the limits that decide what a copy is worth once it has been taken: timeouts, noticing a reused refresh tokenA longer-lived credential that a client sends to the authorization server, never to an API, to get new access tokens without asking the person again., narrow audiences and scopes, binding access to a key, asking again before sensitive changes, and lifetimes people can live with.
A stolen session has a shelf life
At 09:14 on Day 1, a relay page at a look-alike address passed Riley's password and authenticator-app code to Cedar's identity providerA service that authenticates users and tells other applications about the sign-in, so those applications never handle the users' passwords. In OpenID Connect it is called an OpenID Provider. and kept the session cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. it issued. Riley never held that session, so signing out on Riley's own laptop could not end it. Whatever limits Cedar placed on its sessions were the only limits on the attacker's copy.
Staying signed in described two of those limits. An idle timeout ends a session after a period without activity. An absolute timeout ends it after a fixed total time, however busy it is. Against theft, they behave very differently. A thief who keeps using a session keeps resetting its idle timer, so the idle timeout mainly protects sessions nobody is using. The absolute timeout bounds a copy in active use: once it passes, the thief has to sign in, with the password and the second factor.
Applications that keep people signed in for weeks usually renew a session quietly. A renewal must not extend a stolen copy too, so it either stays within the same absolute limit or issues a new identifier and treats any use of the replaced one as a warning sign. Refresh tokens use the same idea, in the next section.
Noticing a reused refresh token
Applications that call APIs face the same question with tokens. Cedar's expense app on Riley's phone calls the expense APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. with access tokens that last minutes, and obtains new ones with a refresh token, as The refresh token grant explained. That makes the refresh token the long-lived credential worth stealing.
Rotation makes each refresh token close to single-use: the server returns a replacement each time and remembers every member of the token family descended from one grant, as Refresh tokens and rotation explained. That record is what lets it notice a copy. If a thief copies R1 from the expense app and refreshes first, the thief receives R2 while the app still holds R1. When the app presents R1, the server sees a used token come back, and because it cannot tell which holder is genuine, it revokes the whole family.
The signal needs both holders to show up. A thief who rotates while the real app is offline never triggers it, so the family also needs an absolute lifetime and an inactivity limit. And a genuine app that retries after a lost response looks exactly like a copy, which is why some servers allow a few seconds of grace and accept a little more replay risk in return. Refresh token theft follows these races at the token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect..
Narrowing what a token can reach
A copy can do only what the original could. A token whose audience is https://api.expenses.example is refused by the training service's API at api.training.example, because it was not issued for that service. A token with the claims.read scope cannot approve an expense claim. Each restriction shrinks what a thief gains. It also limits the damage when the leak happens at an API: an API whose logs are exposed, or which is itself compromised, holds tokens that work nowhere else.
Narrow tokens have to be requested on purpose. A client that calls two APIs can ask for a separate token for each instead of one token that both accept, and a token that only needs to read claims should not also carry permission to approve them. Scopes and audiences explained how these values are requested and checked.
Binding access to a key
Every limit so far reduces what a copy is worth without making it useless, because a bearer tokenA token that works for whoever presents it: the API checks that the token is genuine and current, not who is holding it. That is why bearer tokens must be kept from being copied. is complete in itself. Protecting credentials and messages mentioned the alternative, a token bound to a key pairA private key and a public key generated together and mathematically linked. The private key creates signatures and the public key checks them, but the private key cannot practically be worked out from the public one.. When the authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. issues a sender-constrained token, also called a proof-of-possession token, it records which key the client holds, and the API accepts the token only together with fresh proof that the sender holds the matching private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner.. The client keeps the private key, ideally in storage that will not export it, as Storing and using keys described. Someone who copies the token from a log has the token but not the key.
Two standards do this for OAuthA framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in.. RFC 9449, OAuth 2.0 Demonstrating Proof of PossessionAn OAuth extension, RFC 9449, that binds tokens to a key pair the client holds. The client signs a fresh proof for each request, so a stolen token is useless without the private key. (DPoP), has the client sign a short proof for each request with a key pair it generated. RFC 8705, which defines mutual TLSTransport Layer Security, the protection behind HTTPS. It encrypts traffic between two connected systems, detects changes on the way, and uses certificates so the client can confirm which server it reached. for OAuth, binds the token to the client certificate the client presents when it opens the TLS connection. The specialist lessons Binding a token to a key and Certificate-bound access tokens show how each one works; this lesson needs only the idea that the API asks for proof of a key along with the token.
The same idea can protect browser sessions. In a device-bound session, the browser creates a key pair when the session starts and keeps the private key in the device's secure hardware where it can. The server issues short-lived cookies and renews them only when the browser proves it still holds the key. Malware that copies the cookies gets something that stops working within minutes, because the key it would need to renew them cannot be copied out. The proposal that does this for the web, Device Bound Session Credentials (DBSC), is developed in the W3C and in 2026 is generally available only in Chrome on Windows. A site also has to implement the registration and renewal on its own servers, so most browser sessions today are still plain bearer cookies.
Binding has two limits. Malware still running on the device can ask the hardware to sign, so binding stops replay from elsewhere but not misuse from the victim's own machine. And binding protects only what happens after issue. In a relayed sign-in like Riley's, the identity provider issues the session to the relay in the first place, so the session would be bound to the relay's key. Only a sign-in method that checks where it is used, such as a passkey, stops that.
Predict what happens when each copy below is replayed.
Replay a copied token
Simulation. These replay attempts against Cedar's services are made up, and answering sends nothing. Each record describes a copied credential and how it is replayed; predict the result.
Asking again before it matters
Some actions deserve an extra check whatever the state of the session: changing a password, adding a sign-in method, changing where payments go, or approving another application's access. Re-authentication asks the person to prove themselves again before the action proceeds. Authentication policy and SSO described how a policy can require a recent sign-in or a stronger one.
Cedar had a check of this kind: adding an authenticator required a sign-in within the last fifteen minutes. At 09:20, from a hosting provider's address, the attacker used the stolen session to register an authenticator app of their own, and the check passed without a prompt because the session was six minutes old. A session stolen by a relay is always fresh, since the relay creates it at the moment of the theft. A recency check measures how long ago someone signed in, not who that someone was.
The check needed to ask how the session's sign-in was done, not only when. For actions that add a way into the account, a recent sign-in should count only if it used a phishing-resistant method, such as a passkey or a security key. Otherwise the service asks again, with one of those methods. The same rule lets the recovery walkthrough in Enrollment, replacement, and recovery accept a sign-in made moments earlier with a security key. Riley's 09:14 sign-in used a password and a code, so under that rule the 09:20 request would have stopped at a passkey prompt. Asking for the password and a code again would not have helped, because the relay could pass them along a second time, while a passkey will not sign for a look-alike address. The rule works only when the account has such a method enrolled, and when the policy refuses to fall back to a weaker one.
A notice through a separate channel helps as well. When a sign-in method is added, a message to the account's existing devices or verified email address gives the real owner a chance to react, even after the action has succeeded.
Choosing lifetimes people can live with
Every limit here has a cost for the people it protects. Sessions that end every hour mean signing in many times a day. People asked constantly learn to approve prompts without reading them, choose the quickest method on offer, and tick "remember this device" wherever they can.
The usual answer is to make the strict parts invisible and keep the visible parts rare. Access tokens can last minutes because refreshing them happens unnoticed. Re-authentication is saved for actions that change who can get in or where money goes, and signals such as an unfamiliar network can shorten a session or prompt a check in between.
| Credential or action | Example setting | What limits a stolen copy |
|---|---|---|
| Access token | 10 minutes | Expiry, audience and scope, and a key binding where supported |
| Refresh token | Rotated at each use; the family ends after 30 days, or after 7 days unused | Reuse detection ends the family |
| Session on a managed laptop | 10 hours absolute, 1 hour idle | The absolute timeout, and a device-bound session where the browser supports one |
| Session on an unrecognized device | 2 hours absolute, 30 minutes idle | Shorter timeouts and a new-device notice |
| Adding a sign-in method | Accept a recent passkey or security-key sign-in; otherwise ask for one | Phishing-resistant re-authentication |
The right numbers depend on what each application protects. A consumer service such as the photo service can keep a customer signed in on their own phone for weeks, because refresh token rotation, and a key the app holds where the platform supports one, leave a copy little to work with. A system that releases payments can ask for a passkey before each one, because the people using it expect that check and a stolen session there would cost far more.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Choose token lifetimes and watch an idle refresh token expireSet short lifetimes on the token policy an application uses, issue a token to see them applied, keep a refresh token alive by using it, then let it sit until it expires.