Repository navigation
Description
Context
A browser session cookie lasts 30 days (SESSION_TTL_SECONDS, packages/ui-server/src/middleware/auth.ts:62; set in issueSessionCookie, auth.ts:319-345). Any request that carries a live owner cookie can do the following with no further check:
- register a new passkey (
POST /auth/passkey/register-optionsandregister-verify,packages/ui-server/src/middleware/passkeys.ts:480-576). The first passkey for an RP also turns password login off (passwordLoginDisabled, lines 289-295). - delete a passkey (
DELETE /auth/passkey/:id, lines 608-620). - mint a delegated principal and receive its cookie (
POST /auth/principals,packages/ui-server/src/middleware/principals.ts:94-166).
A borrowed unlocked phone, or one cookie stolen from a 30-day session, is therefore enough to plant a permanent passkey or a long-lived agent credential.
Guide security/passkey-reauthentication covers "re-verifying returning signed-in users for sensitive steps". Its rule: "Populate the allowCredentials options array with specific PublicKeyCredentialDescriptor records mapping all registered credential IDs for the signed-in user. Leaving this empty or omitting it regresses to discoverable credentials, violating session safety."
Binding decisions:
- docs/decisions/session-principals.md "Non-goals" excludes "Scopes / least privilege per route". Freshness is a property of when the session last proved possession, not a scope. That reading needs to be recorded.
- docs/decisions/http-api-boundary.md and
docs/integration-contract.md: a new 403 on supported routes changes what a value means.
Settled policy decisions
- Routes — decided (maintainer, 2026-10-22). Require fresh verification for all security changes: passkey register-options and register-verify, passkey delete, principal mint, principal revoke, passkey rename, and "Sign out everywhere". Listing credentials/principals and ordinary sign-out do not gain this requirement. The maintainer selected option B, accepting that fresh verification may delay emergency revocation or be unavailable after loss of a passkey. All five policy decisions and design brief rev 2 are accepted.
- Response — decided (maintainer, 2026-10-22). Approve enforcement now as a breaking API change: guarded routes return
403 { error, code: "reauth_required" }when verification is missing or stale. The paired UI verifies and retries once. Independent clients must handle this response and perform re-verification. Applybreaking, use a changeset that explicitly names the break, aCONTRACT:commit prefix, and a same-commit contract update. Under the pre-1.0 policy, the approved break may ship in a minor release. No delayed compatibility transition is required. - Window and storage — decided (maintainer, 2026-10-22). Use a five-minute freshness window per calling session principal, persisted as a verified-at timestamp on its principal row in
brain-ui.db. Successful password login, passkey login, or permitted re-verification starts the window. Ordinary activity does not extend it. The timestamp survives server restarts and is shared consistently across processes using the database. A stolen session can retain the remaining freshness window; this tradeoff is accepted. Permitted re-verification methods are recorded in question 4. - Methods — decided (maintainer, 2026-10-22). Passkey re-verification must set a non-empty
allowCredentialslist containing existing credentials for the current RP and require user verification. Password re-entry follows the existing password-login policy: allow it when the current RP has no passkey, or when password login is explicitly re-enabled throughBRAIN_UI_ALLOW_PASSWORD; otherwise refuse it. Password re-entry shares the existing password-login failure buckets and verification concurrency limits, rather than receiving a separate guessing allowance. When no current-RP passkey exists, do not start a passkey ceremony with an empty credential list; use the permitted password path. - Record — decided (maintainer, 2026-10-22). Extend
docs/decisions/session-principals.mdwith a dated section recording all five rulings and clarifying that verification freshness proves recent identity, not per-route scopes. Do not create a separate decision record. Update the supported HTTP API contract in the implementation commit as already required.
All five policy decisions are settled. The maintainer accepted design brief rev 2 as a whole on 2026-10-22; the accepted specification and proof requirements below govern implementation.
Client prompt decisions — maintainer, 2026-10-22
The maintainer selected option A on 2026-10-22: accept design brief rev 2 as a whole. It supersedes rev 1 where they differ and preserves the three earlier rulings below.
- Passkey start — option A, decided: Show “Confirm it's you” explaining why verification is needed. Start the OS passkey ceremony only when the user activates “Verify with passkey”. Opening the prompt must not start the ceremony automatically. Accept the extra tap for explanation and user control.
- Consent ordering — option A, decided: Obtain the action's confirmation first, then verify identity if required. Keep the existing Remove/Revoke confirmation and the local-work confirmation for “Sign out everywhere”. Cancelling either step leaves the action undone; do not verify identity for an action the user has already declined.
- Lost-passkey copy — option A, decided: Name
BRAIN_UI_ALLOW_PASSWORDin the “Lost your passkey?” disclosure. Explain that security changes require a passkey for this site, ordinary sign-out remains available, and the operator can re-enable password sign-in with that setting. The maintainer corrected the initial B response to A before recording; A is the final choice. The copy supplies recovery instructions and does not itself enable password fallback or change the settled server policy.
All interview choices and the revised design are accepted. Remove needs: decision and needs: design; add agent-ready for the complete brief, retaining blocked while #2556 is open. Acceptance does not claim implementation or browser proof.
Accepted client specification
S1. Trigger.
- The prompt opens only on
403 { code: "reauth_required" }from a guarded route. BrainApimaps that response toReauthRequiredError, and a singleuseFreshActionhook per root owns the prompt.- Inside the window, no prompt ever appears.
S2. Order. For each caller:
- Remove passkey: confirm → request.
- Revoke device or agent: confirm → request.
- Sign out everywhere: local-work dialog → request.
- Add, Rename, Create agent credential: no confirm of their own → request.
- On a 403, the prompt opens, verification runs, and the request is retried once.
- Cancelling at the confirm or at the prompt leaves the action undone, with no banner.
S3. Placement.
- A modal kit
Overlay: sheet below 900 px, dialog at ≥ 900 px. - Entry motion is per D54. Close is instant, and it is not a view change, so ui-react: record the accepted destination crossfade and its D54 exception, and file its implementation briefs #2604's exception does not apply.
S4. Method. The /reauth/options answer decides the method:
- passkey only
- password only, when there is no current-RP passkey; no passkey ceremony is started
- passkey primary with Use password instead, when a passkey exists and
BRAIN_UI_ALLOW_PASSWORDis set
S5. Focus and keyboard.
- Initial focus: Verify with passkey, or the password field. Enter in the field submits.
- Escape, Android Back (
CloseWatcher) and Cancel all cancel. - On close, focus returns to the trigger. If the trigger is gone (a removed row), it goes to the list heading.
- While verifying: the button reads Verifying…, the prompt is
aria-busy, Cancel stays enabled, and cancelling aborts through ui-react: passkey ceremonies use native WebAuthn JSON APIs with an owned abort signal instead of @simplewebauthn/browser #2556's signal. - All controls are ≥ 44 px.
S6. Copy (final).
| Part | Text |
|---|---|
| Title | Confirm it's you |
| Body | {Action} changes how this brain is secured. Verify to continue. |
| Footnote | You won't be asked again for 5 minutes. |
| Buttons | Verify with passkey · Verify (password) · Cancel |
| Swap | Use password instead / Use passkey instead |
{Action} |
Adding a passkey · Removing "{label}" · Renaming "{label}" · Creating agent access · Revoking "{label}" · Signing out everywhere |
| Disclosure title | Lost your passkey? |
| Disclosure body (final) | Security changes need a passkey for this site. You can still sign out. To use your password again, whoever runs this brain can set BRAIN_UI_ALLOW_PASSWORD=1 on the server. |
The disclosure shows only when the method is passkey-only. It explains, and grants nothing: password re-entry stays refused under the ruled policy.
S7. States.
| State | Shows | Focus |
|---|---|---|
| OS sheet cancelled | Status "Not verified." (neutral, role="status") |
Primary |
| Passkey rejected | Red Callout: "That passkey couldn't be verified for {host}." |
Primary |
| Wrong password | Field error "Wrong password.", field cleared | Field |
| Rate-limited | Callout: "Too many attempts. Try again later." Verify is disabled until the server's Retry-After, if sent; otherwise until the prompt is reopened. |
Cancel |
| Retry still stale | "That took too long. Verify again." No automatic loop. | Primary |
| Offline | "You're offline. Security changes need the server." Verify is disabled. | Cancel |
S8. Multi-step registration.
- A 403 on
register-optionstriggers the prompt, then the ceremony. - A 403 on
register-verifytriggers the prompt, then one retry with the same attestation. - If the challenge has expired: "Registration timed out. Add the passkey again."
S9. Callers.
| Caller | Change |
|---|---|
PasskeyTab.onAdd |
Wrap with freshAction (both steps, per S8) |
PasskeyTab.onDelete |
Confirm, then freshAction |
PasskeyTab.onRename |
freshAction. New in rev 2: cancel restores the old label and leaves edit mode, with no error. |
PasskeyTab.confirmSignOut |
Local-work dialog, then freshAction. The loss summary is re-read after verification, as today. |
principal-store.mintAgent |
freshAction. The one-time credential shows only after a successful retry. |
DevicesAgentsTab.onRevoke |
Confirm, then freshAction. Revoking your own device still reloads. |
| Chat passkey offer, Add a passkey (#2563) | freshAction around both registration steps, per S8, exactly like PasskeyTab.onAdd. Accepted after the five-minute window that password login started, it prompts; cancelling the prompt leaves the card as it was, with no banner and no dismissal recorded, and focus returns to Add a passkey. |
Not guarded: listing passkeys and principals, and ordinary sign-out.
Both registration callers use the two-request helper (registerPasskey, packages/ui-react/src/lib/passkeys.ts:51-58: options, then verify); the Settings caller is onAdd (packages/ui-react/src/components/settings/passkey-tab.tsx:78-94). #2563's card stays until acted on or dismissed, so it can be accepted long after the window that password login started. If #2563 has not landed when this issue is implemented, the Chat row is wired by #2563 instead (its body carries the same cases); server freshness enforcement stays here either way.
Blocked by #2556
Scope
Implement the settled policy and accepted client design:
- New owner-only routes, additive:
POST /api/auth/reauth/options(request options withallowCredentialsset to current-RP credentials,userVerification: "required"),POST /api/auth/reauth/verify(passkey), andPOST /api/auth/reauth/password(password fallback under the existing password-login policy, sharing login failure buckets and verification concurrency limits). Passkey verification succeeds only for a credential of the current RP; password verification follows the password-login policy for that RP. Successful re-verification sets freshness only on the calling principal. - Persist the verified-at timestamp on the calling principal row in
brain-ui.db; successful password/passkey login and permitted re-verification set it, while ordinary activity does not extend it. - A guard on the ruled routes that returns the ruled response when the stamp is missing or at least five minutes old.
- Client: on that response, callers for every guarded security action (including principal revocation and "Sign out everywhere") run the re-verification ceremony through the native helper from ui-react: passkey ceremonies use native WebAuthn JSON APIs with an owned abort signal instead of @simplewebauthn/browser #2556, then retry once. A cancel leaves the action undone with no error banner.
- Update
docs/http-api.md, the authoritative integration-contract component, and a dated section indocs/decisions/session-principals.mdcovering all five rulings and clarifying that freshness is not a scope.
Out of scope
- Per-route scopes or a permission system (session-principals Non-goals).
- Shortening the 30-day session or adding idle timeout.
- Step-up for anything outside passkey management, principal management, and "Sign out everywhere". Ordinary sign-out remains outside this scope.
- The CLI (
packages/core): delegated principals cannot reach owner routes (requireOwner).
Acceptance criteria
- Maintainer rulings on all five questions are recorded before code is written. Questions 1-5 and design brief rev 2 are accepted above.
- Every security action selected in question 1 enforces freshness, including principal revocation, passkey rename, and "Sign out everywhere"; ordinary sign-out and read-only lists remain available without fresh verification.
- Server tests, each failing before the change:
- A stale owner session gets the ruled response on every guarded route.
- Passkey re-verification with a credential from another RP, or after the window has expired, is refused.
- After successful re-verification, the guarded route succeeds within the five-minute window and is refused at or beyond expiry.
- Successful password and passkey login initialize freshness on the new calling principal. Ordinary activity does not extend freshness, another principal does not inherit it, and reopening the database after server restart preserves the timestamp and original expiry.
- The lost-passkey disclosure names
BRAIN_UI_ALLOW_PASSWORD, explains that ordinary sign-out remains available, and does not offer password verification when server policy forbids it. - Real-browser proof: for actions with confirmation, confirmation precedes identity verification. Declining confirmation starts no verification or action request; cancelling verification leaves the action undone.
- Real-browser proof: opening the verification prompt starts no passkey ceremony; activating “Verify with passkey” starts exactly one ceremony through ui-react: passkey ceremonies use native WebAuthn JSON APIs with an owned abort signal instead of @simplewebauthn/browser #2556's helper.
- Real-Chrome runtime test (CDP virtual authenticator): deleting a passkey with a stale session prompts, verifies and completes. Cancelling leaves the passkey listed.
- Re-verification request options never contain an empty
allowCredentials. The test asserts it; when no current-RP passkey exists, the client uses the permitted password path instead. - Password re-entry is allowed when the current RP has no passkey or password login is explicitly re-enabled, and refused otherwise. Server tests cover each policy branch.
- Password login and password re-entry share failure buckets and verification concurrency limits; tests demonstrate attempts against one route consume the allowance available to the other.
- Android support: the client uses no API beyond ui-react: passkey ceremonies use native WebAuthn JSON APIs with an owned abort signal instead of @simplewebauthn/browser #2556's helper, so the fallbacks there apply.
- If ui-react: offer an explicit platform passkey after a password sign-in #2563's Chat offer exists when this lands, it goes through
freshAction, proven in real Chrome for: acceptance inside the window (no prompt, one credential); acceptance after the window expired (prompt, verify, then registration); cancelling the prompt (no credential, card unchanged, no dismissal); and freshness expiring betweenregister-optionsandregister-verify(prompt, then one retry with the same attestation, or the S8 timed-out message if the challenge expired). - The PR records a mutation: drop the guard on principal mint and watch its test fail.
Accepted client runtime and visual criteria
- Real Chrome, CDP virtual authenticator:
- Stale session: Remove → confirm → prompt → Verify with passkey → the passkey is gone and focus is on the list heading.
- Cancel at the prompt keeps the passkey listed, shows no banner, and focuses Remove "
{label}". - No
navigator.credentials.getcall happens before Verify with passkey is activated (explicit-start ruling).
- Each S9 caller with a stale session: the prompt appears with its
{Action}line after its own confirm, and the request count shows exactly one retry. - Inside the window: no prompt for any caller.
- No current-RP passkey: password field only, zero
credentials.getcalls. - Passkey-only: the disclosure renders with the S6 text. In the other method states it does not render.
- Escape, Back and Cancel cancel. Cancelling during Verifying… aborts the helper's signal.
register-verify→reauth_required: exactly one retry with the same attestation.- Rename cancel: restores the old label, and the row leaves edit mode.
- Visual baselines: new baselines for the prompt in the S7 states at 320 px and 1280 px, both themes. Existing Settings baselines are unchanged.
Verification
bun run test packages/ui-server/tests/passkeys.test.ts
bun run test packages/ui-server/tests # principals tests
bun run test packages/ui-react/tests/passkey-login-runtime.test.ts # BRAIN_REQUIRE_CHROME=1
bun run test
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. New routes, plus a new 403 on existing routes approved as breaking by the maintainer in question 2. Pre-1.0 this ships as a minor changeset that names the compatibility break, never a major one (maintainer, 2026-10-24). - This changes a published package's behaviour, so it needs a changeset.
2026-10-24: added the Chat passkey offer from #2563 to the S9 caller inventory and its four freshness cases to the criteria (the card can be accepted after the five-minute window); refreshed the registration-helper citations; moved the stacked 2026-10-22 correction notes to a comment.
Activity
schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Question 1: option B. Require fresh verification for all security changes: adding and deleting passkeys, minting and revoking delegated principals, renaming passkeys, and "Sign out everywhere". Registration guards apply to both register-options and register-verify. This accepts the tradeoff that verification can delay emergency revocation or be unavailable after losing a passkey. Ordinary sign-out and read-only lists remain outside the new guard.
The body, scope and acceptance criteria now reflect this ruling. Questions 2-5 remain unresolved, so
needs: decisionstays. No implementation is authorized by this partial ruling.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Question 2: option A. Approve the new
403 { error, code: "reauth_required" }response on the guarded security routes as a breaking API change, with enforcement introduced alongside the paired UI verification-and-retry flow. Independent clients must update; no delayed compatibility transition is required.Apply the
breakinglabel, a changeset explicitly naming the break, aCONTRACT:commit prefix and a same-commit contract update. The binding pre-1.0 versioning policy permits this approved break in a minor release. The body now reflects this ruling. Questions 3-5 remain unresolved, soneeds: decisionstays.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Question 3: option A. Use a five-minute freshness window per session principal, persisted as a verified-at timestamp on its principal row in
brain-ui.db. Successful password login, passkey login, or permitted re-verification starts the window; ordinary activity does not extend it. A restart preserves the timestamp and original expiry. Freshness is not shared with other principals.This accepts that a stolen session can retain the remaining freshness window. The body, scope and acceptance criteria now reflect the ruling. Questions 4-5 remain unresolved, so
needs: decisionstays.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Question 4: option A. Password re-entry follows the existing password-login policy: permitted when the current RP has no passkey, or when password login is explicitly re-enabled through
BRAIN_UI_ALLOW_PASSWORD; refused otherwise. It shares the existing password-login failure buckets and verification concurrency limits, preventing a second guessing allowance.Passkey re-verification uses a non-empty
allowCredentialslist of existing current-RP credentials and requires user verification. With no current-RP passkey, use the permitted password path rather than an empty-list passkey ceremony. Successful verification refreshes only the calling principal. The body, scope and acceptance criteria now reflect this ruling. Question 5 remains unresolved, soneeds: decisionstays.3 remaining items
schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Client prompt choice 1: option A. Show “Confirm it's you” explaining why verification is needed, then start the OS passkey ceremony only when the user activates “Verify with passkey”. Accept the extra tap for explanation and user control.
The issue body and runtime acceptance criteria now reflect this choice. Consent ordering and lost-passkey recovery copy remain unresolved; keep
needs: decision, the existing dependency and noagent-ready. The supplied design is a proposal; no runtime proof or approval of the whole design is claimed.schlessera commentedon Oct 22, 2026
2026-10-22 source audit at a310317: refreshed the registration (480-576), password-policy (289-295) and delete (608-620) pointers. Read the supplied shared-prompt proposal and later explicit-start ruling; preserve the remaining consent-order/recovery-copy decisions, native #2554 parent and open #2556 blocker. No ready label or implicit approval of the whole proposal is added.
schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Client prompt choice 2: option A. Confirm the sensitive action first, then verify identity when required. Keep existing Remove/Revoke confirmation and the local-work confirmation for “Sign out everywhere”. A cancellation at either step leaves the action undone. This avoids asking the user to verify for an action they then decline.
The body and runtime acceptance criteria now reflect the order. The explicit-start passkey ruling remains unchanged. Lost-passkey recovery copy remains unresolved; keep
needs: decision, the existing dependency and noagent-ready. This choice does not approve the entire design proposal or claim runtime verification.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Client prompt choice 3: option A. The maintainer corrected the initial B response to A before recording. In “Lost your passkey?”, name
BRAIN_UI_ALLOW_PASSWORDas the operator setting for re-enabling password sign-in. Explain that security changes require a passkey for this site and ordinary sign-out remains available. This is explanatory copy, not permission to bypass the existing password-verification policy.The body and acceptance criteria reflect A. All three interview choices are now settled: explicit tap to start passkey verification, action confirmation before verification, and recovery copy naming the setting. Remove
needs: decision. Retainneeds: designfor acceptance of the remaining supplied prompt proposal (placement, focus/cancellation/error states, expiry/retry and caller integration), and keep noagent-readyand the existing dependency. These individual choices do not approve the whole proposal or claim browser proof. The existing self-contained design prompt remains linked in the body and in the earlier policy decision comment.schlessera commentedon Oct 22, 2026
Design brief rev 2: the fresh-verification prompt, final for acceptance
This folds the three client rulings into the proposal (#2560 (comment)) and closes its remaining gaps. Rev 1 stays the reference for the mocks. Everything below is the complete spec to accept or amend.
Settled (rulings of 2026-10-22)
BRAIN_UI_ALLOW_PASSWORD.The spec
S1. Trigger.
403 { code: "reauth_required" }from a guarded route.BrainApimaps that response toReauthRequiredError, and a singleuseFreshActionhook per root owns the prompt.S2. Order. For each caller:
S3. Placement.
Overlay: sheet below 900 px, dialog at ≥ 900 px.S4. Method. The
/reauth/optionsanswer decides the method:BRAIN_UI_ALLOW_PASSWORDis setS5. Focus and keyboard.
CloseWatcher) and Cancel all cancel.aria-busy, Cancel stays enabled, and cancelling aborts through ui-react: passkey ceremonies use native WebAuthn JSON APIs with an owned abort signal instead of @simplewebauthn/browser #2556's signal.S6. Copy (final).
{Action}changes how this brain is secured. Verify to continue.{Action}{label}" · Renaming "{label}" · Creating agent access · Revoking "{label}" · Signing out everywhereBRAIN_UI_ALLOW_PASSWORD=1on the server.The disclosure shows only when the method is passkey-only. It explains, and grants nothing: password re-entry stays refused under the ruled policy.
S7. States.
role="status")Callout: "That passkey couldn't be verified for{host}."Callout: "Too many attempts. Try again later." Verify is disabled until the server'sRetry-After, if sent; otherwise until the prompt is reopened.S8. Multi-step registration.
register-optionstriggers the prompt, then the ceremony.register-verifytriggers the prompt, then one retry with the same attestation.S9. Callers.
PasskeyTab.onAddfreshAction(both steps, per S8)PasskeyTab.onDeletefreshActionPasskeyTab.onRenamefreshAction. New in rev 2: cancel restores the old label and leaves edit mode, with no error.PasskeyTab.confirmSignOutfreshAction. The loss summary is re-read after verification, as today.principal-store.mintAgentfreshAction. The one-time credential shows only after a successful retry.DevicesAgentsTab.onRevokefreshAction. Revoking your own device still reloads.Not guarded: listing passkeys and principals, and ordinary sign-out.
Changes from rev 1
Retry-Afterwhen present (S7).Acceptance criteria (replacing rev 1 §8)
{label}".navigator.credentials.getcall happens before Verify with passkey is activated (explicit-start ruling).{Action}line after its own confirm, and the request count shows exactly one retry.credentials.getcalls.register-verify→reauth_required: exactly one retry with the same attestation.For the maintainer
schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Option A: accept design brief rev 2 as a whole, including S1-S9 and its runtime/visual acceptance criteria. This settles placement, focus/cancellation/error states, expiry/retry and all guarded callers while preserving the earlier security policies and interaction rulings.
The body now incorporates the accepted specification and proof requirements. Remove
needs: decisionandneeds: design; addagent-readyfor the complete brief, retainingblockedfor open prerequisite #2556. Acceptance is a design ruling, not evidence of implementation or successful tests.schlessera commentedon Oct 24, 2026
History, moved from the body on 2026-10-24 (the active specification above already reflects every ruling these notes record):