OAuth: pending auth lost on process death #15
Labels
No labels
auth
bug
composer
correctness
database
durability
enhancement
feeds
interactions
notifications
performance
reliability
safety
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starsetbyte/peregrine#15
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Pending authorization is memory-only. Android can kill app while in browser. On return, no pending auth.
Proposed fix
Persist state, code verifier, DID, PDS URL, metadata, DPoP key before opening browser. Private key behind Android Keystore.
Source: Codex code review — auth #1
Fix up in PR #32 (
fix/oauth-pending-auth-process-death).Root cause confirmed: the pending authorization (DPoP key, PKCE verifier, CSRF state, discovery) lived only in memory — on the
AtProtoOAuthClientsingleton and duplicated aspendingStateinOAuthLoginViewModel. Process death during the browser step wiped both, socompleteLoginthrewNo pending auth.New
PendingAuthStorepersists it toEncryptedSharedPreferencesbefore the browser opens and restores it on return; the persisted CSRF state is now the single source of truth (so the ViewModel no longer holds its own copy). Cleared on success.One deliberate scope note re: "private key behind Android Keystore": this PR persists the DPoP EC key as Base64 PKCS8/X509 in EncryptedSharedPreferences — i.e. encrypted at rest via the Keystore master key — which matches how the live session key is already stored in
OAuthSessionStore. Generating a fully hardware-backed, non-exportable key would diverge the two key paths, so I left that as a follow-up (noted in the PR) to harden both stores together.Will auto-close on merge.