# OWASP ASVS 5.0

> The library's self-assessment against OWASP ASVS 5.0: what it meets, where it deviates and why, and what the application owns.

From `docs/security/asvs-5.0.md` in tensile-tools/tensile-auth at commit `e66760d` (v0.4.1-7-ge66760d). The HTML page is https://auth.tensile.tools/docs/reference/asvs.

This document assesses tensile-auth (`tensile.tools/auth`) against OWASP ASVS 5.0.0. It covers every requirement in V6 Authentication and V7 Session Management at all levels, and the V11 Cryptography and V16 Security Logging and Error Handling requirements that apply to the library. It is the self-assessment named in the human-login design and in the release gate in `docs/RELEASING.md`.

- **Assessed code:** the code that v0.1.0 releases. That includes human login, the audit trail of failed attempts, the rate limiter, the tamper-evident audit log, agent self-signup and signup overrides, leaked-token revocation, the admin API, personal access tokens and the OAuth 2 and OpenID Connect provider, quota hooks, DPoP proof of possession, social login, and the fix that clears a stale session cookie instead of answering 401.
- **Standard:** OWASP ASVS release tag `v5.0.0_release` (commit `5cf9b032440be53ce345ab3c130fda46ba1ce7a2`, released 30 May 2025). The requirement text comes from `5.0/en/0x15-V6-Authentication.md`, `0x16-V7-Session-Management.md`, `0x20-V11-Cryptography.md`, `0x25-V16-Security-Logging-and-Error-Handling.md`, and `0x92-Appendix-C_Cryptography.md` at that tag.
- **Assessment dates:** first assessed on 13 November 2026 after human login; reassessed on 14 November 2026 for v0.1.0. See [History](/docs/reference/asvs). Email and password sign-in was assessed on 27 November 2026.

## Summary

The library meets or deliberately deviates from every requirement that it owns. Nothing is "Not met". The [open findings](/docs/reference/asvs#open-findings) list what the reassessment found that is short of a gap but worth closing before v1.0.

| Status | V6 | V7 | V11 | V16 | Total |
|---|---|---|---|---|---|
| Met | 28 | 10 | 13 | 10 | 61 |
| Met with deviation | 7 | 8 | 4 | 1 | 20 |
| Application's responsibility | 8 | 1 | 1 | 6 | 16 |
| Not applicable | 4 | 0 | 3 | 0 | 7 |
| Not met | 0 | 0 | 0 | 0 | 0 |
| **Requirements assessed** | 47 | 19 | 21 | 17 | 104 |

### Not met

None. The first version of this assessment found three gaps in V16, all about failed attempts that left no record (16.3.1, 16.3.2, and 16.3.3). [Audit of failed attempts](/docs/reference/asvs#audit-of-failed-attempts) describes how the library closes them. The v0.1.0 reassessment found no requirement that the library owns and fails.

### Deviations

| Requirement | Deviation | Rationale and mitigation |
|---|---|---|
| 6.4.1 | An agent's claim code works until its claim deadline: 7 days by default, at most 30 days. ASVS asks for activation codes that expire after a short period. | A claim code has about 256 bits of entropy, works once, and is stored only as a hash. Only a fresh, multi-factor human can redeem it, and a leaked code reported by a secret scanner deletes the unclaimed agent (`TestLeakedClaimCodesDeleteTheUnclaimedAgent`). `SignupPolicy.ClaimWindow` shortens the window. |
| 6.5.5 | TOTP accepts the current and the previous 30-second step, so a code works for up to 60 seconds instead of 30. It never accepts the next step. | Tolerates clock drift on phones. Each step works once (`AdvanceTOTP` compare-and-set). `Options.Strict` accepts only the current step. Tested by `totp: TestClockSkew`. |
| 7.1.1, 7.3.1, 7.3.2 | `DefaultPolicy` sets `HumanIdle` to 14 days and `HumanMax` to 90 days. NIST SP 800-63B-4 sets reauthentication at AAL2 to at most 24 hours overall, with at most 1 hour of inactivity recommended, and at AAL3 to at most 12 hours overall. | The library always enforces both an idle timeout and an absolute maximum. Sensitive actions don't rely on session age: step-up proofs must be at most 5 minutes old (`MaxProofAge`), factor changes need a session that authenticated within 10 minutes, and `authhttp.RequireFresh` gates other actions. Apps that need AAL2 reauthentication pass `WithPolicy` with `HumanIdle` of 1 hour and `HumanMax` of 24 hours. See [Session lifetimes and limits](/docs/reference/asvs#session-lifetimes-and-limits). |
| 7.2.4 | `Rotate` and `StepUp` leave the rotated-out token usable for `RotateGrace` (10 seconds by default, at most 1 minute). | Covers requests already in flight. During the grace window the old token keeps its old `AuthenticatedAt`, so it isn't elevated, and reuse after the window revokes the session tree. |
| 7.5.1 | Factor changes need a session that authenticated within 10 minutes (`FreshFor`), not a new authentication for each change. `passkey.Passkeys.BeginFirstRegistration` needs no session at all, only that the user has no passkey, recovery codes, or TOTP factor. | A short freshness window; agents and federated sessions are never fresh. `BeginFirstRegistration` refuses an account with any other factor, checked again atomically at finish (`passkey: TestFirstRegistrationNeedsNoOtherFactor`). |
| 7.6.1 | Signing out at an identity provider, or the provider disabling the account, doesn't end the sessions that a sign-in through it started. The OAuth provider supports neither front-channel nor back-channel logout. | The library's own idle and absolute lifetimes always apply, and a federated session can't reach a sensitive action without another factor. See [Federated sessions](/docs/reference/asvs#federated-sessions). |
| 7.6.2 | The OAuth provider issues a grant without a consent page for a client that the application marks `FirstParty`, when the user is signed in and fresh. | `FirstParty` is opt-in per client and still needs a fresh human session; `prompt=consent` forces the page. Every other client needs explicit approval with `Provider.Approve`. A client from a metadata document or registration never skips the page, and no client skips it with a loopback redirect (`oauth: TestDynamicClientsAlwaysSeeConsent`, `oauth: TestLoopbackNeverSkipsConsent`). |
| 11.2.3 | The OAuth provider accepts RSA signing keys of 2048 bits, which give about 112 bits of security, below the 128-bit floor. | RS256 is the one algorithm that every OpenID client must support. An application that needs 128 bits passes an ECDSA P-256 key (ES256) or an RSA key of at least 3072 bits. |
| 6.2.8 | Passwords are normalized to NFC before they are counted, hashed, and checked. ASVS asks for passwords to be verified exactly as received. | NIST SP 800-63B-4, section 3.1.1.2, recommends NFC, so the same password typed on two keyboards matches. It never changes an ASCII password; nothing else is trimmed, case-mapped, or cut (`password: TestPasswordIsCheckedAsReceived`). |
| 6.2.12 | The breached-password check is off until the application sets `password.Config.Breached`, for example with `password/pwned`. | The check makes a network call for each password set, so the application chooses it. The embedded list of 10,000 common passwords always applies. |
| 6.3.1 | No number of failed password attempts disables a password or an account, unlike NIST SP 800-63B-4, section 3.2.2, which disables an authenticator after 100 consecutive failures. | That rule lets anyone disable someone else's password. The limiter delays attempts for each client and each address instead, `password.New` refuses to start without one, and known devices keep their own budget (`password: TestFailuresNeverLockAnAccount`, `password: TestKnownDevicesKeepTheirOwnBudget`). |
| 6.3.8 | With `password.VerifyLater`, signing in after a sign-up shows whether the sign-up created the account, and an account whose password hash has old parameters differs in timing. | `VerifyFirst`, the default, creates no account before the mailbox is confirmed (`password: TestVerifyFirstCreatesNothingBeforeConfirmation`). Every other path does the same work, counted by tests. |
| 11.4.1 | TOTP uses HMAC-SHA-1, which ASVS Appendix C classes as legacy. | Required for compatibility with authenticator apps (RFC 6238 defaults). |
| 11.5.1 | Recovery codes carry 120 bits of entropy, and OAuth device user codes about 34.6 bits, under the 128-bit floor in 11.5.1. | 6.5.2 and 6.5.4 set the limits for lookup secrets: 120 bits is above the 112-bit threshold that allows a plain hash, and far above the 20-bit minimum. A user code is typed by a person, as RFC 8628 intends, works only for 15 minutes, is stored as a hash, and every lookup passes the limiter. |

Other deviations, recorded in the tables: 6.3.1 (the limiter is opt-in outside the `password` package), 6.3.3 (single-factor sessions are possible), 7.4.5 (no single call revokes "all users"), 11.2.2 (the token hash isn't versioned), and 16.3.4 (factor packages return errors without logging them).

### Open findings

The reassessment found these items. None fails a requirement, but each relies on the application or on documentation where the library could enforce the rule:

1. **V10 OAuth and OIDC isn't assessed.** The OAuth 2 and OpenID Connect provider (`oauth`) and the relying party (`federation`) fall under ASVS V10, which this document doesn't cover. The OpenID conformance suite runs the basic OP and config plans on every pull request (`oidc-conformance.md`), and invariants 64 to 71 and 90 to 96 test the security rules, but no V10 self-assessment exists. Recommendation: assess V10 before v1.0.
2. **Unlinking an identity doesn't end the sessions it started.** `Federation.Unlink` stops future sign-ins through the identity; sessions that it already started live until they expire or the application revokes them. Applications that unlink because of a compromised provider account should call `Service.RevokeUser` too.

## Scope and responsibilities

The library is headless. Every status in this document reflects that split:

- **The library owns** human and agent sessions and tokens, delegation, agent self-signup and claiming, passkeys (through `go-webauthn/webauthn` v0.18.2), recovery codes, TOTP, email and password sign-in (`password`, with Argon2id from `golang.org/x/crypto`), step-up, personal access tokens, OAuth grants and the OAuth 2 and OpenID Connect provider (through `zitadel/oidc` v3), sign-in through external identity providers (`federation`, through `zitadel/oidc`'s relying party and `golang.org/x/oauth2`), DPoP proofs of possession (`dpop`, through `go-jose/go-jose` v4), quota hooks, the rate-limit hook and the built-in limiter, leaked-token revocation, the admin API, and the audit log.
- **The application owns** users and accounts, sending email and notifications (the library calls its mailer), screens, consent pages, TLS, HTTP routing, the sign-up hook for federated identities, registration of its OAuth clients at providers and of its own OAuth clients, key material (TOTP sealing keys, the OAuth signing key, and audit checkpoint keys), which limiter backend to run, and where logs go. Agents own their DPoP private keys.

"Application's responsibility" means the library can't meet the requirement on its own; the evidence names what the library provides to help. Email and password sign-in is in the `password` package; its design, with the threats, limits, and the tables this assessment takes its rows from, is in `design/passwords.md`. The library has no SAML, so 6.8.3 doesn't apply.

Test names are Go test functions, prefixed with their package outside the root package; `storetest:` names are subtests of `storetest.Run`, `RunFactors`, `RunSignup`, `RunDevices`, or `RunIdentities`, which `memstore`, `sqlitestore`, and `pgstore` run.

### Authentication pathways

| Pathway | Entry points | Strength (`Principal.MultiFactor`) |
|---|---|---|
| Discoverable passkey with user verification | `Passkeys.BeginLogin`, `Passkeys.FinishLogin` | Multi-factor |
| Passkey step-up of an existing session | `Passkeys.BeginStepUp`, `Passkeys.FinishStepUp`, `Service.StepUp` | Multi-factor |
| First passkey of a new account | `Passkeys.BeginFirstRegistration`, `Passkeys.FinishRegistration` | Multi-factor |
| Recovery code | `Codes.Redeem` | Single-factor |
| TOTP after another proof | `TOTP.Verify` | Multi-factor with the other proof |
| External identity provider (OpenID Connect or GitHub) | `Federation.BeginSignIn`, `Federation.FinishSignIn`, then `StartSession` | Single-factor, never fresh |
| Application factor | `StartSession` with a `MethodExternal` proof, or with no proofs | As the application decides; no methods recorded without proofs |
| Existing session token | `Authenticate`, `authhttp.Middleware` (Bearer, `DPoP` with `WithDPoP`, `token`, opt-in Basic, cookie for human sessions only) | Inherits the session's methods |
| Key-bound agent token | `Authorization: DPoP` with a proof from the bound key | Inherits the session's methods; the proof is required |
| Unclaimed agent (self-signup) | `Service.RegisterAgent`, then its sandboxed `tsa_` token | No human; `Principal.Unclaimed` |
| Claimed agent | `Service.ClaimAgent` by a fresh, multi-factor human, then `Service.CollectClaim` once | Delegated from the claimer |
| Personal access token | `Service.CreatePAT` from a human session fresh within 10 minutes | Never fresh |
| OAuth access token | Code flow with PKCE, device flow, or refresh, through `oauth.Provider`; `Service.Grant` and `Service.RefreshGrant` | Never fresh; a refresh token never authenticates a request |
| OAuth access token for an MCP server | Code flow with PKCE and a `resource` (RFC 8707), from a configured client, a client ID metadata document, or a registered client, through `oauth.Provider`; checked by `mcpauth` | Never fresh; works only at its resource |
| Token exchange (RFC 8693) | `oauth.Provider` token endpoint onto `Service.Delegate` | Delegated from the subject token |
| Email and password | `password.Passwords.SignIn`, then `Service.BeginSignIn` | Single-factor; multi-factor with TOTP. Never fresh on an account with a passkey or confirmed TOTP |
| Password step-up | `password.Passwords.Verify`, then `Service.StepUp` or `Service.Elevate` | Single-factor; refused for an account with a passkey or confirmed TOTP |

## V6 Authentication

| ID | Requirement (paraphrase) | Level | Status | Evidence |
|---|---|---|---|---|
| 6.1.1 | Document how rate limiting and anti-automation defend against credential attacks without enabling malicious lockout. | 1 | Met | Throttling documents the limits for each client, target, and user, their defaults, and why nothing locks an account. `password: TestLimiterRunsBeforeAnyWork`, `password: TestFailuresNeverLockAnAccount`, `password: TestKnownDevicesKeepTheirOwnBudget` |
| 6.1.2 | Document context-specific words banned from passwords. | 2 | Application's responsibility | The application lists its words in `Config.ContextWords` and `Config.Context`, and documents them. The library adds the address and its local part. `password: TestContextWordsDontCount` |
| 6.1.3 | Document all authentication pathways with their controls and strength. | 2 | Met | The pathway table gains "Email and password" (`SignIn`, then `BeginSignIn`; single-factor, multi-factor with TOTP) and "Password step-up" (`Verify`; refused for a strong account). Email codes aren't a pathway: `TestCodesNeverSignIn` |
| 6.2.1 | Passwords at least 8 characters. | 1 | Met | `MinLength` is 15 by default and can't be lower than 8. `password: TestLengthBoundsCantBeWeakened` |
| 6.2.2 | Users can change their password. | 1 | Met | `Change`. `password: TestChangeNeedsAFreshSessionAndTheCurrentPassword` |
| 6.2.3 | Password change needs the current and new password. | 1 | Met | `Change` takes the current and the new password and verifies the current one. `password: TestChangeNeedsAFreshSessionAndTheCurrentPassword` |
| 6.2.4 | Check passwords against the top 3,000 passwords. | 1 | Met | 10,000 common passwords of 8 or more characters are embedded and checked at sign-up, change, reset, and add. `password: TestCommonPasswordsAreRefused`, `password: TestEmbeddedListMeetsThePolicy` |
| 6.2.5 | No composition rules for passwords. | 1 | Met | No composition rule exists. `password: TestAnyCompositionIsAccepted` |
| 6.2.6 | Password fields use `type=password`. | 1 | Application's responsibility | The application owns the pages. The guide says to use `type="password"`; the browser client renders no fields |
| 6.2.7 | Allow paste and password managers. | 1 | Application's responsibility | The application owns the pages. The library never sees how a password was entered, and the routes accept any client |
| 6.2.8 | Verify passwords exactly as entered. | 1 | Met with deviation | No truncation, trimming, or case mapping. `password: TestPasswordIsCheckedAsReceived`, `password: TestLongPasswordsAreRefusedNotCut`. Deviation: NFC normalization, which NIST SP 800-63B-4 recommends, so equivalent Unicode sequences match. It never changes an ASCII password |
| 6.2.9 | Allow passwords of at least 64 characters. | 2 | Met | `MaxLength` is 256 by default and can't be below 64. `password: TestLengthBoundsCantBeWeakened` |
| 6.2.10 | No forced periodic password rotation. | 2 | Met | No expiry and no forced rotation; the policy doesn't run at sign-in. Only `StartReset` with `Invalidate` ends a password, for a suspected compromise. `password: TestPasswordsNeverExpire` |
| 6.2.11 | Use the context-specific word list. | 2 | Met | Context words don't count toward the minimum length. `password: TestContextWordsDontCount` |
| 6.2.12 | Check passwords against breached sets. | 2 | Met with deviation | `password/pwned` checks the Have I Been Pwned range API at sign-up, change, reset, and add. `password: TestBreachedPasswordsAreRefused`, `pwned: TestOnlyTheHashPrefixLeaves`. Deviation: the check is off until the application sets `Config.Breached`, because it makes network calls |
| 6.3.1 | Implement the documented controls against credential stuffing and brute force. | 1 | Met with deviation | For passwords the limiter is required: `TestNewNeedsALimiter`, `password: TestLimiterRunsBeforeAnyWork`, `ratelimit: TestTargetLimitsApplyAcrossClients`. Deviation, as before: the other packages only warn without a limiter. No failure count disables a password, a recorded deviation from NIST's limit of 100 |
| 6.3.2 | No default accounts such as "admin". | 1 | Application's responsibility | Unchanged. A password sign-up goes through the application's hook: `TestSignUpNeedsTheHook` |
| 6.3.3 | Require MFA or a combination of factors; at L3, one hardware-based, phishing-resistant factor. | 2 | Met with deviation | A password alone is `AssuranceSingle`; with TOTP it is multi-factor; a password never stands in for a passkey or TOTP that the account has. `TestPasswordAloneIsSingleFactor`, `TestPasswordWithTOTPIsMultiFactor`, `TestPasswordNeverStandsInForAStrongerFactor`, `TestPasswordSignInNeedsTOTP`. Deviation, as before: single-factor sessions exist, so the application requires `AssuranceMulti`; for Level 3, the library can't prove a hardware authenticator |
| 6.3.4 | No undocumented pathways; controls enforced consistently. | 2 | Met | The password pathway goes through the same limiter, failure audit, and `BeginSignIn` as every other. `TestPasswordSignInNeedsTOTP`, `password: TestLimiterRunsBeforeAnyWork` |
| 6.3.5 | Notify users of suspicious authentication attempts. | 3 | Application's responsibility | The library records every failed password attempt with its user and passes it to the observer; the application decides what is suspicious and sends the notice. `password: TestFailedPasswordAttemptsAreAudited` |
| 6.3.6 | Email isn't used as an authentication factor. | 3 | Met | No email code returns a proof or starts a session, and `MethodExternal` still forbids email links. `password: TestCodesNeverSignIn`. A reset by email is recovery, not authentication: it starts no session and leaves every other factor required |
| 6.3.7 | Notify users after authentication details change. | 3 | Application's responsibility | The library calls the mailer after every password and address change and for an address change request, to the verified address, and the application sends the mail. `password: TestEveryChangeIsAuditedAndNotified`, `password: TestAddressChangeConfirmsTheNewAndTellsTheOld` |
| 6.3.8 | Valid users can't be deduced from errors, status codes, or timing. | 3 | Met with deviation | The same answer and the same work for sign-in, forgot-password, and sign-up. `password: TestSignInFailuresLookTheSame`, `password: TestSignInDoesTheSameWorkForEveryAddress`, `password: TestForgotAnswersTheSameForEveryAddress`, `password: TestSignUpAnswersTheSameForEveryAddress`. Deviations: with `VerifyLater`, signing in after a sign-up shows whether it created the account, and that path runs the hook; an account with old hash parameters differs in timing. `VerifyFirst` closes the first: `TestVerifyFirstCreatesNothingBeforeConfirmation` |
| 6.4.1 | Initial passwords or activation codes are random, short-lived, and not long-term. | 1 | Met with deviation | The library issues no initial passwords. Email codes are random and single-use; reset codes live at most 10 minutes and confirmation codes `ConfirmTTL`, 24 hours by default and at most 72, because confirming starts no session: `emailcode: TestCodesLiveWithinTheirCeiling`, `password: TestCodeLifetimesFollowTheirKind`. Deviation, unchanged: agent claim codes live up to 30 days |
| 6.4.2 | No password hints or secret questions. | 1 | Met | Unchanged: no hints or secret questions |
| 6.4.3 | Password reset doesn't bypass MFA. | 2 | Met | A reset starts no session and changes no other factor; sign-in still needs TOTP, and the password cap still holds. `password: TestResetNeverBypassesSecondFactors`, `password: TestResetNeedsAVerifiedAddress`. A reset email carries a typed code only when a browser the account already trusts asked for it, so an attacker can't ask for a reset from their own browser and talk the owner into reading out a code: `password: TestResetCodesAreTypedOnlyForTrustedDevices` |
| 6.4.4 | Replacing a lost MFA factor needs identity proofing at the enrollment level. | 2 | Application's responsibility | Unchanged. A person without their passkeys who signs in by password gets a session that can't change factors: `TestPasswordNeverStandsInForAStrongerFactor` |
| 6.4.5 | Send renewal instructions before an authenticator expires. | 3 | Not applicable | Unchanged: no factor expires, and passwords don't either |
| 6.4.6 | Administrators can start a reset but can't set the user's password. | 3 | Met | `StartReset` sends the code to the user and never returns it or accepts a password. `password: TestAdminResetNeverRevealsOrSetsAPassword` |
| 6.5.1 | Lookup secrets, OOB codes, and TOTPs work once. | 2 | Met | Unchanged for TOTP and recovery codes. Email codes work once, and a link and its typed code spend each other: `emailcode: TestCodesWorkOnce`, `emailcode: TestTypedCodesWorkOnce`, `emailcode: TestPeekedCodesSpendOnce` |
| 6.5.2 | Lookup secrets under 112 bits use a salted password hash; at 112 bits or more, a standard hash is allowed. | 2 | Met | Unchanged for other secrets. Link codes have about 256 bits and are stored as SHA-256: `emailcode: TestCodesAreStoredHashed`. Typed codes have 40 bits, so each is stored as Argon2id (7,168 KiB, 5 iterations) with its own 16-byte random salt: `emailcode: TestTypedCodesAreStoredWithASaltedHash`. See Why Argon2id, and not HMAC |
| 6.5.3 | Lookup secrets, OOB codes, and TOTP seeds come from a CSPRNG. | 2 | Met | Unchanged. Email codes and salts come from `crypto/rand` |
| 6.5.4 | Lookup secrets and OOB codes have at least 20 bits of entropy. | 2 | Met | Unchanged for other secrets. Link codes have about 256 bits, and typed codes 40 bits from `crypto/rand`, above the 20-bit minimum: `emailcode: TestTypedCodesParseLeniently` |
| 6.5.5 | OOB requests live at most 10 minutes; TOTPs at most 30 seconds. | 2 | Met with deviation | Reset codes, which prove possession to set a credential, live at most 10 minutes (`ResetTTL`, and `emailcode.MaxProofTTL` with `Spec.Proves`): `emailcode: TestCodesLiveWithinTheirCeiling`, `password: TestCodeLifetimesFollowTheirKind`. Codes that only confirm an address live `ConfirmTTL`, 24 hours by default and at most 72: confirming never starts a session or returns a proof, so they aren't out-of-band authentication codes (`password: TestConfirmingNeverStartsASession`, `password: TestCodesNeverSignIn`). Deviation, unchanged: a TOTP code works for up to 60 seconds |
| 6.5.6 | Any factor can be revoked after loss or theft. | 3 | Met | Unchanged, and `Remove` deletes a password, `Reset` replaces one, and `StartReset` invalidates one. `password: TestRemoveKeepsTheLastSignInMethod` |
| 6.5.7 | Biometrics only as a secondary factor with something you have or know. | 3 | Met | Unchanged |
| 6.5.8 | TOTP uses a trusted server time source, not client time. | 3 | Met | Unchanged |
| 6.6.1 | PSTN OTPs only with validated numbers and stronger alternatives; none at L3. | 2 | Not applicable | Unchanged: no phone factor |
| 6.6.2 | OOB requests are bound to the original authentication request. | 2 | Met | Email codes aren't an authentication factor, but the library holds them to this rule: each is bound to its purpose, user, address, and, for a reset, password version. `emailcode: TestCodesAreBoundToTheirKind`, `password: TestCodesAreBoundToUserAndAddress`, `password: TestAPasswordChangeVoidsResetCodes`. A typed code is also bound to the device that started its flow, and a typed reset code only to a browser that holds a known-device token for the account and its current password version: `password: TestTypedCodesFinishOnTheStartingDevice`, `password: TestResetCodesAreTypedOnlyForTrustedDevices`, `password: TestAddressChangeNeedsItsSessionAndTheCode` |
| 6.6.3 | Code-based OOB is rate-limited. | 2 | Met | Redeeming a code passes the limiter for the client, and a typed code also for the device that types it; a typed code dies after 5 wrong guesses, even under concurrency, and a link code has about 256 bits. `password: TestLimiterRunsBeforeAnyWork`, `password: TestTypedCodesDieAfterFiveWrongGuesses`, `emailcode: TestTypedCodesDieAfterFiveWrongTries`, `ratelimit: TestDefaultRulesCoverPasswordActions` |
| 6.6.4 | Push MFA is rate-limited against push bombing. | 3 | Not applicable | Unchanged: no push factor |
| 6.7.1 | Certificates that verify cryptographic assertions are protected from modification. | 3 | Application's responsibility | Unchanged |
| 6.7.2 | Challenge nonces are at least 64 bits and unique. | 3 | Met | Unchanged |
| 6.8.1 | Users can't be spoofed through another IdP. | 2 | Met | Unchanged. An identity still never attaches by email address, and a federated sign-up can't attach to an account with an address: `storetest: FirstIdentityIsFirst` |
| 6.8.2 | Signatures on authentication assertions are always validated. | 2 | Met | Unchanged |
| 6.8.3 | SAML assertions are used once. | 2 | Not applicable | Unchanged: no SAML |
| 6.8.4 | Verify IdP-reported strength and recency (`acr`, `amr`, `auth_time`). | 2 | Met | Unchanged |

## V7 Session management

| ID | Requirement (paraphrase) | Level | Status | Evidence |
|---|---|---|---|---|
| 7.1.1 | Document idle and absolute lifetimes, and justify deviations from NIST SP 800-63B reauthentication. | 2 | Met with deviation | [Session lifetimes and limits](/docs/reference/asvs#session-lifetimes-and-limits) and the `DefaultPolicy` documentation justify the human defaults of 14 days idle and 90 days absolute, which exceed the NIST AAL2 limits, and name the settings that meet them. The table also lists agent, unclaimed agent, personal access token, and OAuth lifetimes. |
| 7.1.2 | Document the concurrent-session limit and what happens when it's reached. | 2 | Met | [Session lifetimes and limits](/docs/reference/asvs#session-lifetimes-and-limits): the library sets no limit on human sessions; `Service.Sessions` lists a user's sessions so the application can enforce one. `auth.Caps` limits enabled agents per human and live sessions per agent, and a refused action returns `ErrQuotaExceeded` (`TestCapsCountAgentsAndSessions`, `storetest: AgentCapHolds`). |
| 7.1.3 | Document federated systems that manage sessions, and how they coordinate lifetimes and termination. | 2 | Met | [Federated sessions](/docs/reference/asvs#federated-sessions) documents both roles: the library as a relying party of external identity providers, and as an OAuth 2 and OpenID Connect provider. |
| 7.2.1 | Verify session tokens on a trusted backend. | 1 | Met | `Service.Authenticate` always reads the store: `TestStartSessionAndAuthenticate`, `TestRevokeCascadesImmediately`. Key binding is checked on the server against the stored thumbprint (`TestBoundTokensNeedAProofFromTheirKey`). Through `cachestore`, a node that can't hear changes stops serving cached lookups: `pgstore: TestWatchFailsClosed`. An OAuth token bound to a resource authenticates only there: `authhttp` and the provider's userinfo and token exchange refuse it, and `mcpauth` accepts only tokens for its own resource (`authhttp: TestResourceTokensStayAtTheirResource`, `mcpauth: TestWrongAudienceIsRejected`). |
| 7.2.2 | Use dynamically generated tokens, not static secrets. | 1 | Met | Opaque reference tokens from `token.Generate` for every session kind: human, agent, personal access token, OAuth access and refresh. |
| 7.2.3 | Reference tokens are unique, from a CSPRNG, with at least 128 bits. | 1 | Met | About 256 bits from `crypto/rand` (43 base62 characters, rejection-sampled) for every token kind: `token: TestGeneratedTokensMatchScannerPatternAndAreUnique`, `token: TestEveryAlphabetCharacterIsReachable`. |
| 7.2.4 | Issue a new token on authentication and reauthentication, and end the current one. | 1 | Met with deviation | `StartSession` always mints a new token; `StepUp` rotates and elevates only the new token (`TestStepUpRotatesAndElevatesOnlyTheNewToken`); claiming revokes every sandbox session and the agent collects a new token (`TestClaimRotatesTheAgentsToken`). Deviation: the old token keeps working, unelevated, for `RotateGrace` (`TestRotateGraceAndReuseDetection`). The application revokes any session that existed before sign-in, because the library has no anonymous sessions. |
| 7.3.1 | Enforce an inactivity timeout according to documented risk decisions. | 2 | Met with deviation | Idle timeout always enforced and can't be turned off (`Policy.validate`, `TestExpiryBoundaries`), for every session kind (`TestPATLifetimes`, `TestGrantLifetimes`). Deviation: the 14-day human default exceeds NIST AAL2; see 7.1.1. |
| 7.3.2 | Enforce an absolute maximum lifetime according to documented risk decisions. | 2 | Met with deviation | Absolute maximum always enforced; use never extends it (`TestExpiryBoundaries`, `TestPATLifetimes`, `TestGrantLifetimes`). Deviation: the 90-day human default exceeds NIST AAL2; see 7.1.1. |
| 7.4.1 | After logout or expiry, the session can't be used; invalidate it on the backend. | 1 | Met | `Service.Revoke` cascades at once (`TestRevokeCascadesImmediately`, `cachestore: TestLocalRevocationIsImmediate`, `pgstore: TestWatchMakesRemoteRevocationVisible`); expiry checked on every use (`TestExpiryBoundaries`). The application calls `Revoke` and `authhttp.ClearCookie` on logout, and `authhttp.Middleware` clears a session cookie that no longer authenticates and treats the request as anonymous (`authhttp: TestStaleCookiesAreClearedAndPassAnonymously`). The OAuth provider revokes tokens at its revocation endpoint (`oauth: TestUserinfoIntrospectionAndRevocation`). |
| 7.4.2 | Terminate all sessions when an account is disabled or deleted. | 1 | Met | `Service.RevokeUser` revokes every human and agent session of the user, and their personal access tokens and OAuth grants: `TestRevokeUserAndAgent`, `storetest: RevokeUserAndAgent`, `storetest: RevokeUserEndsAppTokens`. The application calls it when it disables an account; the admin API exposes it (`authadmin: TestRevokeUserAndAgent`). |
| 7.4.3 | Offer to terminate other sessions after any factor change. | 2 | Met | `Change` and `Remove` take `EndOtherSessions`, which calls `Service.RevokeOthers`; a reset ends every session. `password: TestChangeCanEndOtherSessions`, `password: TestResetEndsEverySession`. The row's earlier deviation, no call for "all sessions except this one", is closed by `RevokeOthers` (`TestRevokeOthersKeepsTheCallerAndRefusesRecovery`) |
| 7.4.4 | Logout is visible on every authenticated page. | 2 | Application's responsibility | The application owns screens. |
| 7.4.5 | Administrators can terminate sessions for one user or for all users. | 2 | Met with deviation | One user: `Service.RevokeUser`, and the admin API's user, agent, and session revocation routes (`authadmin: TestRevokeUserAndAgent`, `authadmin: TestRevokeSessionRevokesItsBranch`). Deviation: no call revokes every user's sessions; the application loops over its users. |
| 7.5.1 | Require full reauthentication before changing attributes used for authentication or recovery. | 2 | Met with deviation | Password, address, and factor changes need a session that authenticated within 10 minutes, and the password cap keeps a password from standing in for a stronger factor. `password: TestFactorChangesNeedAFreshHumanSession`, `TestPasswordNeverStandsInForAStrongerFactor`, `password: TestAddressChangeConfirmsTheNewAndTellsTheOld`. Deviation, as before: a 10-minute window instead of an authentication for each change. Address changes are no longer the application's |
| 7.5.2 | Users can view sessions and, after reauthenticating, terminate any or all of them. | 2 | Met | Unchanged. A password proof from `Verify` is the reauthentication for an account that isn't strong: `TestPasswordStepsUpAnAccountThatIsntStrong` |
| 7.5.3 | Require further authentication before highly sensitive operations. | 3 | Met | `Service.StepUp` with proofs at most 5 minutes old (`TestProofMustMatchUserAndBeFresh`, `passkey: TestStepUpWithAPasskey`, `totp: TestStepUpWithTOTP`) and `authhttp.RequireFresh` (`authhttp: TestRequireFresh`). Admin changes need a fresh human session (`authadmin: TestChangesNeedAFreshHumanSession`). |
| 7.6.1 | RP and IdP session lifetimes and termination behave as documented. | 2 | Met with deviation | The library's sessions behave as [Federated sessions](/docs/reference/asvs#federated-sessions) describes: a federated sign-in starts a session with the library's own lifetimes, and OAuth grants live by `Policy.OAuthIdle` and `Policy.OAuthMax`. Deviation: ending the provider session doesn't end the library's session, and the OAuth provider has no front-channel or back-channel logout; its discovery document says so. |
| 7.6.2 | Creating a session needs user consent or an explicit action. | 2 | Met with deviation | A federated sign-in finishes only in the browser that began it (`federation: TestStateIsSingleUseAndBound`), so another site can't sign a victim in to the attacker's account. The OAuth provider needs a fresh human approval for every grant (`TestGrantNeedsAFreshHumanSession`, `oauth: TestPromptAndMaxAge`), and the device flow needs an explicit approval (`oauth: TestDeviceFlow`). Deviation: a `FirstParty` client skips the consent page; see [Deviations](/docs/reference/asvs#deviations). The application owns the route that calls `BeginSignIn`; serve it behind `http.CrossOriginProtection` so that another site can't start a sign-in silently. MCP clients that identify themselves with a client ID metadata document or registration always see the consent page, which names the client's verified host, the redirect host, the resource, and the scopes, and warns for a loopback redirect; each approval is recorded as `oauth_consented` (`oauth: TestConsentRequestNamesEverything`, `oauth: TestApprovalsAreRecorded`). |

## V11 Cryptography

This section covers the cryptography in token generation and hashing (`internal/token`, `Service.newID`), recovery-code hashing, TOTP (`totp`), TOTP secret sealing (`internal/seal`), the audit hash chain and its checkpoints, DPoP proof verification (`dpop`), ID token signing in the OAuth provider (`oauth`), ID token verification in `federation`, and leak-alert signature verification (`leakscan`), and password hashing, email codes, and the breached-password lookup (`password`, `internal/emailcode`, `password/pwned`). Passkey signature verification belongs to go-webauthn and is out of scope.

These requirements aren't assessed: 11.1.3 (cryptographic discovery tooling), and 11.7.1 and 11.7.2 (memory encryption is a deployment concern). The first assessment also left out 11.6.1 and 11.6.2, because the library had no signing; with ID tokens, checkpoints, and DPoP, it does, so both are assessed.

| ID | Requirement (paraphrase) | Level | Status | Evidence |
|---|---|---|---|---|
| 11.1.1 | Document a key-management policy and lifecycle, such as NIST SP 800-57. | 2 | Application's responsibility | The application supplies and stores the TOTP sealing keys, the OAuth signing key (`oauth.Config.SigningKey` and `KeyID`), the audit checkpoint key, and the audit key for address labels (`auth.WithAuditKey`; the server generates and seals its own). Exports are encrypted to recipients' post-quantum age keys or a generated passphrase. The library documents rotation (`totp.Keyring`, `seal.Keyring` docs) and supports it: `seal: TestSealOpenRoundTripAndRotation`, `totp: TestKeyRotationReseals`. Agents generate and hold their DPoP keys. |
| 11.1.2 | Maintain an inventory of keys, algorithms, and certificates, and where each may be used. | 2 | Met | [Cryptographic inventory](/docs/reference/cryptography#inventory). |
| 11.1.4 | Keep a documented migration plan to new standards, such as post-quantum cryptography. | 3 | Met | [Post-quantum migration](/docs/reference/cryptography#post-quantum-migration). |
| 11.2.1 | Use industry-validated implementations. | 2 | Met | The Go standard library (`crypto/aes`, `crypto/cipher`, `crypto/ecdsa`, `crypto/ed25519`, `crypto/hmac`, `crypto/rand`, `crypto/rsa`, `crypto/sha1`, `crypto/sha256`, `crypto/subtle`) for everything the library computes itself; `go-jose/go-jose` v4 for JWS parsing and signing, through `zitadel/oidc` v3 and in `dpop`. `filippo.io/age` v1.4 encrypts exports. TOTP matches the RFC 6238 vectors (`totp: TestRFC6238Vectors`). |
| 11.2.2 | Design for crypto agility: algorithms and keys can be replaced and data re-encrypted. | 2 | Met with deviation | Sealed blobs carry a version and key ID, and TOTP secrets reseal under the new primary key on next use (`totp: TestKeyRotationReseals`). The OAuth key set names keys by ID, the DPoP algorithm list is one constant (`dpop.Algorithms`), and discovery advertises both. Deviation: the token digest (SHA-256) has no version field, so changing it means reissuing tokens; human tokens live at most 90 days, and personal access tokens and OAuth grants at most 366 days. |
| 11.2.3 | Primitives give at least 128 bits of security. | 2 | Met with deviation | AES-256, SHA-256, HMAC-SHA-256 labels truncated to 128 bits, about 256-bit tokens, 160-bit TOTP keys, P-256 and Ed25519 signatures, and hybrid ML-KEM-768 + X25519 for exports. Deviation: the OAuth provider accepts 2048-bit RSA signing keys, about 112 bits; see [Deviations](/docs/reference/asvs#deviations). Identity providers choose their own signing keys. |
| 11.2.4 | Cryptographic operations are constant-time. | 3 | Met | `subtle.ConstantTimeCompare` for token digests (`Service.check`), DPoP thumbprints and token hashes (`Service.checkKey`), TOTP codes (`TOTP.find`), passkey and federation ceremony bindings (`Passkeys.consume`, `federation.equal`), and OAuth client secret digests. Stores look up by digest, which reveals nothing about the secret. |
| 11.2.5 | Cryptographic modules fail securely, with no oracles. | 3 | Met | `seal.Keyring.Open` returns one `ErrOpen` for every failure (`seal: FuzzOpen`); a secret that doesn't open is a server error, not a rejected code (`TOTP.match`). Every DPoP failure gets the same 401, with the reason only in the audit log (`authhttp: TestStolenBoundTokensAreRejected`, `dpop: FuzzVerify`). |
| 11.3.1 | No ECB or weak padding. | 1 | Met | AES-GCM only (`seal.newAEAD`). |
| 11.3.2 | Only approved ciphers and modes, such as AES-GCM. | 1 | Met | AES-256-GCM via `cipher.NewGCMWithRandomNonce`. |
| 11.3.3 | Encrypted data is protected against modification by authenticated encryption. | 2 | Met | GCM with associated data that binds the header and the user: `seal: TestSealedDataIsBoundToItsRow`, `totp: TestTOTPSecretIsSealedAndBoundToItsRow`. Note: the associated data names the user only, not the factor ID that the design and research describe; with one TOTP factor per user this has no effect. |
| 11.3.4 | Nonces are never reused with one key, and generated appropriately. | 3 | Met | `NewGCMWithRandomNonce` draws a fresh 96-bit random nonce for each seal; sealing volume (one per enrollment or rotation) stays far below the random-nonce limit. |
| 11.3.5 | Combined encryption and MAC use encrypt-then-MAC. | 3 | Not applicable | Only AEAD is used. |
| 11.4.1 | Only approved hash functions for cryptographic uses; no disallowed ones. | 1 | Met with deviation | SHA-256 for token, recovery-code, challenge, `state`, DPoP `ath`, and replay-cache digests. Deviation: TOTP uses HMAC-SHA-1, which Appendix C classes as legacy, for authenticator-app compatibility. CRC32 in tokens is a typo check, documented as "not a security control" in `internal/token`. |
| 11.4.2 | Passwords are stored with an approved, computationally intensive key derivation function, with parameters set to current guidance. | 2 | Met | Argon2id with parameters at or above the OWASP Password Storage Cheat Sheet's minimum, stored with the hash and upgraded at sign-in. `password: TestHashIsArgon2idPHC`, `password: TestWeakParamsAreRefused`, `password: TestSignInRehashesOldParams` |
| 11.4.3 | Hashes used for integrity are collision resistant, with at least 256 bits where needed. | 2 | Met | SHA-256 (`token.Hash`, `ceremonyID`, `chainHash`). The identity labels in audit events (`federated:<provider>:<32 hex digits>`) are 128-bit HMAC-SHA256 pseudonyms under the audit key, which name an identity without revealing it, even to someone who can list candidate subjects, and aren't used for integrity. |
| 11.4.4 | Keys derived from passwords use an approved key derivation function with a salt and parameters set to current guidance. | 2 | Not applicable | The library derives no key from a password. Passkey PRF outputs never reach the server (`passkey: TestPRFOutputsNeverReachTheServer`) |
| 11.5.1 | Non-guessable values come from a CSPRNG with at least 128 bits. | 2 | Met with deviation | `crypto/rand` everywhere: tokens and claim codes about 256 bits, session and agent IDs 128 bits (`Service.newID`), user handles 512 bits, TOTP secrets 160 bits, federation `state` and nonce 256 bits, and PKCE verifiers from `oauth2.GenerateVerifier`. Deviation: recovery codes have 120 bits, as allowed for lookup secrets by 6.5.2 and 6.5.4, and OAuth device user codes about 34.6 bits, as RFC 8628 intends; see [Deviations](/docs/reference/asvs#deviations). |
| 11.5.2 | Random generation stays secure under heavy demand. | 3 | Met | `crypto/rand` uses the operating system CSPRNG and doesn't block after seeding. Read failures are reported, never ignored: `TestRandomnessFailureIsReported`, `token: TestGenerateRandomnessFailure`. |
| 11.6.1 | Only approved algorithms for key generation and for signature generation and verification; no insecure keys. | 2 | Met | The library generates no long-term keys. It signs with Ed25519 (audit checkpoints) and with RS256 (RSA of at least 2048 bits) or ES256 (P-256 only) for ID tokens; `oauth.New` rejects other key types and smaller keys. It verifies DPoP proofs with ES256 or EdDSA only, rejecting `none`, `HS256`, RSA, and keys of the wrong type before parsing (`dpop: TestEveryClaimMismatchIsRejected`, `dpop: TestMalformedProofsAreRejected`); leak alerts with ECDSA P-256 over SHA-256; and ID tokens with the algorithms the issuer's discovery document lists, through go-jose v4, which refuses `none` and keys of the wrong type. |
| 11.6.2 | Approved algorithms and secure parameters for key exchange. | 3 | Not applicable | The library performs no key exchange; TLS belongs to the application. |

## V16 Security logging and error handling

The library writes audit events to the store in the same transaction as each change, passes them to one `Observer`, and logs internal warnings through an optional `slog.Logger`.

| ID | Requirement (paraphrase) | Level | Status | Evidence |
|---|---|---|---|---|
| 16.1.1 | Keep an inventory of logging at each layer: events, formats, storage, access, and retention. | 2 | Application's responsibility | The application decides storage, access, and retention. The library documents the event kinds in Events and writes only to the store, the observer, and the logger |
| 16.2.1 | Each entry has when, where, who, and what. | 2 | Met | Every event has the kind, time, user, session, factor, action, reason, client, and actor. `password: TestEveryChangeIsAuditedAndNotified`, `storetest: EmailEventsAreRecorded` |
| 16.2.2 | Synchronized clocks; timestamps in UTC or with an offset. | 2 | Application's responsibility | Unchanged: clock synchronization is the deployment's. The two tables store times as the other tables do |
| 16.2.3 | Logs go only to documented destinations. | 2 | Met | The package writes to the store, the observer, the logger, and the mailer, and nowhere else. `pwned` sends 5 characters of a hash to one configured URL (`pwned: TestOnlyTheHashPrefixLeaves`) |
| 16.2.4 | Logs use a format the log processor can read. | 2 | Application's responsibility | Unchanged: events are structured values, and logs use `slog` attributes |
| 16.2.5 | Sensitive data is not logged, or is masked. | 2 | Met | No password, hash, code, or address reaches an event, a log line, or an error; events name an address by a label keyed with HMAC-SHA-256 under the audit key, so a copy of the log doesn't confirm a guessed address, and `password.New` refuses to start without the key. `TestEmailLabelIsKeyed`, `password: TestNewNeedsAnAuditKey`, `password: TestSecretsNeverReachEventsLogsOrErrors`, `password: TestSecretRedactsItself` |
| 16.3.1 | Log all authentication operations, successful and unsuccessful, with the factors used. | 2 | Met | A password sign-in records `session_started` with the method `password`; every failure records `factor_rejected` with the action, reason, client, and user when known. `password: TestFailedPasswordAttemptsAreAudited`, `TestSessionsRecordHowTheyStarted` |
| 16.3.2 | Log failed authorization attempts. | 2 | Met | Refusals of the needs, of the password cap, and of the address gate record `access_denied`. `TestUnverifiedAddressCantUseAgents`, `TestPasswordCantStepUpAStrongAccount` |
| 16.3.3 | Log the documented security events and attempts to bypass controls. | 2 | Met | The events in Events are recorded, and so are throttled attempts and reset requests. `password: TestEveryChangeIsAuditedAndNotified`, `password: TestLimiterRunsBeforeAnyWork` |
| 16.3.4 | Log unexpected errors and security-control failures. | 2 | Met with deviation | The package logs a failed rehash, a mailer error, a breached-password check outage, a stored hash that doesn't parse, and a hook that returned an existing account. `password: TestMailerOutageDoesntChangeTheAnswer`, `password: TestBadStoredHashesAreServerErrors`. Deviation, as before: other server errors return wrapped, for the caller to log |
| 16.4.1 | Encode log data to prevent log injection. | 2 | Met | Structured attributes only; an address is never logged; actions are constants. `password: TestSecretsNeverReachEventsLogsOrErrors` |
| 16.4.2 | Protect logs from unauthorized access and modification. | 2 | Application's responsibility | Unchanged: the audit hash chain covers the new events, because it covers every field of every event (`TestChainHashCoversEveryField`) |
| 16.4.3 | Send logs to a separate system. | 2 | Application's responsibility | Unchanged: the observer receives the new events |
| 16.5.1 | Return a generic message for unexpected or security-sensitive errors. | 2 | Met | Before identification, every failure is `factor_rejected` or nil; every error has a problem, and unknown errors hide their message. `password: TestSignInFailuresLookTheSame`, `TestDescribeCoversEveryError` |
| 16.5.2 | Keep operating securely when external resources fail. | 2 | Met | A limiter outage is a server error; a mailer outage changes no answer; a breached-password check outage follows `BreachOutage`. `TestLimiterOutageIsNotRejection`, `password: TestMailerOutageDoesntChangeTheAnswer`, `password: TestBreachOutageFollowsTheSetting` |
| 16.5.3 | Fail securely; no fail-open paths. | 2 | Met | A store error in the password cap or the address gate refuses; a stored hash that doesn't parse is an error, never a match. `TestPasswordCapFailsClosed`, `password: TestBadStoredHashesAreServerErrors` |
| 16.5.4 | A last-resort handler catches unhandled exceptions. | 3 | Application's responsibility | Unchanged: the application owns the process |

## Fixed during the assessments

During the first assessment:

- **Step-up ceremonies weren't bound to their session.** `BeginStepUp` stored the session ID as the binding, but `FinishLogin` finished step-ups without checking it, so a step-up response for one session could elevate another session of the same user. `Passkeys.FinishStepUp` checks the binding, and `FinishLogin` no longer finishes step-ups (`passkey: TestStepUpIsBoundToItsSession`).
- **A test name in the invariants table didn't exist.** `docs/ARCHITECTURE.md` invariant 7 cited `storetest: RevokeWhereCascades`; it cites `RevokeUserAndAgent` and `RevokeAgentCascades`.
- **`Runtime.Observe` documentation didn't match the code.** It describes how factor packages use it.
- **`MethodExternal` suggested email links.** Its documentation says not to use it for email links or SMS codes (6.3.6).
- **Session lifetimes and the cryptographic inventory weren't documented.** This document adds them (7.1.1, 7.1.2, 11.1.2, 11.1.4).
- **`authhttp.RequireFresh` used `time.Now`** instead of the service clock. It reads the service clock.
- **Failed attempts left no record** (16.3.1, 16.3.2, 16.3.3). See [Audit of failed attempts](/docs/reference/asvs#audit-of-failed-attempts).

During the v0.1.0 reassessment:

- **CI didn't run the Valkey replay cache tests.** The `test-redis` job ran only `ratelimit/redislimit`, so invariant 87's `replaytest.Run` on Valkey never ran in CI. The job runs `dpop/redisreplay` too.
- **The 6.3.6 row still said `MethodExternal` suggested email links,** after the first assessment fixed that documentation.
- **The cryptographic migration plan said the library uses no public-key cryptography of its own.** It signs ID tokens and checkpoints and verifies DPoP proofs, ID tokens, and leak alerts; the plan covers each.
- **Invariant references disagreed.** The federation design numbered its invariants 83 to 89, which the invariants table gives to DPoP; it uses 90 to 96, as the table does. The table pointed the agent signup design at invariants 59 to 63; it covers 49 to 55.

## Session lifetimes and limits

| Session | Idle timeout | Absolute lifetime | Notes |
|---|---|---|---|
| Human | 14 days | 90 days | Use never extends the absolute lifetime. |
| Agent | 15 minutes | 8 hours | Never outlives the session it was delegated from. |
| Unclaimed agent (self-signup) | 24 hours (`SignupPolicy.SessionIdle`) | The claim deadline: 7 days by default, at most 30 days (`SignupPolicy.ClaimWindow`) | Deleted with the agent at the deadline. |
| Personal access token | 90 days (`Policy.PATIdle`) | 30 days by default, at most 366 days (`Policy.PATDefault`, `Policy.PATMax`) | Never fresh. |
| OAuth grant (refresh token) | 90 days (`Policy.OAuthIdle`) | 366 days (`Policy.OAuthMax`) | A refresh token never authenticates a request. |
| OAuth access token | Its lifetime | 1 hour with a refresh token (`DefaultAccessTTL`); without one, up to `Policy.OAuthMax`, idling out after `Policy.OAuthIdle` | Never outlives its grant. |

Short-lived ceremonies: passkey ceremonies last 5 minutes by default, federated sign-ins and links 10 minutes (at most 30), OAuth authorization requests 10 minutes, authorization codes 1 minute, device codes 15 minutes, and DPoP proofs 60 seconds either side of their `iat`.

The human defaults are longer than the NIST SP 800-63B-4 reauthentication limits for AAL2: 24 hours, with 1 hour of inactivity. They suit a developer tool used on personal devices, where frequent passkey prompts train people to approve them without reading. Session age doesn't gate anything sensitive:

- Step-up proofs must be at most 5 minutes old (`MaxProofAge`).
- Adding or removing factors and identities, creating personal access tokens, and claiming agents need a session that authenticated within 10 minutes (`passkey.FreshFor`, `recovery.FreshFor`, `totp.FreshFor`, `federation.FreshFor`, `PATFreshFor`, `ClaimFreshFor`); approving an OAuth request needs one within 10 minutes (`oauth.ApproveFreshFor`), and `Service.Grant` accepts one within 30 minutes (`GrantFreshFor`), to cover a device's wait for its token.
- `authhttp.RequireFresh` gates the application's own sensitive actions.
- Agents, personal access tokens, OAuth tokens, and federated sessions are never fresh, so they can't do any of these.

To meet AAL2 reauthentication, pass `auth.WithPolicy` with `HumanIdle` set to 1 hour and `HumanMax` set to 24 hours.

The library sets no limit on concurrent human sessions for an account. `Service.Sessions` lists a user's sessions, so an application that needs a limit can revoke the oldest session when it starts a new one. `auth.Caps`, passed with `auth.WithQuota`, caps enabled agents per human and live sessions per agent: the agent cap holds under concurrency, and the session cap can be exceeded by at most the number of concurrent delegations minus one (`TestCapsAgentLimitHoldsUnderConcurrency`, `TestCapsSessionLimitIsSoftByTheConcurrentDelegations`). Reaching a cap refuses the action with `ErrQuotaExceeded` and records `access_denied`.

## Federated sessions

The library takes part in federation in two roles.

As a relying party of external identity providers (`federation`):

- A sign-in through a provider starts an ordinary human session with the method `federated`. Its idle and absolute lifetimes come from `Policy`, not from the provider's session or token lifetimes.
- The library discards the provider's access, refresh, and ID tokens after the sign-in and never asks the provider again. Signing out at the provider, or the provider disabling the account, doesn't end the session. To end it, the application calls `Service.Revoke` or `Service.RevokeUser`. `Federation.Unlink` stops later sign-ins with the identity, but doesn't end sessions it started.
- The library ignores `acr`, `amr`, and `auth_time`, and assumes the weakest authentication: a federated session is single-factor and never fresh, can't step a session up, and can't extend another factor's freshness. Reaching a sensitive action takes another factor of the library's, however recently the provider checked the person.
- Neither front-channel nor back-channel logout is supported.

As an OAuth 2 and OpenID Connect provider (`oauth`):

- Each grant is its own session tree, with the lifetimes in [Session lifetimes and limits](/docs/reference/asvs#session-lifetimes-and-limits). It doesn't end when the human session that approved it ends.
- A grant ends when its refresh token is revoked at the revocation endpoint or with `Service.Revoke`, when refresh-token reuse is detected, when it idles out or reaches `Policy.OAuthMax`, or when `Service.RevokeUser` revokes the user.
- `prompt=login` and `max_age` make the human sign in again before approving (`oauth: TestPromptAndMaxAge`).
- Discovery reports `frontchannel_logout_supported` and `backchannel_logout_supported` as `false`, and the provider has no end-session endpoint. Clients that need to end their own sessions when the user signs out of the application revoke their tokens.

## Audit of failed attempts

Every failed attempt is recorded in the audit log with `Store.RecordEvent`, not only passed to the observer:

| Event | Recorded when | Fields |
|---|---|---|
| `factor_rejected` | A passkey, recovery code, TOTP code, registration, federated sign-in, identity link, or signed leak alert doesn't verify | Action, reason, client, and user when known |
| `attempt_throttled` | The limiter delays an attempt | Action, client, and user when known |
| `token_rejected` | A token doesn't authenticate, including a bound token without a valid proof from its key | Action, reason, client, and the session and user when the token belongs to one |
| `access_denied` | A request or delegation lacks a permission, or a quota refuses an action | Action (route pattern, or method and path), reason, client, and principal |

Anyone can fail an attempt, so one row per attempt would let an attacker write to the database as fast as they can send requests. The library keeps every attempt in three ways:

- **Every attempt reaches the observer**, with all its fields, whether or not it's stored (`TestObserverSeesEveryAttempt`). Send the observer to your log pipeline for a record of every attempt.
- **Within `FailureLimits`, every attempt is its own row.** The defaults per minute are 10 rows for one kind, reason, client, and user, and 1,000 in all, with separate budgets for failures tied to a user and anonymous ones (`TestFailureEventsAreBoundedPerClient`, `TestFailureEventsAreBoundedInTotal`, `TestAnonymousFloodsDontHideAttributedFailures`). `WithFailureLimits` changes them, and `UnlimitedPerUser` removes the per-key limit for failures tied to a user (`TestFailureLimitsAreConfigurable`).
- **Beyond the limits, attempts are counted in summary rows** that keep the kind, reason, client, user, number, and first and last time (`Until`). The 1,000 keys of each budget that skipped the most get their own summary; other failures tied to a user get one summary per user; the rest are one `failures_skipped` total (`TestFailureKeysAreBounded`, `TestAttributedSummariesKeepTheUser`).

Attacker-chosen text in the action and client is cut to 128 bytes without control characters (`TestFailureFieldsAreCleaned`, `TestVaryingTheActionDoesntBypassTheCap`). Writes ignore request cancellation, every failed write is retried, one failure writes at most 50 queued rows, and `Service.Run` writes queued rows once a minute and flushes on shutdown (`TestSummariesSurviveCancellationOutagesAndShutdown`, `TestRunWritesSummariesWithoutAnotherFailure`).

What the store can't keep:

- one row per attempt in a flood beyond the limits, which becomes counts with a time range
- the client of anonymous attempts beyond the 1,000 keys a minute that skipped the most, or beyond the 10,000 tracked keys, which become a total
- up to one minute of over-limit counts after a crash, because queued rows live in memory
- who and where, after a store outage long enough to fill the queue: the rows merge into a `failures_skipped` total with the reason `merged`, the service logs an error, and the count survives (`TestLongOutagesKeepCountsAndSayTheyMerged`)

Retention is the application's: the audit table grows with failures, so delete old rows on the schedule your policy sets.
