# Security

Source: https://keyringauth.com/docs/0.x/security

## Introduction

This page lists what Keyring guarantees, the limits of each guarantee, and the reason for each limit. It covers how sign-in, rate limits, codes, sessions, account changes, links and logging are protected. It also covers what Keyring stores and what your app must provide itself, such as HTTPS, proxies, cookies and bot checks. The last sections list where Keyring departs from a standard and where the standards come from.

Read the limits before you rely on a guarantee. The [conformance suite](https://keyringauth.com/docs/0.x/testing#the-conformance-suite) tests several guarantees against your configuration, and the [OWASP ASVS and NIST SP 800-63B](https://keyringauth.com/docs/0.x/owasp-asvs) page goes through each requirement.

A guarantee about a [feature](https://keyringauth.com/docs/0.x/quick-start#adding-features), such as devices or email changes, applies once you turn that feature on.

## Guarantees

### Signing In

- A wrong password and an unknown account get the same error, field and status code.
- A sign-in succeeds only for a user the guard can load back through its provider, so a passkey that belongs to another model fails even when the IDs match.
- Every refused verification takes at least `timebox` (500ms by default), and unknown accounts still run a password hash, so timing doesn't reveal which accounts exist. The timebox covers the whole pipeline, so a `429` waits too, and so does a correct password that a risk lock or response turns down, which answers like a wrong one. A refused password reset is held for the same time. The timebox only hides a difference while it's [longer than a hash takes](https://keyringauth.com/docs/0.x/configuration#pending-logins-timebox-and-rate-limits).
- A password longer than its stored hash can check (72 bytes for bcrypt) fails like a wrong one wherever Keyring checks a password, and never reaches the hasher.
- Passwords are normalised to Unicode NFC before they're measured, hashed or checked, so a password typed on one device works on another that composes characters differently.
- A pending login is encrypted JSON in the session, never `serialize()`d, and expires after `pending_logins.keep_for`, and ends when the password or email changes, when a proven sign-in method is removed, or when `keyring.guard` changes. An email change or undo also ends a sign-in waiting for a code, since the code may have gone to an address the account no longer has.
- Keyring regenerates the session ID, and destroys the old one, on every proof (sign-in or step-up) and on every change to how the account signs in (password change, sign out everywhere else, applied email change, new sign-in method). So a copied cookie stops working, and a session planted before the password step doesn't share the pending login.
- A signed-in session also moves to a new registry record each time, on every session driver. That signs out a copy through its record, which matters on Laravel's `cookie` driver, where nothing on the server can be destroyed, and on server-side drivers, where a request sent with the old ID could save the old session again.
- A password reset never signs anyone in, so your policy applies at the next sign-in.
- Registration doesn't reveal whether an address has an account, unless you set `registration.reveal_taken`. Every address gets the same response, cookies, session, validation, timing and one password hash, and emails go after the response. Nobody is signed in by registering. Keyring decides whether an address is taken, so this holds however your action is written, as long as the action doesn't check for itself. A password the hasher can't take is refused for every address, whatever your action's rules say. Anything else `create()` throws is reported and answered like the rest. See [Registration](https://keyringauth.com/docs/0.x/sign-in-flow#without-revealing-who-has-an-account).
- While registration hides who has an account, an account can't sign in until its address is verified, and a correct password gets the same answer as a wrong one until then. Verifying takes the emailed link and the password together, so neither a mail-less registrant nor a stranger who never chose the password gets a verified account. A followed link lets in only the browser that followed it. A finished password reset also verifies the address.
- A rehash is saved only over the hash that was checked, under a row lock, so an overlapping reset can't be overwritten by the old password. Device trust granted by that overlapping sign-in is withdrawn when its session ends.
- An identity provider sign-in finds the user by issuer and subject, never by email. Nobody is signed up or linked by their address, and an unlinked account gets the same error as a wrong password. The callback finishes only a request this browser started, once, with PKCE and, for OpenID Connect, a nonce, and checks every ID token's signature, issuer, audience and times. See [Security Notes](https://keyringauth.com/docs/0.x/sso#security-notes).
- A login attempt can't sign the owner out: risk responses at login never revoke sessions, change the "remember me" token or stop trusting devices, even for a custom responder.

### Rate Limiting

Keyring checks each factor's limits in the pipeline, before it looks at the proof.

- **Per account**: `limits.per_account` attempts a minute (5). Every way of typing a username shares it, because Keyring resolves the account first. Guesses at login and at confirmations count together, and two accounts never share a count. Browsers carrying the account's device cookie count in one shared bucket of their own, so guessing from outside can't lock the owner out. The bucket is shared because an attacker may hold many of those cookies. A browser stops counting as known after a password reset, a password change, a sign-out everywhere or a new sign-in method other than recovery codes, until it signs in again.
- **Per typed username**: a sign-in that names an account is also counted under the name as typed, whether or not anyone has that name. Only this count answers with a `429`. The account's own limit refuses quietly, like a wrong password, so locking an account under one name reveals nothing about its other names. A sign-in under a name doesn't clear that name's counts, since clearing them would show which names have accounts. A reset, a new password and `Keyring::unlock()` leave typed-name counts alone, so a refused name stays refused to anyone without the password, and the owner still gets in. A success takes back only its own attempt from the name's per-minute count. A passkey counts against no name, because it's found by its credential.
- **Per IP address**: `limits.per_ip` attempts a minute (20), shared by every account on that address. A browser carrying the account's device cookie counts per IP for that account alone, so people sharing an address can't hold it up. Behind a load balancer, configure [trusted proxies](https://keyringauth.com/docs/0.x/security#trusted-proxies), or every user shares its address.
- **In a row**: `limits.consecutive` failures (100, the most NIST SP 800-63B-4 allows, Sec. 3.2.2) on one authenticator, however slowly they come. Each authenticator and each set of recovery codes has its own count, and so does the password. The counts live in the database, so clearing the cache doesn't reset them. Setting `null` removes the cap, and without one, guessing just under the per-minute limit would never stop. With `Features::devices()` on, browsers the account hasn't signed in from may make only `limits.consecutive_elsewhere` (80) of the failures, leaving the rest for the owner's browsers.

How they count:

- Each attempt is counted before it's verified, so overlapping requests can't all slip under the limit.
- Routes that spend session state take Laravel's session lock (`->block()`). These are sign-in, passkey options, challenges and verifications, enrollment, renaming and removing an authenticator, the single sign-on routes, changing the password, signing out other sessions or devices, confirming an email change, and the impersonation start and stop routes. This stops parallel requests reusing a WebAuthn challenge, and stops a stolen cookie and its owner running a change at once. The lock is only as good as its store, which must be [shared by every server](https://keyringauth.com/docs/0.x/security#a-shared-lock-store). Sent codes don't depend on it; they're [used up in the cache](https://keyringauth.com/docs/0.x/security#single-use-codes).
- When failures reach an account's limit, that key locks. Each lock lasts twice as long as the last, from one minute up to a day (`limits.longest_lock`). The lockout count resets a day after the first lock.
- The per-IP limit locks the same way, but never for more than 15 minutes (`limits.longest_ip_lock`). A person failing behind carrier-grade NAT or an office network holds the others up for a quarter hour at most, and someone spraying from one address still slows to about `limits.per_ip` guesses every 15 minutes. A browser carrying the account's device cookie isn't held up, and an attempt the address refuses doesn't count against the account. With `Features::devices()` off, everyone on the address waits.
- A success clears the account's per-minute count and the failures in a row made by its own kind of browser. It doesn't clear typed-name counts, and it takes back only its own attempt from the per-IP count. An attacker can't reset either limit by signing in to an account of their own.
- A completed password reset clears the failures in a row, per-minute counts, locks and lockout count for the factors that can start a sign-in, and for each known device. A new password chosen while signed in does the same. Second factors keep their counts, because a reset only proves the mailbox and could otherwise be repeated to keep guessing a code. The reset is logged as `password_reset`, and per-IP limits stay in place.
- Requests that don't name an account, such as usernameless passkey sign-ins, get only the per-IP limit, so junk requests can't fill a bucket every user shares.
- A factor checked inside another request counts the same way, including a password typed to add or remove a second factor and a key or code that [proves a change while sign-in methods are frozen](https://keyringauth.com/docs/0.x/authenticators#making-a-change-with-an-established-key). A wrong one dispatches `FactorFailed`, and one the limits refuse dispatches `Lockout`, or `AccountLocked` at the cap on the password. The count is kept before any change is made, so a refused change doesn't take it back.

Keyring keeps per-minute counts, locks and typed-name failures in `cache.limiter`, a key you set in `config/cache.php` (`null` uses your default store). Sent codes, answered WebAuthn challenges and the end of an [impersonation](https://keyringauth.com/docs/0.x/impersonation#how-it-works) are kept there too, and [risk locks](https://keyringauth.com/docs/0.x/risk#actions) are in `risk.store`. So is the mark of when the account's browsers were last forgotten, which decides whether a device or a `known_browser` cookie still counts as known. A count that has gone reads as no attempts, so losing those keys restarts the limits and lifts risk locks, and losing the mark makes browsers the account forgot count as known again until it next forgets them. `php artisan cache:clear` and `optimize:clear` empty the default store, and a store that evicts under memory pressure can drop keys one at a time. The failures in a row and the held locks are in `keyring_failure_counts`, so the cap holds whatever the cache does. Point `cache.limiter` and `risk.store` at a persistent store that doesn't evict and that deploys don't clear, such as a database or Redis store. Octane's in-memory store isn't suitable ([Octane's Cache Store](https://keyringauth.com/docs/0.x/security#octanes-cache-store)).

#### At the Cap

An authenticator that has failed `limits.consecutive` times in a row is disabled for that account, as NIST SP 800-63B-4 asks (Sec. 3.2.2). What re-enables it depends on the factor:

- **One that can start a sign-in** (the password or a passkey) is cleared by a completed password reset, a new password chosen while signed in, or `Keyring::unlock($user)`. The sign-in form tells the user to reset the password (`keyring::keyring.locked`). Keyring dispatches `AccountLocked`, logs `account_locked`, and by default emails the owner, who may not be the one guessing (see [the `account_locked` notice](https://keyringauth.com/docs/0.x/security-log-and-emails#email-types)).
- **A second factor** is cleared by removing it and adding it again. The user signs in another way, with another factor or a recovery code, and the challenge page says so (`keyring::keyring.factor_locked`, with a `429`). Each refused attempt dispatches `Lockout` with a `retryAfter` of `null`. A password reset doesn't clear it.

A support tool of your own can clear one factor's counts and locks:

```php
use Keyring\Facades\Keyring;

Keyring::unlock($user);            // the password and passkeys, and the risk lock
Keyring::unlock($user, 'totp');    // every authenticator app the user has
```

NIST says a disabled authenticator is bound again, not switched back on, so `unlock()` goes further than the standard. Use it only after you've checked who you're unlocking it for, because for a second factor nothing else stands between whoever has the password and another round of guesses.

Before the cap, a success clears the count for its own kind of browser. A reset, a new password and `Keyring::unlock()` clear it for the factors that can start a sign-in, and nothing else does. The rows are never pruned, because a row is what keeps an authenticator refused.

> [!WARNING]
> Someone who knows a username can guess its password from elsewhere, 80 wrong passwords, about 20 minutes at four a minute, which never meets a lock. Someone who runs into every lock needs a day and a half instead. After that the password is refused from every browser the account hasn't signed in from, until its owner resets it. The owner's own browsers keep working, because the last 20 failures can only come from them. With `Features::devices()` off, no browser is known, so all 100 failures are shared, and the password is refused everywhere after about 25 minutes.

A typed name nobody has can't be counted in the database, so its failures are counted in the cache for `limits.remember_names_for` (30 days) from the first one. Those counts answer the sign-in form. A name with an account, a second name for an account at the cap, and a name with no account each get a `429` after the same number of failures. If the cache loses a name's count, the name reads as "wrong password" again, while the account stays refused.

#### Locking Until a Reset

By default every lock lifts by itself, and only the cap stops a steady guesser. To stop a fast guesser sooner, set `limits.lock_after`:

```php
'limits' => [
    'lock_after' => 5,
],
```

Once an account has been locked that many times within a day, on a factor that can start a sign-in, it's refused as it would be at the cap. With the default one-minute window, the fifth lock comes after about a quarter of an hour. At most eleven locks start in a day, so a value above 11 never holds anything. The lock ends with a completed reset, a new password chosen while signed in, or `Keyring::unlock($user)`, and it's kept in the database, so time and a cleared cache don't lift it. The [`account_locked` notice](https://keyringauth.com/docs/0.x/security-log-and-emails#email-types) tells the owner that a reset unlocks it, unless `account_locked` is `null`.

The lock follows the same rules as the other limits. Browsers the account has signed in from are locked apart from everyone else. A name nobody has is held from the cache for `limits.remember_names_for`, and then answers like a wrong password while the account stays locked. Second factors are never held, because a reset wouldn't clear them, so they keep the cap. A hold reached under another name, or placed by wrong passwords on a confirm page in a signed-in session, lands on the account's own limit and is answered quietly. Tell the user through the `account_locked` notice, or from `AccountLocked`.

It's off by default. It only brings a fast guesser to the cap sooner: in a quarter of an hour instead of a day and a half.

You can set limits for a factor by overriding its `limits()` method. A factor that leaves out the default list also leaves out the cap on failures in a row, so add to that list rather than replacing it. A reset clears only the keys the default builds, so a factor with its own per-account keys should clear them in a `PasswordReset` listener.

Routes outside the factors use the named `keyring` limiter through `keyring.throttle`: registration, password reset requests and resets, email change requests, enrollment confirmations, removing an authenticator, verification emails, and the buttons on pages that emailed links open. They share 6 requests a minute per user, or per IP address for guests. Keyring counts a request only after its session middleware has accepted the session. Laravel's own `throttle` runs earlier, so a "remember me" cookie of a session the owner ended could otherwise use up the owner's six.

Password changes and signing out everywhere else use `keyring-session-changes`: 6 requests a minute per session, and 30 a minute for all the user's sessions together. A session someone else holds can't spend the owner's six, and signing in on many sessions doesn't multiply the guesses at the current password. Requests on ended sessions are signed out before they count. Where the session middleware is off, the limiter keeps a separate count for them. `keyring-pages`, at 60 a minute per IP address, keeps a mail scanner following an emailed link from using up the six. `keyring-login-options`, at 60 a minute per IP address, covers the usernameless passkey options that the login page fetches on every load. A refused request is logged as `rate_limited`, once for each wait. You may redefine each limiter ([Rate Limits](https://keyringauth.com/docs/0.x/configuration#pending-logins-timebox-and-rate-limits)).

Each account can be sent three codes per factor every 10 minutes (`limits.codes` and `limits.codes_per`) in each of three buckets, so nine at most whoever asks:

- Sign-ins from browsers that can't show they ever signed in to the account share one.
- Sign-ins from browsers that can share another: a browser with one of the account's devices, or with [devices](https://keyringauth.com/docs/0.x/devices-and-sessions) off, the encrypted cookie (`known_browser`) a finished sign-in gives it. Either counts only if it signed in after the account's browsers were last forgotten, which a password reset, a password change and a sign-out everywhere do, and so does adding a sign-in method other than recovery codes, since browsers that signed in without it never proved it. The mark of when that was is kept in `cache.limiter` (see below), so clearing that store makes forgotten browsers count as known again. Someone who knows the password but can't read the inbox has neither, so their sign-ins can use up the first bucket and never this one, and the owner can still be sent a code to finish signing in. It's one bucket for all of them, not one each, since whoever can sign in can make any number of browsers known.
- Step-ups and enrollments share the third, whichever browser asks.

Each send is counted before it's checked, so sends at once get exactly the limit.

Mail that isn't a guess has a count of its own. A successful sign-in is never counted. An account gets each kind of [security notice](https://keyringauth.com/docs/0.x/security-log-and-emails#security-emails) five times an hour (`limits.notices` and `limits.notices_per`), and can ask to change its email that often. A typed address is mailed about a change that often too, and registration mails an address that often. Every event still reaches the security log.

No security notice goes to an unverified `MustVerifyEmail` address, because whoever typed it may not own it. The notice of a finished reset is the exception, since the reset link went to that address.

#### Octane's Cache Store

Under Octane on Swoole, Laravel's `octane` store is a Swoole table in server memory. It's fast, but keep `cache.limiter` and `risk.store` on a database or Redis store. A test run on the `octane` store found:

- **Keys hold 63 bytes.** Everything Keyring keeps there fits, under a short prefix and a hash.
- **Rows aren't freed when they expire.** A table of the default 1,000 rows filled after a couple of hundred failed sign-ins for made-up names, and every later sign-in that needed a row answered `500`. Size `octane.cache.rows` for everything your app caches there.
- **Counts aren't atomic across workers.** With 48 wrong passwords sent at once against a limit of 5, 8 got through. The database store never let more than 5. Anything that must happen once (a sent code, an answered challenge, an enrollment's confirmation) relies on the store taking only one of two writes.
- **"Forever" is one year, and a restart loses everything.** Marks kept for good run out after a year, and every count, lock, sent code and mark is lost on restart.
- **The session lock needs another store.** If `CACHE_STORE=octane` is your default, set `session.block_store` to a store with locks, because this table has none ([A Shared Lock Store](https://keyringauth.com/docs/0.x/security#a-shared-lock-store)).

The failures in a row and the held locks are in your database, so the cap holds; see [Rate Limiting](https://keyringauth.com/docs/0.x/security#rate-limiting). The per-minute limits, sent codes and risk locks are only as good as their store.

### Single-Use Codes

- A TOTP code can't be reused. Each authenticator stores the last step it accepted and updates it under a row lock.
- A TOTP code is accepted for one 30 second step either side of now at most. With a [window of zero](https://keyringauth.com/docs/0.x/factors#authenticator-apps-totp), only its own step counts, and no wider window can be set.
- Each recovery code works once, under the same row lock. If two different codes are used at once, both stay valid until used.
- A set that has had a code used says so until it's replaced (`shouldReplaceRecoveryCodes()`). Keyring doesn't issue a new set itself ([Known Limitations](https://keyringauth.com/docs/0.x/security#where-keyring-departs-from-a-standard)).
- Email codes are random, eight digits by default, sent as one run of digits such as `48291374`, in the body and never the subject, which mail providers and apps log. Each expires after 10 minutes and allows five wrong guesses per pending attempt. `EmailCode::asExtraStep()` takes `length`, `expireAfter` and `maxGuesses`. A newer code replaces the older one without resetting the count, and a sent code verifies only the authenticator it was sent to.
- A code factor can't be registered with codes shorter than six digits or lasting longer than ten minutes, which throws a `LogicException`. This covers your own [code factors](https://keyringauth.com/docs/0.x/factors#writing-a-code-factor) too.
- A sent code works once on every session driver. Its state (the keyed hash of the code, wrong guesses and use) is in `cache.limiter`, filed under the sign-in, step-up or enrollment it was sent for. A right code is used up as soon as it's checked, even if a later step refuses the sign-in. A newer code ends the older one, and the guesses stay counted. Clearing that cache clears pending codes too, so the user asks for another.
- An email code's [sign-in link](https://keyringauth.com/docs/0.x/factors#signing-in-from-the-email) carries its code, encrypted with `APP_KEY` together with the sign-in it was sent for, and nothing about the link is stored. It finishes only that sign-in, only in the browser whose session holds it, by posting the code as typing it would, so it shares the code's single use, expiry, guess limit and rate limits. Anywhere else, its page finishes nothing and doesn't show the code, only asks for it to be typed from the email. So a scanner opening it signs nobody in or keeps a working code, another device isn't signed in, and the owner can't approve from their inbox a sign-in someone else started with the password.
- An enrollment adds its sign-in method once. Its confirmation is remembered in the same cache until it would expire, so an earlier copy of the session can't confirm it again and bring back replaced recovery codes.
- WebAuthn challenges are random 32 byte values kept in the session with their ceremony. The first answer uses a challenge up, right or wrong, and the answer is remembered in `cache.limiter` until it would expire. So a signed answer can't be replayed on any session driver, even from an earlier copy of the session that still holds the challenge. That matters most for a synced passkey, whose signature counter stays at zero.
- The rule covers every ceremony: usernameless sign-in, second factor, step-up, adding a key, and proving a key to [make a change while sign-in methods are frozen](https://keyringauth.com/docs/0.x/authenticators#making-a-change-with-an-established-key). A passkey that verifies on the second-factor step has used its challenge up, even if a later check refuses the login.
- A challenge completes only the ceremony it was issued for. One from the usernameless options can't finish a second factor or step-up. A challenge issued to prove a frozen change is bound to that change and its account. Nothing else can stand in for it, and answering it for another change uses it up. Keyring claims it in `cache.limiter` on the first answer, so this holds for your own factor too.
- Challenges also expire on the server: usernameless ones after `webauthn.login_options_for` (5 minutes), second-factor and step-up ones with their pending login (10 minutes), new key ones with their enrollment (15 minutes), and frozen change ones like usernameless ones.
- A passkey's signature counter is checked and saved under a row lock, so two assertions can't both pass and a slower request can't lower it.

### Second Factors and Step-Up

- Two factors of the same kind never count as multi-factor, and AAL2 needs one factor the user has (NIST SP 800-63B-4, Sec. 2.2.1). A password with a biometric-only factor makes an AAL1 session.
- Assurance levels follow NIST SP 800-63B-4 as far as a library can check. A syncing passkey reaches AAL2. AAL3 needs a phishing-resistant key that can't leave its device, was added with a verified attestation, and verified the user itself or was used with a password. Another built-in authenticator's user verification never counts beside it. A factor of your own that reports only inherence does count beside an attested key (Sec. 2.3.1). A key nothing vouches for stays at AAL2, though a policy can still ask for one with `deviceBound()`.
- NIST's AAL3 also needs validated (FIPS 140) authenticators and cryptography, which Keyring can't supply or check. So a session Keyring calls AAL3 meets NIST's rules for the authentication only.
- Email codes are opt-in through `EmailCode::asExtraStep()`. Email isn't an accepted authenticator, and the inbox can reset the password anyway, so a code is a sign-in step, never a factor. A password and a code make an AAL1 session, which doesn't pass `keyring:aal2` or `keyring.enrolled`, doesn't earn a trusted device, and can't stand in for a possession factor. A [sign-in link](https://keyringauth.com/docs/0.x/factors#signing-in-from-the-email) beside the code counts for exactly as much.
- A passkey counts as inherence only when it verified the user that time.
- The first recovery codes are shown only to a session that has proved two factors, and confirming a new sign-in method counts that proof from the same response (Sec. 3.1.2.1). Later sets need a fresh verification of both factors.
- With `noDowngrade()`, users with a passkey or security key aren't offered a weaker way in. Recovery codes stay on offer unless you pass `except: []`. Only keys the account has had for 7 days count (`authenticator_changes.established_after`), so a key added from a stolen session doesn't stop the owner's other factors working.
- With `ifEnrolled()`, a policy the user can't fully meet asks for the strongest version they can give, so a user with a second factor never signs in with one. Only authenticators the account has had for 7 days decide how much that is. A newer one counts when used, but doesn't add a factor kind or count as phishing resistant, device bound or attested. So a stolen-session key can't make `factors(3)`, `phishingResistant()`, `deviceBound()` or `aal3()` ask the owner for a factor they lack.
- The exception is an account with an established password and no established second factor: adding one takes the password, so its new factors are asked for at once. A factor added without the password being checked, while the account had none or its only one was new, isn't asked for until it's established. A requirement stated outright, without `ifEnrolled()` or through middleware such as `keyring:aal3`, takes any key that meets it.
- Adding, removing or changing sign-in methods, revoking devices, changing the password and starting an email change need a fresh verification at the strongest combination the account can give, and at least what signing in would ask (Sec. 4.1.2.1). Users with a possession factor use one, and users with a non-exportable key use that key. A stolen session plus a phished password and code isn't enough once the session is no longer fresh.
- A recovery code with the password stands in for a lost key, as NIST's recovery allows. At a step-up, a recovery code never counts alone. An account with only recovery codes beside its password confirms with the password. Only keys held for 7 days are asked for, so the owner can remove a key someone else added.
- Adding a second factor to an account with no established one takes the current password in that request, which a recent sign-in doesn't replace, so a copied session can't give a password-only account a factor its owner doesn't have. A first password set from a session isn't established for 7 days, so it isn't asked for until then.
- A sign-in step sent to an address of its own, such as a [code factor](https://keyringauth.com/docs/0.x/factors#writing-a-code-factor) returning `Category::Address` that texts a number given at enrollment, is guarded the same way though it isn't a factor: adding one takes the password where a second factor would, one added without it isn't asked for until it's established, a new one starts the freeze, and an established one can't be removed, renamed or replaced while frozen. Otherwise a copied session could add one sent to itself, and the owner would be asked for a code they never get at every sign-in, which a reset wouldn't undo. The built-in emailed code goes to the account's own address, so it's added and asked for at once as before.
- An account's sign-in methods are [frozen](https://keyringauth.com/docs/0.x/authenticators#frozen-sign-in-methods) for 7 days after one is added (including a first password set from a session), and after an established one or recovery code set is removed or replaced. While frozen, established authenticators can't be removed, renamed or replaced, and established recovery codes with codes left can't be replaced. A newer authenticator can always be removed. `AuthenticatorChanges` enforces this for JSON clients and your code too.
- The owner can still make one change by proving, in that change's own request, a passkey or security key (or a phishing-resistant factor of your own) the account has had 7 days and since before the session signed in. A sign-in or step-up never counts, and an authenticator app counts only with `authenticator_changes.skip_with_totp`. Recovery codes, emailed codes and the password never do.
- The fresh window is fixed from the moment of verification and doesn't slide.
- Users can't add a sign-in method until their email is verified (`MustVerifyEmail`), so a planted factor can't survive the owner's reset. With registration on, a user model that can't verify its email can't add sign-in methods.
- Users can't remove authenticators below what they need to sign in, even several at once.

### Sessions and Devices

- Every signed-in Keyring route checks the guard (`auth:{guard}`), and the step-up middleware reads the user from it too, so a user of another guard can't stand in.
- Every signed-in session is in Keyring's registry, which is checked on every `web` request unless `sessions.middleware` is `false`, and on any group you add `keyring.session` to. A revocation takes effect on the next request, whichever driver you use. Timeouts and revocations reach only routes that run that middleware. The [conformance suite](https://keyringauth.com/docs/0.x/testing#the-conformance-suite) fails for a signed-in route that doesn't run the middleware.
- An account can have 100 sessions (`sessions.max`). A sign-in beyond that ends the session unused longest, and is never refused. See [How Many Sessions](https://keyringauth.com/docs/0.x/devices-and-sessions#how-many-sessions).
- A session ends after two hours unused (`sessions.idle`) or 30 days after sign-in (`sessions.absolute`). Both count on the registry record, not on your driver or `session.lifetime`.
- Each assurance level lapses on NIST's clock: AAL2 after one hour idle or 24 hours, AAL3 after 15 minutes idle or 12 hours. A lapsed session stays signed in at the lower level until the user verifies again. That reads NIST Sec. 5.1 and departs from Sec. 5.2. With `sessions.end_on_lapse`, the session ends instead, and "remember me" brings nothing back.
- A browser that ticked "remember me" may stay away for 14 days (`sessions.remember_idle`), within the 30 days. After two hours unused it holds no level, so routes behind `keyring:aal2` or `keyring.fresh` ask again. See [Inactivity and "Remember Me"](https://keyringauth.com/docs/0.x/devices-and-sessions#inactivity-and-remember-me).
- "Remember me" can't outlast the session it was ticked for. Laravel's cookie signs nobody in alone, and Keyring's cookie names that session's registry record. Once that record has timed out, been revoked or been ended by a risk response, both cookies are refused, even if the client kept them.
- A "remember me" cookie works once. Coming back moves the session to a new record and issues a new cookie, so a copy brings back nothing the original browser hadn't had. If a used cookie is sent again, or a browser is still on the record it named, two browsers held the pair, and the session ends for both (`RememberMeReused`, logged as `remember_me_reused`). The same browser's other requests in the next `sessions.remember_grace` (10 seconds) join the session the first one resumed instead. They can't start another session, and sending the cookie again doesn't make those seconds any longer.
- A resumed session's device, IP and browser are those of the request that resumed it, and the old record is never compared with them.
- Users can see every session at `/user/sessions`, whatever features are on, and can end one or all the others. Ending needs a fresh verification, and users only find their own sessions.
- A session's registry ID is never sent to a page. The sessions list names each session by a keyed hash, which can't be turned back into the ID or used as a cookie.
- If a session's registry record is missing, the session is signed out rather than started over.
- An administrator can end one user's sessions, or everyone's, with `php artisan keyring:sign-out`. "Remember me" brings none back. See [For Administrators](https://keyringauth.com/docs/0.x/devices-and-sessions#for-administrators).
- [Impersonation](https://keyringauth.com/docs/0.x/impersonation) is off until your app says who may use it. Starting is a `POST` behind two factors proved in the last 15 minutes. The impersonated session is a new registered session that proved nothing, can't step up, and ends after an hour. Keyring refuses its own security changes while it runs, and asks who may impersonate whom on every request, so taking the right away ends one in progress. Going back needs the impersonator's own session still good, never just their ID, and the browser still holding the impersonation it started. Their session moves to a new record as they come back, so a copy from during the impersonation leads nowhere. Both accounts' security logs record the start and end.
- The impersonator's session is kept from lapsing while busy, but a gap past a level's idle limit still lapses it. They come back at AAL1 at most, with nothing counting as fresh. Under `sessions.end_on_lapse`, an impersonator whose session signed in above AAL1 is signed out instead. So admin routes belong behind `keyring:aal2` rather than `auth` alone, since `keyring:aal2`, `keyring.fresh` and other step-ups ask again.
- An account your app stops letting sign in is refused wherever a session starts or carries on, as set by [`allowSignInWhen()`](https://keyringauth.com/docs/0.x/sign-in-flow#who-may-sign-in). The first refused request ends every session the account has, with its "remember me" cookies and trusted devices. Sessions stay on record until they make a request, so call `app(Sessions::class)->signOutEverywhere($user)` as you set the flag. `Sessions` is `Keyring\Sessions\Sessions`, resolved from the container.
- A "remember me" cookie can't carry a session past a sign out that's happening at the same moment, and a request that saves a stale copy of its session can't undo a revocation.
- A request sent with a session ID that a sign-in, step-up or sign-out has since replaced almost never saves that session or sends its cookies, on any route that starts the session through Keyring's `StartSession`, including an identity provider's callback. Keyring remembers the replaced ID before destroying the session, and checks it as the session starts and again just before saving, and a "remember me" cookie can't sign such a request in under an ID of its own. A request sent with the old ID later, while Keyring remembers it (five minutes), gets a fresh, empty session.

  The gap is between that last check and the save. Only the session lock closes it, so a locking route waits for a sign-in that takes the lock. Another check would only shorten the gap, so Keyring doesn't add one. While the rate limiter's store is down, sessions are saved as Laravel saves them. See [Requests That Overlap a Sign In](https://keyringauth.com/docs/0.x/devices-and-sessions#requests-that-overlap-a-sign-in).
- After a password change, an email change or a new sign-in method that signs out the other sessions, no copy of the cookie made before it stays signed in, whatever order the requests ran in. The change moves the session to a record only the browser making it knows.

  A copy that changed the session first, by signing out others or stepping up, moved it to its own record. So the owner's change is refused and the owner's browser is signed out, and signing in again and making the change signs the copy out. A copy that changes the session during the owner's change is ended by that change's sign-out, or the change finds its record moved and revokes it everywhere. Both browsers are signed out and the event is announced as a [contested session](https://keyringauth.com/docs/0.x/devices-and-sessions#a-contested-session). Keyring's own routes take the session lock for these changes. Your own `signOutEverywhere($user, except: ...)` keeps that record for whoever holds it, so call `signOutOthers()` instead, or `rotate()` after it.
- Laravel's session ID is never stored by Keyring or written to the security log.
- Devices are recognised by a random httpOnly cookie stored as a hash. A device is never a factor; it only feeds your policy and risk signals.
- Keyring's device and "remember me" cookies are httpOnly and `SameSite=Lax`. Once the app is served over HTTPS (`APP_URL` is `https`, or `session.secure` is on), they're `Secure` and prefixed `__Host-`, or `__Secure-` when cookies are shared with subdomains or kept to a path. See [Keyring's Cookies](https://keyringauth.com/docs/0.x/devices-and-sessions#keyrings-cookies).
- Signing out everywhere also stops trusting other devices and cancels pending email changes.
- A device is trusted only after a login that reached AAL2, never after the password alone or an emailed code. A device never takes a cookie value the browser sent, and the first sign-in from a browser, a login that reaches AAL2, and any grant of trust give the device a new value, and a repeat password-only sign-in on a known device keeps its token. So a cookie placed before sign-in can't make a browser recognised.
- Every device stops being trusted when the password changes, an authenticator is removed, an email change is applied, or a signed-in request places a risk lock. A lock from a login attempt doesn't do this (see [Signing In](https://keyringauth.com/docs/0.x/security#signing-in)).

### Account Changes

- With `Features::updatePasswords()` and `Features::emailChanges()` on, `password` and `email` change only through Keyring's flows. `Keyring::withoutProtection()` gets around that, and is logged and announced.
- An email change needs a fresh verification, confirmation from the new address, and confirmation from the current one. The last is skipped only when the session proved a second factor held for 7 days (`email_changes.established_after`) and since before the session signed in. A recovery code doesn't count.
- An email change never reveals whether the new address has an account, in its answer, timing or pending view. Its emails go after the response, and it applies only if the address is still the one it was requested from.
- Emailed links (verification, email change confirm and revert, "this wasn't me", an email code's sign-in link) act only on a POST button press, so mail scanners change nothing. No `GET` route of Keyring's changes state, apart from the three [single sign-on](https://keyringauth.com/docs/0.x/sso) needs: the sign-in redirect, the confirm redirect (`GET /confirm/sso/redirect`) and the callback. The two redirects only start a request in the browser's own session, and a link from another site can start either. The callback finishes only a request this browser's session started, which its state names.
- A confirm redirect opened from another site, while a confirm is in progress (which opening any page behind `keyring.fresh` starts), sends the user to their provider. With `freshness` set to `reauthenticate`, they sign in there again. With `round_trip`, they're let straight through and come back fresh, which is the [known limitation](https://keyringauth.com/docs/0.x/security#other-limits) of `round_trip`. A `never` provider isn't offered for a fresh verification, so its confirm redirect answers `404` there. Toward a level, a `never` confirm counts no more than signing in again would, and never as fresh.
- The page posts the link's token or signature in the body, to a URL without it, so the acting request doesn't leave the token in access logs a second time.
- A password reset with a bad token gets the same answer for every address. Password rules run only once the token checks out.
- Reverting an email change signs out every session, ends sign-ins waiting for a second factor, closes later changes, and removes sign-in methods that weren't established when the change was asked for. It removes recovery codes too when none of what's left is a factor they could recover. Cancelling a change doesn't stop its revert link working.
- While a change can be reverted, nobody else can take the address it replaced.
- A password reset gives the same answer for every address. It signs out every session, cancels pending email changes, unlinks every identity provider, and lifts risk locks and sign-in lockouts.
- A password change takes the current password and a fresh verification. Keyring checks both itself. A user with no password sets one with the fresh verification alone. The new hash is saved only over the one that was checked, under a row lock and only while the session is signed in, so an overlapping reset isn't overwritten.
- Password changes cancel pending email changes, so someone who knew the old password can't finish one.
- Any change to how someone signs in can end their other sessions. A reset and a reverted email change end every session. A password change and an applied email change end the others, unless you say otherwise with `sign_out_others` on the request or `email_changes.sign_out_others`. Adding or removing an authenticator, or making new recovery codes, ends the others when the request sends `sign_out_others`. `DELETE /user/sessions` is always registered.
- Passwords need at least 8 characters with a second factor and 15 without, and neither minimum can go below 8. Any characters are accepted, with no composition rules.
- New passwords are checked in every environment against the 10,000 most common of 8 characters or more and the 3,000 most common of 15 or more, your app's name, the words in `passwords.context`, and the user's name and email. Look-alike characters count as letters. The whole password is compared (Sec. 3.1.1.2), so a password made of those words is refused, but a passphrase containing one isn't.
- In production, new passwords are checked against Have I Been Pwned. If that service can't be reached, the password is let through unless you set `passwords.refuse_unchecked`. Outside production, the check doesn't run at all unless `passwords.uncompromised` is `true`.
- bcrypt silently ignores bytes past 72, so Keyring refuses longer passwords rather than truncate them. To accept every password up to `passwords.max`, use argon2id. A password with a NUL byte that bcrypt can't hash is refused with the other rules.
- Passwords never expire. A user is held until they choose a new one when there's evidence the password is compromised (Sec. 3.1.1.2). That evidence can come from your app, from your own risk response, or from Keyring's response to the `BreachedPassword` signal, which is off until you turn it on. The hold survives sign out and a cleared cache, ends with a password change or reset, and never applies to an account without a password.

### Links and Headers

- Every Keyring response is sent with `Cache-Control: no-store, private` and `X-Content-Type-Options: nosniff`, and sign out also sends `Clear-Site-Data`.
- Emailed links and the callback URL Keyring sends identity providers are built from `APP_URL`, never from the request that caused them, so neither `Host` nor an `X-Forwarded-Prefix` from your proxy reaches a link.
- Signed links are signed over the path and query only, and are checked with `keyring.signed:relative`, which is Laravel's `signed` middleware with refused links logged. A forged `Host` can't redirect them.
- Pages opened from emailed links carry the token in their URL, so they're sent with `Referrer-Policy: no-referrer`, and nothing they load learns that URL. A failed form still finds its way back.
- After signing in, confirming or verifying an address, Keyring goes on to an intended URL only on the app's own origins (the request's, `APP_URL`'s, or the `keyring.domain` host's) or a path. Other sites, `//host`, backslash and userinfo tricks included, go to `home` instead, in the redirect and in JSON alike. See [Where They Go Next](https://keyringauth.com/docs/0.x/sign-in-flow#where-they-go-next).
- The page a user was heading to when Keyring sent them to enroll or change a password is kept in the session for an hour, for the same user and origin. It's saved only for top-level navigations and Inertia visits, and signing in forgets it.
- Every other Keyring response sends `Referrer-Policy: same-origin`.
- Each Keyring response sends `Cross-Origin-Opener-Policy: same-origin-allow-popups` unless it already has that header, so a site that opens a Keyring page keeps no handle on it. A social login window the page opens itself still answers to the page.
- Each Keyring response sends `X-Frame-Options: DENY`, so no page can be framed. That covers one-press pages and the sign-in, challenge and confirm pages, which a page on another site could otherwise overlay with its own button. A response that already says who may frame it is left alone. See [A Content Security Policy](https://keyringauth.com/docs/0.x/security#a-content-security-policy).
- An Inertia app keeps the policy of the page it first loaded, so after an emailed link's form succeeds Keyring answers with a full page visit (a `409` with `X-Inertia-Location`). Otherwise every later page would send no `Referer`.

#### Emailed Links

An app on several domains can start its links somewhere other than `APP_URL`, such as the user's tenant:

```php
Keyring::linkRootUsing(fn () => tenant()->url);
```

Compute the root from something the server knows. The request's `Host` header is whatever the sender says, and a link built from it would send a real reset token to the sender's site. Signatures cover the path and query only, so links work under any root. A frontend Laravel doesn't serve sets the root to its own URL, serves a page at each of Keyring's paths, and needs `Referrer-Policy: no-referrer` and `Cache-Control: no-store` on its own pages. See [Headless Frontends](https://keyringauth.com/docs/0.x/headless#emailed-links).

#### Tokens in Emailed Links

An emailed link must carry what makes it work, so its token or signature is in the URL of the page it opens. OWASP ASVS 5.0.0 (14.2.1) asks for nothing sensitive in a URL, so these links can't fully meet it. Keyring limits the damage: the page changes nothing and posts the token in the body of the acting request, and it's sent with `Referrer-Policy: no-referrer` and `Cache-Control: no-store`. Links expire as follows:

- a reset link stops once used, or after `auth.passwords.*.expire` (60 minutes in a new app),
- an email change's confirm links last 24 hours (`email_changes.confirmable_for`) and its undo link a week (`revertable_for`), each working once,
- a verification link lasts `auth.verification.expire` (60 minutes),
- a "this wasn't me" link lasts a week (`devices.report_link_for`),
- an email code's sign-in link works once, for as long as its code does (10 minutes at most), and no longer than its sign in.

The reset link also carries the account's email address, as Laravel's does. Laravel's broker finds a reset by address and stores the token as a hash that can't be looked up, so the form must post the address. Most reset pages show it read-only. To keep the address out of the URL, build the link yourself and have your page ask for it. Keyring leaves a callback of yours alone:

```php
use Illuminate\Auth\Notifications\ResetPassword;
use Keyring\Support\Url;

ResetPassword::createUrlUsing(fn (User $user, string $token) => Url::route('password.reset', ['token' => $token]));
```

`Url::route()` builds the link from `APP_URL`, and the `reset-password` page then receives an empty `email`.

### Request Input

A URL lands in access logs, proxies and browser history, which a body doesn't. Laravel's `$request->input()` reads the query string too, so `POST /login?password=...` would work and be logged. Keyring reads its fields from the body for that reason.

- Anything that proves something is read from the body alone, as form or JSON: passwords, codes, WebAuthn credentials, the reset token, and the tokens and signatures that emailed-link pages post.
- Sign in, challenges, step-up, enrollment and resets validate against the body, so a required field only in the query fails as missing. Your factors' `rules()` are checked the same way.
- Your `CreatesNewUsers`, `ResetsUserPasswords` and `UpdatesUserPasswords` actions receive the body.
- A `GET` has no body, so a sign-in started from a `GET` route with `Keyring::attempt()`, such as an identity provider's callback, reads the query string. The code and state there are what OAuth needs, and the code is useless without the PKCE verifier that stays in the session.
- Fields that prove nothing may come from either: `remember`, `trust`, which authenticator to show, `sign_out_others`, and the new address of an email change.

### Storage

- TOTP secrets are encrypted with `APP_KEY`. [Cryptography](https://keyringauth.com/docs/0.x/security#cryptography) lists every algorithm and key.
- Recovery codes and email codes are stored as keyed hashes (HMAC-SHA-256). A recovery code must have 112 random bits or more, so Keyring's 128-bit codes qualify and Fortify's 119-bit codes qualify too. Nothing else is stored or accepted. A sent code's hash stays in your cache for ten minutes at most.
- Each kind of keyed hash has a key derived from `APP_KEY` with HKDF, so a hash for one kind can't pass as another, and none uses the key Laravel encrypts with.
- Email change tokens and device tokens are stored as SHA-256 hashes. The addresses in a pending change are encrypted.
- A session's registry ID is stored as it is ([Algorithms](https://keyringauth.com/docs/0.x/security#algorithms) explains why it signs nobody in on its own).
- WebAuthn credential IDs over 512 characters are refused, not truncated.
- WebAuthn user handles are an HMAC of the user's model and ID, never the ID or email, so two models with the same ID don't share one.

### Logging

- Out of the box Keyring records sign-ins, failed factors, lockouts, session starts and ends, "remember me" sessions carried on, and every change to how an account signs in. Sessions your own code starts with `Auth::login()` aren't recorded. Entries go to the [security log](https://keyringauth.com/docs/0.x/security-log-and-emails) table, which is on by default, or to your app's log when it's off. There's no setting that records nothing.
- Invalid UTF-8 in an entry is cleaned up so the entry is still written. If details can't be kept at all, the entry is written without them and the reason is reported.
- Refused requests are recorded too: someone else's record, a sign-in method that wasn't added, a removal that would lock the account out, an emailed link with a wrong or expired token, a rate-limited form, and a verification the pipeline's final gate turned away (`verification_refused`). The requester's answer doesn't change.
- No entry holds a password, code, token, signature, session ID or request body. Form validation errors aren't logged.
- Every entry has a severity, a time, and, when `security_log.context_key` is set (`trace_id` by default), the request's ID. The table's time is in `app.timezone`, and your app's log writes the offset. See [Times](https://keyringauth.com/docs/0.x/security-log-and-emails#times).
- Refusals can't fill the log: a lock is logged once when it starts, and refusals are capped per account or IP, with one entry saying where the log stopped. See [Refusals That Repeat](https://keyringauth.com/docs/0.x/security-log-and-emails#refusals-that-repeat).
- A failed log write never fails a sign-in. The exception is `Keyring::withoutProtection()`, which doesn't run unless its entry was written.
- Old entries, devices, ended email changes, ended sessions and old sign-in changes are deleted daily by a task Keyring schedules itself, and a force-deleted user's records go with them.

## What Keyring Keeps

This section covers what Keyring stores about a person, how it's protected, how long it stays and who can read it. The list comes from the migrations, so columns you add hold whatever you put in them.

| Where | Personal Data | Protected By | Kept For |
|---|---|---|---|
| `keyring_authenticators` | The name the user gave it. TOTP secrets and recovery codes in `secret`. A passkey's credential ID, public key, AAGUID and transports, and an email code's address when a factor keeps one. | `secret` is encrypted with `APP_KEY`, and its recovery codes are keyed hashes. Credential IDs and public keys are public by design. `secret`, `public_key` and `credential_id` are hidden when serialised. | Until removed, an email change is undone, or the user is force deleted. |
| `keyring_devices` (with `Features::devices()`) | IP address, user agent, a name, and the [location](https://keyringauth.com/docs/0.x/devices-and-sessions#locations) your locator returned: country, region, city and coordinates. | The device token is a SHA-256 hash, hidden when serialised. | 30 days after sign out (`devices.keep_revoked_for`), a year unseen (`devices.keep_unseen_for`), or past `devices.limit`. |
| `keyring_sessions`, or your cache with the `cache` driver | User ID, IP, user agent, "remember me" flag, sign-in and last-active times. | Keyring's own random ID, never Laravel's session ID. | Until it expires or is revoked, then the next daily prune. A record "remember me" replaced stays until it would have expired, and cache records expire on their own. |
| `keyring_pending_changes` (with `Features::emailChanges()`) | The new and old email address. | Both encrypted with `APP_KEY`. A keyed hash of the old address finds the change. The tokens are SHA-256 hashes. | 30 days after the change ended (`email_changes.keep_ended_for`). |
| `keyring_events` (with `Features::securityLog()`) | IP, user agent, device ID, and in `meta` an authenticator or device name. | Plain. Never a password, code, token, signature, session ID or body. | 180 days (`security_log.keep_for`). |
| `keyring_failure_counts` | User, factor, authenticator and two failure counts. | Plain. | Until cleared by a success, reset or `Keyring::unlock()`, or the authenticator is removed. Never pruned, since it keeps an authenticator [refused](https://keyringauth.com/docs/0.x/security#at-the-cap). |
| `keyring_password_holds` | That a new password is due, the reason given, and the hash of the password the hold was placed over. Write nothing personal in the reason. | The password hash is hidden when serialised. | Until the password changes, then kept lifted for a year (`PasswordHold::KEEP_LIFTED_FOR`) and pruned. It's deleted at once if the hold is called off. |
| `keyring_sign_in_changes` | User, and when an established method or its recovery codes were last removed or replaced, or a first password set from a session. | Plain. | Until it no longer [freezes](https://keyringauth.com/docs/0.x/authenticators#frozen-sign-in-methods) anything, then pruned. Deleted with a force-deleted user. |
| Your app's log (without `Features::securityLog()`) | The same as `keyring_events`, one line per event. | Whatever protects that channel. | Whatever that channel keeps. |
| The session | A sign-in awaiting its second factor, an enrollment in progress (including the secret), what a response hands the next page, and what the session has verified. | Encrypted with `APP_KEY`, whichever driver holds it. | 10 minutes for a pending login (`pending_logins.keep_for`), 15 for an enrollment (`enrollments.keep_for`), otherwise the session's life. |
| The rate limiter's cache store | Attempt counts keyed by a SHA-1 of the factor with the account, typed name or IP; hashed sent codes; answered-challenge marks; ended-impersonation marks; enrollments under way. Risk locks in `risk.store`, keyed by a SHA-1 of the user. | Hashed keys, so no names or addresses to read back. A risk lock key can be recomputed from a known ID. | A minute for counts, up to 24 hours for locks, 30 days for typed-name failures (`limits.remember_names_for`). |
| Laravel's own tables | The reset token and address in `password_reset_tokens`, and `remember_token`. | Laravel hashes the reset token. | `auth.passwords.*.expire`. Keyring deletes a user's reset tokens when they're deleted or their address changes. |

To store less of an address, see [What's Stored](https://keyringauth.com/docs/0.x/security-log-and-emails#whats-stored). `Keyring::recordIpsUsing()` applies to devices, sessions and the log. Security emails pass the IP address and a description of the browser to the user they're about.

**Who can read it.** Keyring has no admin screens, and no route returns another person's records. A signed-in user can read their own devices ([`GET /user/devices`](https://keyringauth.com/docs/0.x/devices-and-sessions#listing-and-revoking-devices)), alerts about their account ([was this you?](https://keyringauth.com/docs/0.x/security-log-and-emails#was-this-you-alerts)), and their activity ([`Keyring::activity($user)`](https://keyringauth.com/docs/0.x/security-log-and-emails#showing-recent-activity)). Everything else is readable only by your code and by whoever can read your database, cache and logs. Restrict those, and treat the log as an audit log.

**Deleting someone.** Force deleting a user removes their authenticators, devices, pending changes, log entries, failure counts, password holds and reset tokens, and revokes their sessions. A soft deleted user is signed out everywhere and loses reset tokens, but keeps the rest until each record's own time is up.

## What Your App Must Provide

Keyring sets headers and cookies on its own responses. Everything else a browser needs belongs to your app and server, because it covers every response.

| Your App Provides | Keyring Does | Keyring Doesn't |
|---|---|---|
| HTTPS on every request, and HSTS | Builds links from `APP_URL` and keeps its cookies to HTTPS once `APP_URL` is `https` | Redirect HTTP, or send `Strict-Transport-Security` |
| Trusted proxies behind a load balancer | Reads the client address and scheme from the request Laravel gives it | Decide which proxies to trust |
| `SESSION_SECURE_COOKIE=true` | Makes its two cookies `Secure` with the `__Host-` prefix | Change Laravel's session, CSRF or "remember me" cookies |
| A `Content-Security-Policy` with `frame-ancestors` | Sends `X-Frame-Options: DENY` unless yours already say who may frame | Send a policy. Your layout decides what it must allow |
| `nosniff` on your own responses | Sends it, plus `no-store`, `DENY`, a referrer policy and an opener policy, on every Keyring response | Add headers to routes that aren't Keyring's |
| A bot check, if your forms need one | Limits how often anything can be tried, and makes every refusal take as long as the next | Tell people from scripts |
| A lock store every server shares | Takes Laravel's session lock where needed | Check that the store works. A store that doesn't fails silently |

### HTTPS and HSTS

Serve the whole app over HTTPS, redirect HTTP to it, and send `Strict-Transport-Security`, so a browser that has visited once never tries HTTP again. Your web server or load balancer does this for every response.

Set `APP_URL` to your `https://` address. Keyring treats that as the sign the app is on HTTPS. It's where emailed links start, the origin passkeys bind to, and what decides whether Keyring's cookies are `Secure` and prefixed. Unset, it defaults to `http://localhost`, which is trusted as one of the app's own origins (see [Where They Go Next](https://keyringauth.com/docs/0.x/sign-in-flow#where-they-go-next)).

Without HTTPS, passwords, codes and session cookies cross the network in the clear, and browsers refuse passkeys except on `localhost`.

> [!NOTE]
> Keyring still works over plain HTTP for local development, with unprefixed cookies that aren't forced `Secure`.

### Trusted Proxies

Behind a load balancer or CDN that ends TLS, list the proxies with `trustProxies()` in `bootstrap/app.php`. Until you do, every request looks like plain HTTP from the proxy, so:

- every user shares one address for the [per-IP limit](https://keyringauth.com/docs/0.x/security#rate-limiting), and one person's failures hold everyone up,
- the addresses in the security log and on the devices page are the proxy's,
- Laravel marks its cookies `Secure` only on requests it knows came over HTTPS, so without `SESSION_SECURE_COOKIE` they go out without it,
- the pages Keyring returns to after signing in are `http://` URLs, and a guest stopped on a form post goes to `home` unless the page is on `APP_URL`'s origin (see [Where They Go Next](https://keyringauth.com/docs/0.x/sign-in-flow#where-they-go-next)).

Keyring's cookies don't depend on this, since they go by `APP_URL`. Trust only proxies you run. A trusted proxy's `X-Forwarded-For` is believed, so a client that can reach the app directly could choose its address. `X-Forwarded-Prefix` and `Host` never reach an [emailed link](https://keyringauth.com/docs/0.x/security#links-and-headers).

### Secure Cookies

Set `SESSION_SECURE_COOKIE=true` in production. Laravel then marks its session, CSRF and "remember me" cookies `Secure` on every response. Keyring reads the same setting, with `APP_URL`, for its own two cookies, which need nothing else from you. They're named `__Host-known_device` and `__Host-remembered_session`, or `__Secure-` when `SESSION_DOMAIN` is set or `SESSION_PATH` isn't `/`. Names you set yourself (`devices.cookie`, `sessions.remember_cookie`) are used as written, so the prefix is yours to add. See [Keyring's Cookies](https://keyringauth.com/docs/0.x/devices-and-sessions#keyrings-cookies).

Laravel's session cookie is yours to name, so give it the prefix too:

```ini
SESSION_SECURE_COOKIE=true
SESSION_COOKIE=__Host-session
```

A `__Host-` cookie needs `SESSION_PATH=/` and no `SESSION_DOMAIN`, Laravel's defaults. If you set a `SESSION_DOMAIN`, use `__Secure-` instead. Laravel's "remember me" cookie (`remember_web_...`) can't be prefixed, and it signs nobody in without Keyring's cookie beside it. See ["Remember Me"](https://keyringauth.com/docs/0.x/devices-and-sessions#remember-me).

Keep `SESSION_SAME_SITE` at `lax` or `strict`, and `SESSION_HTTP_ONLY` on. With [Single Sign-On](https://keyringauth.com/docs/0.x/sso), use `lax`: under `strict` the browser drops the session cookie on the return from the provider, and every sign-in through it fails. Keyring's routes are in the `web` group, so Laravel's CSRF check covers them. Don't exempt Keyring's paths, and keep the check if you replace `keyring.middleware`.

### A Content Security Policy

Keyring renders through your layout, so the scripts, styles and fonts a policy must allow are yours to list. Keyring sends no `Content-Security-Policy`. Yours must include `frame-ancestors`:

```
Content-Security-Policy: frame-ancestors 'none'
```

Use `'self'` if your app frames its own pages. Without `frame-ancestors`, another site can frame a page invisibly and line a button over one of yours. The CSRF token doesn't help, because the press really comes from your page. `SameSite=Lax` cookies stop framed signed-in cases in current browsers, but a page that works signed out is still exposed.

Keyring's own pages are covered without it: every Keyring response has `X-Frame-Options: DENY`. That matters most for the login, challenge and confirm pages, and for the emailed-link pages, three of which act on one press and work signed out.

Your policy can replace that default. When a Keyring response already has `frame-ancestors` or an `X-Frame-Options` of its own, Keyring adds nothing. Keyring only sees the headers set inside it, the route and the middleware listed after it in `keyring.middleware`. A policy set further out, in your `web` group, global middleware or your web server, arrives after `DENY`, and browsers then go by `frame-ancestors`. Two different `X-Frame-Options` headers are read as `DENY`, so if your server sends `SAMEORIGIN` everywhere and you want Keyring's pages framed, send it from inside too, or use `frame-ancestors`.

Send the policy on every HTML response, with `X-Frame-Options: DENY` (or `SAMEORIGIN`) beside it for older browsers.

### Headers on Your Other Responses

`Keyring\Http\Middleware\AddSecurityHeaders` runs only on Keyring's routes. Send `X-Content-Type-Options: nosniff` on your whole app, and decide your own `Referrer-Policy` and `Cache-Control` for pages that show account details. A middleware on `web` and `api`, or your web server, covers this.

If you remove Keyring's middleware from `keyring.middleware`, its responses lose `no-store`, `nosniff`, `X-Frame-Options`, the opener policy and the referrer policy, unless your setup sends them. Pages that emailed links open still need `Referrer-Policy: no-referrer`.

### Bot Checks

Keyring slows guessing with [rate limits](https://keyringauth.com/docs/0.x/security#rate-limiting), but it doesn't tell people from scripts. It has no CAPTCHA, no challenge and no minimum form time. OWASP ASVS 5.0.0 asks for realistic human timing at Level 3 (2.4.2), and the Authentication Cheat Sheet suggests a CAPTCHA after failed attempts. The service, when to show it and what to do about people it gets wrong are yours to decide.

For sign-in, add the check as a [pipeline step](https://keyringauth.com/docs/0.x/sign-in-flow#writing-a-step) before the limits, so a request that fails it is never counted against anyone:

```php
namespace App\Keyring;

use Closure;
use Illuminate\Validation\ValidationException;
use Keyring\Pipeline\Context;

class CheckForBots
{
    public function __construct(
        protected BotCheck $bots,
    ) {}

    public function handle(Context $context, Closure $next): Context
    {
        // Where a sign-in starts. A challenge page only comes after a right password.
        if ($context->identifying && ! $this->bots->passes($context->request)) {
            throw ValidationException::withMessages(['captcha' => __('Please confirm you are not a robot.')]);
        }

        return $next($context);
    }
}
```

```php
// app/Providers/KeyringServiceProvider.php
use Keyring\Pipeline\Steps;
use Keyring\Pipeline\Steps\EnsureNotThrottled;

Keyring::pipeline(fn (Steps $steps) => $steps->before(EnsureNotThrottled::class, CheckForBots::class));
```

`BotCheck` stands in for your check, such as a CAPTCHA's server-side verification or a signed timestamp from your form. The step runs inside the timebox, so a refusal takes as long as any other.

Registration, password reset requests and other forms don't use the pipeline. Add your own middleware to [`keyring.middleware`](https://keyringauth.com/docs/0.x/configuration#routes) for their routes, such as `register.store` and `password.email`.

### A Shared Lock Store

Laravel's session lock (`->block()`) lives in `session.block_store`, or your default cache store when that's `null`. Keyring takes it on the routes listed in the [Rate Limiting](https://keyringauth.com/docs/0.x/security#rate-limiting) section, so two requests in one session can't spend the same state, and a stolen cookie can't run a change beside its owner.

A lock only keeps a request out if both requests look in the same place. So the store must be shared by every server and PHP process and give real locks: Redis, Memcached, the database or DynamoDB. These give no exclusion, and nothing says so:

- `array` is per process. Under PHP-FPM every request gets the lock at once. It's only right for tests.
- `null` hands out every lock it's asked for.
- `file` lives on each server's disk, so it works only on one server or on a filesystem every server mounts.

A lock is held for 10 seconds at most, and a request waits up to 10 seconds for one. A request that waits the full 10 fails with `Illuminate\Contracts\Cache\LockTimeoutException`, which your handler turns into a `500` unless you render it yourself. A request that runs past 10 seconds loses its lock, and a second request can start alongside it. If both move the session to a new record, Keyring can't tell the second from a stolen copy, so it ends the session for both, as a [contested session](https://keyringauth.com/docs/0.x/devices-and-sessions#a-contested-session).

A step-up, password change, sign out of others, applied email change or new sign-in method that another request beat to it is caught by the [registry record](https://keyringauth.com/docs/0.x/devices-and-sessions#a-contested-session), not the session ID. Whichever finishes second is refused or ends the session for both. That still holds while `cache.limiter`, where Keyring remembers replaced IDs, is down.

## Cryptography

Keyring adds no cipher or hash of its own. Everything below belongs to PHP, Laravel or a library.

### Keys

| Key | Where It Lives | Used For |
|---|---|---|
| `APP_KEY`, and `APP_PREVIOUS_KEYS` for rotation | Your environment | Laravel's encrypter and signed URLs. Keyring never uses it directly. |
| Five purpose keys (recovery codes, one-time codes, reserved addresses, WebAuthn user handles, session handles) | Derived on each use from `APP_KEY` (and each previous key) with HKDF-SHA-256, labelled by purpose | Keyring's keyed hashes. A hash for one purpose can't pass as another. |
| Each authenticator app's TOTP secret, 160 random bits | `keyring_authenticators.secret`, encrypted | Making and checking that app's codes. |
| Each passkey's or security key's public key | `keyring_authenticators.public_key` | Checking signatures. The private key never leaves the authenticator. |
| Attestation root certificates | `webauthn.attestation_roots`, or your `TrustsAuthenticators` | Deciding which makers' keys a `requireAttestation()` factor takes. |
| The password hash | Your `users` table | Laravel's hasher. |

If you rotate `APP_KEY` and keep the old key in `APP_PREVIOUS_KEYS`, encrypted values, signed links, recovery codes and reserved addresses keep working. [Known Limitations](https://keyringauth.com/docs/0.x/security#other-limits) lists the short-lived values rotation ends.

### Algorithms

| Algorithm | Where | What It Protects |
|---|---|---|
| Laravel's encrypter (`app.cipher`: AES-256-CBC with HMAC-SHA-256 by default, or AES-256-GCM) | Authenticator secrets, the addresses in a pending change, and pending logins, enrollments and flashed results in the session | Secrets and addresses at rest. |
| Laravel's cookie encryption, the same cipher | Keyring's device and "remember me" cookies, when your `web` group encrypts cookies | Tokens in the browser. |
| HMAC-SHA-256 under a purpose key | Recovery codes, emailed codes while they wait, the lookup hash of an address an email change holds, the WebAuthn user handle, and the session handle a page uses | Values only compared or looked up, never read back. |
| SHA-256, unkeyed | Device tokens and email change tokens | Long random tokens, each with well over 128 bits, which is why a plain hash is enough and a copied table isn't a usable token. |
| SHA-256, unkeyed | The mark a pending login keeps of the password hash and address, inside the encrypted session | Noticing a change. Not a secret. |
| None: stored as it is | A session's registry ID | Nothing is hashed, on purpose. The ID isn't a credential by itself: it only does anything from inside a Laravel session (server-side, or encrypted with `APP_KEY`) or the encrypted "remember me" cookie. Someone who can read the table can make none of those without the key. Laravel keeps its own session IDs the same way. |
| HMAC-SHA-1 by default, or SHA-256 or SHA-512 where [set up with one](https://keyringauth.com/docs/0.x/factors#authenticator-apps-totp) | TOTP codes (RFC 6238), six digits every 30 seconds | Legacy in OWASP ASVS Appendix C (11.4.1), but the default because every authenticator app makes it. |
| Laravel's hash manager (`hashing.driver`: bcrypt by default, or Argon2id) | Passwords, the hash an unknown account spends, and the reset tokens Laravel's broker stores | Keyring calls `Hash` and never picks the algorithm or cost. |
| ES256 (ECDSA P-256 with SHA-256), EdDSA (Ed25519), and RS256 (RSASSA-PKCS1-v1_5 with SHA-256, off by default, 2048 bits at least) | Passkey and security key signatures, limited to [`webauthn.algorithms`](https://keyringauth.com/docs/0.x/passkeys#signature-algorithms) | Proof of holding the key. |
| X.509 path validation (ECDSA, Ed25519, Ed448, or RSASSA-PKCS1-v1_5 over SHA-224 or stronger, RSA of 2048 bits at least, never SHA-1) | Attestation chains, only for a [`requireAttestation()`](https://keyringauth.com/docs/0.x/passkeys#requiring-attestation) factor | Which maker's key this is. RSA with PKCS #1 v1.5 padding is accepted, which ASVS doesn't approve, because several makers' roots use it. |
| HMAC-SHA-256 with `APP_KEY`, by Laravel's URL signing | The verification and "this wasn't me" links | That your app made the link, for that route, and it hasn't expired. |
| SHA-1, unkeyed | Laravel's verification link address, shortened cache keys, and the breached-password lookup's five-character prefix | Nothing rests on it. The link is signed, a cache key isn't secret, and the lookup is the API's own format. |

### Random Values

Every random value comes from PHP's `random_bytes()` or `random_int()`, and `Str::random()` is built on `random_bytes()`. The code that issues secrets never uses `rand()`, `mt_rand()` or `uniqid()`. The conformance suite uses `uniqid()` only for throwaway test addresses.

| Value | Made With | Size |
|---|---|---|
| Recovery codes | `random_bytes(16)` | 128 bits each |
| WebAuthn challenges | `random_bytes(32)` | 256 bits |
| TOTP secrets | `random_int()`, 32 base32 characters | 160 bits |
| Device tokens, session registry IDs (one is the "remember me" pairing), pending login, enrollment and sent-code references | `Str::random(40)` | About 238 bits |
| Email change tokens | `Str::random(48)` | About 285 bits |
| Laravel's "remember me" token, when Keyring replaces it | `Str::random(60)` | About 357 bits |
| WebAuthn user handles | HMAC-SHA-256 of the model and ID under a purpose key | 256 bits, not guessable without `APP_KEY` |
| Emailed codes | `random_int()` | Eight digits, about 27 bits. Short on purpose: they last 10 minutes and allow five guesses. |
| The password an unknown account's hash is spent on | `Str::random(32)` | Thrown away. |

### Changing an Algorithm

| To Change | How | What Happens to Stored Values |
|---|---|---|
| The password hash or its cost | `hashing.driver` | Each password is rehashed at its owner's next sign-in. |
| `APP_KEY` | New key, old key in `APP_PREVIOUS_KEYS` | Encrypted values are read with the old key and rewritten on the next save. Recovery codes and reserved addresses are found under either. A sent code waiting to be typed stops working. |
| The cipher (`app.cipher`) | Change the setting | Laravel reads only what the current cipher wrote, so authenticator secrets and pending changes must be re-saved in a migration of yours first. Pending logins and enrollments end. |
| The WebAuthn algorithms | `webauthn.algorithms`, `webauthn.minimum_rsa_bits` | Adding one changes nothing stored. Removing one refuses its keys, whose owners must add new ones. A key's algorithm can't change. |
| The TOTP digest | The factor's `algorithm` | Only new apps use it. Each user adds their app again to move. |
| The keyed hash or its key derivation | Fixed in code | A release would re-make them. Reserved address hashes can be recomputed. Recovery codes can't, so they'd be reissued. |
| The token hash (SHA-256) | Fixed in code | Tokens can't be rehashed, so device cookies and pending change links would be reissued. |

The last two rows are where Keyring falls short of OWASP ASVS 5.0.0's 11.2.2, which asks that any algorithm can be swapped. Stored hashes carry no tag saying which scheme made them, so old and new can't coexist. A tag is worth adding only on the day of such a change, and neither algorithm has a weakness to move away from.

### Peppering Passwords

NIST SP 800-63B-4 recommends (Sec. 3.1.1.2) a keyed hash or encryption of the password, with its key kept apart from the database. OWASP's Password Storage Cheat Sheet agrees. Keyring doesn't build one in, for three reasons. The password hash column is shared with everything else in your app that checks a password, so a pepper only Keyring knew would break those checks. A pepper protects only if its key sits where the database's attacker can't reach, which is your infrastructure's decision. And losing or rotating it locks everyone out at once, so it needs a plan.

Keyring checks and sets passwords through Laravel's `Hash`, so a pepper added there covers every flow. Register a driver that wraps the one you use:

```php
use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Support\Facades\Hash;

class PepperedHasher implements Hasher
{
    public function __construct(
        protected Hasher $hasher,
        #[\SensitiveParameter] protected string $pepper,
    ) {}

    public function make(#[\SensitiveParameter] $value, array $options = []): string
    {
        return $this->hasher->make($this->pepper($value), $options);
    }

    public function check(#[\SensitiveParameter] $value, $hashedValue, array $options = []): bool
    {
        return $this->hasher->check($this->pepper($value), $hashedValue, $options);
    }

    public function info($hashedValue): array
    {
        return $this->hasher->info($hashedValue);
    }

    public function needsRehash($hashedValue, array $options = []): bool
    {
        return $this->hasher->needsRehash($hashedValue, $options);
    }

    // Base64, because a raw HMAC can hold a NUL byte, where bcrypt stops reading.
    protected function pepper(#[\SensitiveParameter] string $value): string
    {
        return base64_encode(hash_hmac('sha256', $value, $this->pepper, true));
    }
}

// In a service provider's boot().
Hash::extend('peppered', fn () => new PepperedHasher(
    Hash::driver('argon2id'),
    config('services.password_pepper'),
));
```

Then set `hashing.driver` to `peppered`, after settling three things:

- **Existing passwords.** Hashes made without the pepper won't match. Either fall back to the bare hasher in `check()`, reporting `needsRehash()` so each moves at its owner's next sign-in, or add the pepper before there are users.
- **Rotation.** Keep the old pepper to check against, and rehash on sign-in.
- **Length.** The HMAC is 44 characters, so bcrypt's 72-byte limit stops truncating. Keyring's [password rules](https://keyringauth.com/docs/0.x/protected-changes#password-rules) follow `hashing.driver`, so they stop refusing long passwords only with a driver other than `bcrypt`. A password over 72 bytes is still refused at sign-in while its stored hash is bcrypt, because Keyring can't tell a peppered bcrypt hash from a plain one. So wrap Argon2id, or keep new passwords to 72 bytes.

## What a Request Costs

The table shows the expensive operations and what stops a stranger running them without limit. It all happens inside a request. Keyring starts no background work, apart from the mail noted.

| Operation | When | What Bounds It |
|---|---|---|
| One password hash | Every password attempt the limits let through, including for a name with no account, which hashes a random password so both take the same time | The [rate limits](https://keyringauth.com/docs/0.x/security#rate-limiting), checked first. An attempt the IP limit refuses hashes nothing, and that limit bounds how many hashes one address can ask for. An attempt refused by an account or typed-name limit still hashes, so it costs the same as a wrong password. New passwords on registration, change or reset are behind the `keyring` limiter, at 6 a minute. |
| A held worker for `timebox` (500ms) | Every refused verification, `429` included | A sleep, not CPU work, but it holds a PHP worker, and Keyring doesn't bound how many workers that is. Your web server's connection and request limits and the worker pool bound it. A shorter `timebox` frees workers sooner but makes timing less even. |
| The breached-password lookup (HTTPS to Have I Been Pwned) | Setting a password, in production by default (`passwords.uncompromised`), and each sign-in if you add the `BreachedPassword` signal | The `keyring` limiter for new passwords, and sign-in limits for the signal. Laravel's verifier gives up after 30 seconds and lets the password through. With `passwords.refuse_unchecked`, Keyring gives up after 10 seconds and refuses it. To hold a worker for less time, turn the check off or bind your own `UncompromisedVerifier` with a shorter timeout. |
| WebAuthn verification (one signature) | Adding a key, and each sign-in or step-up with one | Factor rate limits, checked before the response is read. Adding a key is behind the `keyring` limiter. Usernameless options are limited to 60 a minute per IP. RSA keys are bounded to 16,384 bits by the library. |
| Attestation (a chain of at most six, checked against your roots) | Adding a key to a `requireAttestation()` factor | The `keyring` limiter, the chain cap, and nothing fetched. |
| Mail | Reset, email change, verification, emailed code and security notice | Reset and change mail goes after the response. Verification links and codes send during the request unless you queue them. Codes are limited to three per factor every 10 minutes (`limits.codes`) in each of three buckets (sign-ins from unknown browsers, sign-ins from browsers that signed in before, and step-ups and enrollments), so nine per factor at most, but the routes that send one aren't behind the `keyring` limiter. Security notices are queued after commit, five of a kind an hour (`limits.notices`). |
| Risk signal lookups (indexed queries on the log, devices and sessions) | A sign-in whose first factor is right, and a browser-name check on each signed-in request | They run after a correct first factor, so rate limits bound them. Each signal is a line in your provider you can remove. |
| Identity provider calls (discovery, keys, token endpoint, GitHub's API; 5 second connect and 10 second timeout) | Sending a user to a provider, and the callback | The redirect is behind `keyring-login-options`, and starting a link needs a fresh verification. The callback calls nothing until it finds the request its own session started, which it uses up; a browser keeps five at most. Discovery and keys are cached for `sso.cache_for`, and a key Keyring hasn't seen is re-read at most once a minute per provider. No redirect is followed. A token endpoint or key set on another host is looked up once per host per request (`HostResolver`) to refuse private addresses, with no timeout of its own. |
| A registry write | Each step-up, password change, sign out of others, applied change and new method, which moves the session to a new record | Only a signed-in session can make one, each takes a proof or fresh verification, and the old record stays revoked until `keyring:prune` removes it. |
| A session lock | Sign-in, passkey options, challenges, enrollment, authenticator changes, single sign-on, renaming and removing an authenticator, changing the password, signing out other sessions or devices, confirming an email change, and the impersonation start and stop routes | Requests in one session wait for each other for up to 10 seconds, then fail with a `500`. One session can't hold up another. See [A Shared Lock Store](https://keyringauth.com/docs/0.x/security#a-shared-lock-store). |

## Standards

This section explains where Keyring's choices come from. A row that departs from a requirement gives the reason under [Known Limitations](https://keyringauth.com/docs/0.x/security#known-limitations). The [OWASP ASVS and NIST SP 800-63B](https://keyringauth.com/docs/0.x/owasp-asvs) page works the other way round, listing each requirement and Keyring's response.

| What Keyring Does | From |
|---|---|
| **Assurance levels and sessions** | |
| AAL2 takes two kinds of factor, one something the user has. AAL3 takes an attested non-exportable key with its own verification or a password. Validated hardware and cryptography are yours to supply. | NIST SP 800-63B-4, Sec. 2.2.1, 2.3.1, 2.3.2, Appendix B |
| Levels lapse after idle and overall limits (AAL2: 1 hour and 24 hours; AAL3: 15 minutes and 12 hours). The session carries on at the level left, or ends with `sessions.end_on_lapse`. | NIST SP 800-63B-4, Sec. 2.2.3, 2.3.3, 5.1, 5.2. Carrying on departs from Sec. 5.2 |
| Idle and absolute timeouts on every session, kept on the server. "Remember me" has a longer idle limit as a stated decision. | OWASP ASVS 5.0.0, 7.3.1, 7.3.2; OWASP Session Management Cheat Sheet. "Remember me" departs from Sec. 5.1 |
| A new session ID, and the old session ended, on every sign-in and step-up | OWASP ASVS 5.0.0, 7.2.4 |
| A signed-out, revoked or timed-out session can't be used again | OWASP ASVS 5.0.0, 7.4.1 |
| A deleted user's sessions end with them, and a refused account loses its sessions at its first request | OWASP ASVS 5.0.0, 7.4.2 |
| A stated session limit per account, and what happens at it | OWASP ASVS 5.0.0, 7.1.2 |
| An option to end other sessions after any sign-in method change | OWASP ASVS 5.0.0, 7.4.3 |
| A command for administrators to end one user's or everyone's sessions | OWASP ASVS 5.0.0, 7.4.5 |
| Users see their sessions and can end any or all after verifying again | OWASP ASVS 5.0.0, 7.5.2 |
| A "remember me" cookie that works once, with reuse ending the session | RFC 9700, Sec. 4.14.2 (refresh token rotation with reuse detection), applied to a cookie; OWASP Session Management Cheat Sheet for revoking every rotated ID of a session together |
| **Rate limits** | |
| 100 failures in a row per authenticator, kept in the database, then refused until set up again. A lower number for unknown browsers is one of NIST's allowed risk-based techniques. | NIST SP 800-63B-4, Sec. 3.2.2 |
| Locks that double, and a separate count for browsers the account has signed in from | OWASP Authentication Cheat Sheet (exponential lockout); OWASP "Slow Down Online Guessing Attacks with Device Cookies", adapted: known browsers share one bucket |
| Limits per account, typed username and IP on every factor, and a limiter on the other forms | OWASP ASVS 5.0.0, 2.4.1, 6.3.1; OWASP Credential Stuffing Prevention Cheat Sheet |
| **Passwords** | |
| Minimum lengths of 8 with a second factor and 15 without, never below 8 | OWASP ASVS 5.0.0, 6.2.1; NIST Sec. 3.1.1.2 |
| A change takes the current password as well as the new one | OWASP ASVS 5.0.0, 6.2.3 |
| The most common passwords refused: the top 10,000 of 8+ characters and the top 3,000 of 15+ | OWASP ASVS 5.0.0, 6.2.4 |
| No composition rules, any characters accepted | OWASP ASVS 5.0.0, 6.2.5; NIST Sec. 3.1.1.2 |
| Passwords of at least 64 characters, never silently cut: up to `passwords.max` with argon2id, 72 bytes with bcrypt | OWASP ASVS 5.0.0, 6.2.9; NIST Sec. 3.1.1.2. Met with `HASH_DRIVER=argon2id` |
| Passwords made of the app's name, `passwords.context`, or the user's name or address are refused, comparing the whole password | OWASP ASVS 5.0.0, 6.2.11 (the list, 6.1.2, is yours); NIST Sec. 3.1.1.2 |
| Breached passwords refused, in production by default | OWASP ASVS 5.0.0, 6.2.12; NIST Sec. 3.1.1.2 |
| Unicode passwords normalised to NFC before hashing | NIST Sec. 3.1.1.2. Departs from the letter of ASVS 6.2.8 (verified exactly as received) |
| No expiry; a user held until they choose a new password on evidence of compromise | NIST Sec. 3.1.1.2 |
| **Factors and codes** | |
| Passkeys and security keys as the phishing-resistant option | NIST Sec. 2.2.2, 3.2.5 |
| Email codes opt-in and counting toward no level | NIST Sec. 3.1.3.1; OWASP ASVS 5.0.0, 6.3.6 |
| Two factors of one kind don't count as two, and no weaker fallback for a phishing-resistant user | OWASP Multifactor Authentication Cheat Sheet |
| Everyone required to add a second factor with `keyring.enrolled`, which the installer sets up once a second factor is picked | OWASP ASVS 5.0.0, 6.3.3 |
| The strongest combination the account can give is proved before a sign-in method is added | NIST Sec. 4.1.2.1 |
| A recent verification before changing how someone signs in | OWASP Authentication Cheat Sheet; OWASP ASVS 5.0.0, 7.5.1 |
| Single-use codes: random, short-lived, limited guesses, stored hashed, a resend replacing the last, bound to their sign-in | OWASP Multifactor Authentication Cheat Sheet; OWASP ASVS 5.0.0, 6.6.2, 6.6.3 |
| TOTP, recovery and sent codes that work once, whatever the session driver | OWASP ASVS 5.0.0, 6.5.1 |
| Recovery codes with at least 112 random bits, so they can be keyed hashes | OWASP ASVS 5.0.0, 6.5.2 |
| Sent codes of at least six digits, living ten minutes at most | OWASP ASVS 5.0.0, 6.5.4, 6.5.5 |
| TOTP codes accepted one step either side, and no further | RFC 6238, Sec. 5.2 and 6. Departs from ASVS 6.5.5, which a window of zero meets |
| A passkey challenge of 32 random bytes, answered once and expiring on the server | OWASP Passkey Security Cheat Sheet; OWASP ASVS 5.0.0, 6.7.2 |
| Sign-in methods presented with when they were added and last used | OWASP Passkey Security Cheat Sheet |
| ES256 and EdDSA by default, RS256 only when asked for, keys of 2048 bits at least | OWASP ASVS 5.0.0, 11.2.3, 11.6.1; RFC 8812, Sec. 2 |
| **Notices and risk** | |
| Emails about changes to sign-in, recovery codes and, with `Features::emailChanges()`, email | NIST Sec. 4.1.2.1, 4.2.1.1, 4.2.3, 4.5, 4.6; OWASP Forgot Password, Multifactor Authentication and Passkey Security Cheat Sheets; ASVS 6.3.7 |
| Emails about suspicious attempts: failed second factor, sign-in after failures or a quiet period, a credential-stuffing address, locked account, and with `Features::devices()` a new device | ASVS 6.3.5; OWASP Multifactor Authentication and Credential Stuffing Prevention Cheat Sheets |
| A line naming a contact in each notice, once `support_contact` is set | NIST Sec. 4.6 |
| Risk signals on every sign-in and request: failure history, browser change, and with `Features::devices()` the device signals | ASVS 8.2.4; OWASP Authentication and Session Management Cheat Sheets |
| A second factor asked for when a correct password comes from an address where other accounts just failed (`CredentialStuffing`, off until you turn it on) | OWASP Credential Stuffing Prevention Cheat Sheet |
| **Account changes and registration** | |
| Registration answers the same for every address | ASVS 6.3.8 |
| Resets give the same answer for every address, build links from `APP_URL`, sign nobody in, sign out every session, and leave second factors as they are | OWASP Forgot Password Cheat Sheet; ASVS 6.4.3 |
| The conformance suite fails an app whose password broker has no `throttle` | OWASP Forgot Password Cheat Sheet |
| Email changes confirmed from both addresses, and a recently changed address not trusted | OWASP Authentication and Forgot Password Cheat Sheets |
| **Headers, cookies and links** | |
| Auth pages and responses never cached | OWASP Session Management Cheat Sheet |
| `nosniff` and a referrer policy on every Keyring response | ASVS 3.4.4, 3.4.5 |
| `X-Frame-Options: DENY` on every Keyring response unless the app's policy says who may frame | OWASP Clickjacking Defense Cheat Sheet; ASVS 3.4.6 asks for `frame-ancestors`, which is your policy |
| `Secure` cookies with the `__Host-` prefix | ASVS 3.3.1, 3.3.3; OWASP Session Management Cheat Sheet |
| Cookie names that say what the cookie is for (`known_device`, `remembered_session`, `known_browser`) | OWASP Session Management Cheat Sheet, on fingerprinting by session ID names |
| No referrer from pages whose URL holds a token | OWASP Forgot Password Cheat Sheet |
| Emailed links act only on a `POST`, with the token in its body | ASVS 3.5.3 and 14.2.1 (the link itself carries its token once); OWASP CSRF Prevention Cheat Sheet |
| Passwords, codes, credentials and tokens are read from the body, never a `POST`'s query string | ASVS 14.2.1, 15.3.7 |
| The browser package encodes what it puts in a URL path | ASVS 1.2.2 |
| Keyring's own breached-password lookup follows no redirects (the default lookup is Laravel's, which follows them) | ASVS 15.3.2 |
| A `Cross-Origin-Opener-Policy` on every Keyring response | ASVS 3.4.8 |
| **Logging and storage** | |
| Sign ins, failures, lockouts, "remember me" carries, session ends and refusals logged by default | ASVS 16.3.1 to 16.3.3 |
| A severity and a request ID on every entry, no secrets in any, and a cap on what refusals can write | OWASP Logging Cheat Sheet |
| A list of what's stored, how it's protected, and a schedule that deletes it | ASVS 14.1, 14.2.7 |

## Known Limitations

### Where Keyring Departs From a Standard

Each of these is a choice. The reason is given once, here, and the [requirement page](https://keyringauth.com/docs/0.x/owasp-asvs) says what each means for an app that must meet the requirement.

- **A default install requires no second factor.** Keyring starts with the password, so ASVS 6.3.3 (Level 2) isn't met until you choose one. If you do, the installer requires it of everyone unless you say otherwise. The published provider has each one commented out.
- **Not every suspicious sign-in is announced by default.** ASVS 6.3.5 lists sign-ins from an unusual client or place. Keyring knows a new device and a quiet period only with `Features::devices()`, and a place only with a locator you supply. A sign-in after several failures is announced from the start, and a failed second factor once there is one.
- **Passwords are normalised before hashing.** ASVS 6.2.8 wants passwords verified exactly as received. Keyring cuts nothing and changes no case, but it applies NFC first, as NIST Sec. 3.1.1.2 recommends. The same "é" can be one code point on one keyboard and two on another, and without this a password could fail on the other device.
- **Bcrypt stops passwords at 72 bytes.** Laravel's default hasher ignores everything past 72 bytes, so with bcrypt Keyring refuses longer passwords, which can be as few as 18 emoji whatever `passwords.max` says. ASVS 6.2.9 and NIST both ask for 64 characters of any kind. Set `HASH_DRIVER=argon2id` to meet that. Keyring doesn't pre-hash to fit, because Laravel's hasher couldn't check the result. See [Passwords](https://keyringauth.com/docs/0.x/configuration#passwords).
- **By default a TOTP code works longer than ASVS allows.** ASVS 6.5.5 caps a TOTP's life at 30 seconds. Keyring accepts one step either side, so a code works for about 90 seconds. The default follows RFC 6238, which allows one earlier step for delay (Sec. 5.2) and a drift limit either way (Sec. 6). With no window, codes typed near the end of their 30 seconds fail, and so do codes from a phone half a minute out. A code still works only once. To meet 6.5.5 exactly, use [a window of zero](https://keyringauth.com/docs/0.x/factors#authenticator-apps-totp).
- **TOTP codes use HMAC-SHA-1.** ASVS lists it as legacy (Appendix C, 11.4.1). It's the default because every authenticator app makes it, and several ignore a request for another digest silently. [Set SHA-256 or SHA-512](https://keyringauth.com/docs/0.x/factors#authenticator-apps-totp) where you know your users' apps.
- **Windows Hello keys that only sign RS256 aren't taken by default.** ASVS doesn't approve RS256, so `webauthn.algorithms` leaves it out, and a machine whose Windows Hello makes nothing else can't create a passkey. See [RS256 and Windows Hello](https://keyringauth.com/docs/0.x/passkeys#rs256-and-windows-hello). Turning it on, like requiring attestation whose makers sign the same way, takes Keyring outside ASVS 11.2.3 and 11.6.1.
- **RS256 ID tokens are accepted from identity providers.** Google and Microsoft sign with nothing else, so [single sign-on](https://keyringauth.com/docs/0.x/sso#security-notes) accepts RS256 as well as PS256, ES256 and EdDSA, though ASVS 11.6.1 doesn't approve RS256's padding. It applies only once you register `SingleSignOn`.
- **Attestation is off unless asked for, covers only hardware keys, and checks no revocation list.** By default any WebAuthn authenticator is accepted and no session reaches AAL3. `requireAttestation()` checks `packed` and `fido-u2f` against the roots you list, and platform formats aren't read. OWASP's Passkey Security Cheat Sheet expects a chain's status to be checked too, but Keyring fetches nothing while a key is added, so a revoked maker's certificate is still accepted until you remove its root. See [Attestation and AAGUIDs](https://keyringauth.com/docs/0.x/passkeys#attestation-and-aaguids).
- **A used recovery code isn't replaced automatically.** NIST Sec. 4.2.1.1 calls for a new code after each use. Keyring uses the code up and reports it through `shouldReplaceRecoveryCodes()`. A new code is only worth something once the owner has saved it, and a sign-in isn't the place to show it. Your app sends the user to [make a new set](https://keyringauth.com/docs/0.x/authenticators#recovery-codes).
- **"Remember me" signs a browser back in without a factor.** NIST Sec. 5.1 doesn't accept a cookie in place of authentication. A browser that ticked the box comes back for up to 14 days, which is the point of the box. The resumed session has no assurance level, so `keyring:aal*` and `keyring.fresh` ask again, but routes behind `auth` alone are reached on the cookie. To follow the section, leave the box off, or set `sessions.end_on_lapse`. See [Inactivity and "Remember Me"](https://keyringauth.com/docs/0.x/devices-and-sessions#inactivity-and-remember-me).
- **A session outlives its assurance level.** NIST Sec. 5.2 ends a session when its timeout passes. Keyring lowers the level instead, which Sec. 5.1 allows. Ending the session would sign out people who set up a second factor after an hour away, while everyone else stays signed in for 30 days. Set `sessions.end_on_lapse` to end it. See [Ending a Session With Its Level](https://keyringauth.com/docs/0.x/devices-and-sessions#ending-a-session-with-its-level).
- **An account has one email address.** NIST asks for two notice addresses (Sec. 4.6) and two recovery addresses (Sec. 4.2.1.2). Keyring uses the `email` attribute. To notify more addresses, return them from `routeNotificationForMail()`, as [A Support Contact](https://keyringauth.com/docs/0.x/security-log-and-emails#a-support-contact) shows. A second recovery address, verified before use, is yours to build.
- **A notice doesn't name a contact until you do.** NIST Sec. 4.6 expects contact information. Keyring leaves the line out while [`support_contact`](https://keyringauth.com/docs/0.x/security-log-and-emails#a-support-contact) is `null`.
- **No pepper.** NIST Sec. 3.1.1.2 and OWASP's Password Storage Cheat Sheet recommend one. See [Peppering Passwords](https://keyringauth.com/docs/0.x/security#peppering-passwords).
- **The breach check fails open by default.** Laravel's check lets a password through when Have I Been Pwned can't be reached, so an outage doesn't stop registrations. ASVS 16.5.2 asks that the app stays secure when an outside service fails, and 16.5.3 counts this as failing open. Set `passwords.refuse_unchecked` to refuse instead, at the cost that no new password can be set while the service is down.
- **The per-minute limits live in the cache.** Clearing the limiter's store restarts the per-minute counts and lifts their locks and risk locks, which ASVS 16.5.3 counts as failing open. A count on every attempt belongs somewhere fast, though. What ends guessing doesn't depend on that cache: the failures in a row and held locks are in your database. See [Rate Limiting](https://keyringauth.com/docs/0.x/security#rate-limiting).
- **An emailed link carries its token in its URL.** It has to, and ASVS 14.2.1 doesn't allow for it. See [Tokens in Emailed Links](https://keyringauth.com/docs/0.x/security#tokens-in-emailed-links).
- **Stored hashes don't say which scheme made them, and registry IDs aren't hashed.** See [Changing an Algorithm](https://keyringauth.com/docs/0.x/security#changing-an-algorithm) and [Algorithms](https://keyringauth.com/docs/0.x/security#algorithms).
- **Form validation failures aren't logged.** ASVS 16.3.3 lists them, but a missing field is an ordinary mistake, and logging each one would bury the entries that matter. Every refusal for a reason is logged.
- **The log table's times have no offset.** ASVS 16.2.2 wants UTC or an offset. `keyring_events.created_at` is in `app.timezone`, so leave that at UTC, its default. See [Times](https://keyringauth.com/docs/0.x/security-log-and-emails#times).
- **A disabled account's sessions end at their next request.** ASVS 7.4.2 asks for them to end when the account is disabled, but Keyring can't see that moment because the flag is yours. Call `app(Sessions::class)->signOutEverywhere($user)` as you set it. See [Who May Sign In](https://keyringauth.com/docs/0.x/sign-in-flow#who-may-sign-in).
- **No bot check.** See [Bot Checks](https://keyringauth.com/docs/0.x/security#bot-checks).

### Other Limits

- **A fresh session can add a sign-in method and make one change.** Signing in counts as a fresh verification for 15 minutes, so whoever holds a copy of the session cookie in that window can add a passkey or authenticator app to an account with an established second factor.
  - A password-only account, or one whose second factors are all new, needs [the password](https://keyringauth.com/docs/0.x/authenticators#the-password-for-a-first-second-factor) for it.
  - The added factor signs in like any other, but it doesn't trigger `noDowngrade()` for 7 days.
  - The owner can remove it while it's new, as long as they can still sign in and verify with what they had. Once it's established, it's removed like any other.
  - Nothing established can be removed or replaced while it's there, unless the request proves an established key the copy lacks.
  - If nothing on the account is new, the copy can make one change first: remove an established authenticator that isn't the last second factor, or replace established recovery codes. That freezes everything else for 7 days.
  - While nothing is frozen, the copy can also rename sign-in methods, so a settings page should show when each was added.
  - An owner with an established passkey or security key can put things right by proving it for each change. An owner without one waits.
  - A new authenticator becomes established after 7 days, so the [security emails](https://keyringauth.com/docs/0.x/security-log-and-emails) for a new sign-in method and new recovery codes matter. Set [`authenticators_url`](https://keyringauth.com/docs/0.x/configuration#account-changes-and-enrollment) so they link to where the owner can remove it.
  - Keyring can't tell a copied cookie from the real one. Binding a session to its device, as Device Bound Session Credentials do, is up to the browser or your app.

- **A proof for new recovery codes waits with their enrollment.** The proof, and the password for a first second factor, is kept with the enrollment. A copy of the session taken in between could confirm that one enrollment before the owner did, saving codes it can't see and gaining nothing else.
- **`skip_with_totp` lets a phished code make a change.** With it on, a code from an established app can make one change while the account is frozen, by whoever phishes it while holding the session. That's why it's off.
- **A new account has nothing established.** Every authenticator set up in the last 7 days is new, including the owner's, so any of them can be removed while the account is frozen. Adding a second factor to such an account takes the password, so a copy can't add one unless the account has no password.
- **An account without a password can't be asked for one.** Such an account adds a second factor on the fresh verification alone.
  - While its own passkey is new, a copy of a session that just signed in could add one too, and Keyring can't tell them apart. Once the owner's key is established, a new key can't freeze it out.
  - Under an `ifEnrolled()` policy, a factor added without the password being checked isn't asked for at sign-in until it's established, even after a password reset gives the account a password.
  - The copy can also set the account's first password, since there's none to type. That password isn't established for 7 days: it freezes the account, it isn't asked for at sign-in, and adding a factor doesn't take it, so a factor added with it is asked for no more than one added without it.
  - A reset, which unlinks every identity provider, makes the owner's new password established. After 7 days unnoticed, the copy's password and anything added with it count like the owner's, so the [security emails](https://keyringauth.com/docs/0.x/security-log-and-emails) for a new sign-in method and a changed password matter here too.

- **The owner's new key isn't asked for at first.** For 7 days after a passkey or security key is added, `noDowngrade()`, `ifEnrolled()` and a fresh verification don't ask for it, so the owner's password and app keep working. This is the same rule that stops a key added from a copied session shutting the owner out.
- **The undo link for an email change trusts the old mailbox.** It has to, since it's for an owner with nothing else left. So whoever reads the old mailbox can undo a change the owner made, which also removes sign-in methods that weren't established when the change was asked for. An attacker can then reset the password by email. A second factor older than that survives. See [Reverting](https://keyringauth.com/docs/0.x/protected-changes#reverting).
- **The `cache` session registry is only as good as its store.** A record and a key beside it both say a session is revoked. The list of a user's sessions is one key, though, and a store that drops it hides those sessions from the list and from sign out everywhere until they expire. Evicting stores and promoted replicas without their latest writes do this. Use a store that doesn't evict, or the `database` driver, which is the default.
- **Lockouts still reach new browsers.** Someone who knows a user's email can keep the account locked by guessing faster than the per-minute limit. After 80 wrong passwords in a row, about 20 minutes at the quickest, the password is refused from every unknown browser until the owner resets it ([At the Cap](https://keyringauth.com/docs/0.x/security#at-the-cap)). If the attacker guesses under one name and the owner types another, the owner is told the password is wrong, not to wait, so the two names aren't linked. With `Features::devices()` on, the owner's browsers keep their own limit and keep working. Without devices, the lock reaches every browser while the guessing goes on, and so does the cap. A reset clears the password's counts, not a second factor's.
- **Which browsers are known is kept in the cache.** If the store loses its keys, a browser from before a reset counts as known again. It still can't pass the cap, which known browsers and everyone else share, and its sign-ins share one count of codes with the owner's other browsers.
- **A run of failures can start with a few at once.** Once a kind of browser has failures on record, each attempt is counted before its proof is checked. The first attempts aren't counted in advance, so an ordinary sign-in writes nothing. Up to `limits.per_account` (5) can be checked together. With the defaults that can't pass the cap, but it could if `limits.consecutive_elsewhere`, or what's left of `limits.consecutive` above it, were set below 5.
- **No clone detection for synced passkeys.** Their counters stay at zero, so there's nothing to compare.
- **Protection covers only Eloquent saves.** Query builder updates and `saveQuietly()` skip the protected attribute check.
- **Changing `APP_KEY` invalidates short-lived data.** Pending email codes stop working. A user's first passkey after the change gets a new user handle, though later passkeys reuse the handle their keys already have. Recovery codes, reserved addresses and TOTP secrets keep working when the old key is in `APP_PREVIOUS_KEYS`.
- **Signing out ends "remember me" in every browser.** Laravel keeps one remember token per user, so sign out, revoking any device or signing out others ends every remembered browser. A session that times out, one the user ends from their [sessions list](https://keyringauth.com/docs/0.x/devices-and-sessions#listing-and-ending-sessions), or one Keyring ends for another reason, ends only itself.
- **A copied "remember me" pair is caught only when both holders use it.** Whoever comes back first gets the session, and the other holder ends it when they turn up. A copy from a browser that never returns goes unnoticed until the `absolute` limit. Inside `sessions.remember_grace`, a copy from what looks like the same browser joins the session, and is caught the next time either of them comes back. A browser that never received its new cookie looks like a copy and must sign in again.
- **"Remember me" expects one session store per browser.** Two apps sharing the cookies and registry but with separate Laravel sessions would each see the other's return as a used cookie.
- **Laravel's `cookie` driver can't destroy an old session.** Keyring ends copies through the registry: a sign-in, step-up, password change, sign out everywhere else, applied email change and new sign-in method each revoke the old record. If moving fails, the old record is still revoked where the registry can be reached. A copy keeps working until the next such event or until its session ends, and it's turned away only where the [session middleware](https://keyringauth.com/docs/0.x/devices-and-sessions#the-session-middleware) runs. A sign-in that isn't finished has no record to swap, so an earlier copy can hold its pending login as it was. A server-side driver has none of these problems.
- **The `cookie` driver lets a browser send back what its session held.** A pending login or enrollment in the session can come back from an earlier copy. Nothing that must happen once depends on the session: TOTP steps and recovery codes are used up in the database, and sent codes, their guesses, enrollment confirmations and challenge answers are in the cache. Two things remain. An earlier copy returns a pending sign-in to an earlier point, which only means proving a factor again. And if the cache loses an answered challenge (kept 5 to 15 minutes), whoever holds the copy and the signed answer could resend it. A counter-based key refuses that, but a synced passkey whose counter stays at zero would be accepted. The same goes for a used code and a confirmed enrollment. Keep the cache where [your deploys don't clear it](https://keyringauth.com/docs/0.x/security#rate-limiting). A server-side driver has neither problem.
- **A request overlapping a session ID change can lose its changes, and a few can undo one.** Laravel saves the session when a request ends and resends its cookie. Keyring's [`StartSession`](https://keyringauth.com/docs/0.x/devices-and-sessions#requests-that-overlap-a-sign-in) stops a request sent with the old ID from doing that. What it costs, and where it doesn't hold:
  - A request sent with the old ID within 10 seconds of the change saves nothing it added unless it signed in, so a form's errors and the login page's CSRF token are lost. One sent later gets a fresh, empty session, and the browser must sign in again.
  - A request the server only starts more than 10 seconds after the browser sent it counts as one sent later, and takes the browser out of its new session.
  - An ID your own code changes is remembered only as that request ends. So a request reading the session in between isn't covered, and nor is a request that ends more than five minutes after the ID changed.
  - Nor are a sign-out that leaves the ID as it was, an app whose own `StartSession` Keyring leaves alone, an app with `sessions.overlapping_requests` off, or a tenancy package that switches the cache prefix after the session starts.
  - Nor is a request that started more than 10 seconds into a sign-in that's still running after a minute, since a replacement's record is only open for that long.
  - A store that evicts keys early forgets replaced IDs. A request that looks up an ID just before the request replacing it, and saves just after that request destroys the old session, can write the old session back on the `file`, `redis` and other cache-backed drivers. The gap is very short and needs the attacker to hold the session already. The race exists on any store, and only the session lock closes it. Keyring adds no further check, since another look would only shorten the gap.
  - When Keyring replaced the ID first, a signed-in request sent with the old ID isn't saved even if it changes the ID itself, so your own sign-out sent with the ID from before a step-up leaves the browser on the step-up's session.
  - For the five minutes Keyring remembers the old ID, nothing the old session held comes back. After that, a copy of a `cookie` driver session is carried on as Laravel would, until the registry signs it out.

- **Location signals need trustworthy data.** `HeaderLocator` trusts request headers, so use it only behind a proxy that sets them and can't be bypassed.
- **A provider set to `round_trip` counts as fresh when the user comes back.** By default an identity provider sign-in doesn't count toward `keyring.fresh` on an old session. A provider with [`freshness`](https://keyringauth.com/docs/0.x/sso#freshness) set to `reauthenticate` (any OpenID Connect provider, and Microsoft) counts the sign-in from its `auth_time`, and one without `auth_time` never counts. A confirm asks for `max_age=0` (and `prompt=login` where taken), and needs an `auth_time` from after the user was sent there. Google and GitHub are `never`, so neither their sign-ins nor their confirms count, and a user whose only way in is such a link must [reset their password](https://keyringauth.com/docs/0.x/sso#users-whose-only-way-in-is-never-fresh) before making protected changes. A `round_trip` provider counts both sign-ins and confirms from when the user comes back, so someone at a browser still signed in there gets a fresh verification without typing anything. A link from another site can start that confirm too, so a session can turn fresh without the user doing anything. See [Step-Up](https://keyringauth.com/docs/0.x/sso#step-up).
- **No single logout.** Signing out of Keyring doesn't sign the user out of their provider, and the provider ending its session doesn't end Keyring's. Keyring reads nothing from the provider after sign-in.
- **Session guards only.** Pending logins and step-up live in the session, so stateless API clients and mobile apps can't use the sign-in flow directly.
- **Not production-tested yet.** Keyring is new, and until 1.0 a minor release may change the public API (see [What's Stable](https://github.com/keyringauth/keyring/blob/main/README.md#whats-stable)).
