Security: SessionManager/OAuthSessionStore apply() → commit() for auth-critical writes #37
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#37
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?
What
SessionManager and OAuthSessionStore use
SharedPreferences.edit().apply()(async) for auth-critical writes instead ofcommit()(sync). If the process dies between the async write and disk flush, tokens and session data are lost.Affected locations
SessionManager.saveSession()— access/refresh JWT + DID + handleSessionManager.saveOAuthSession()— DID + handle + auth modeSessionManager.clearSession()— session wipeSessionManager.saveAppPassword()— app password credentialsOAuthSessionStore.clear()— OAuth session wipeOAuthSessionStore.updateTokens()— access/refresh token rotationWhy it matters
apply()returns immediately but writes to disk asynchronously. If the process is killed before the background write completes, the data is never persisted. For auth data (tokens, passwords, session state), this can cause:clearSession()— user thinks they logged out but tokens persistFix
All
apply()calls at the locations above changed tocommit(). The OAuth nonce update methods (updateResourceNonce,updateAuthServerNonce) intentionally keepapply()since nonce staleness is recovered automatically (server returnsuse_dpop_nonce→ retry).Fixed in current working tree.