You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(codex): fence retained native login by account identity - #8808
A complete Native main login could remain retained after another component observed a different physical account in the same auth file. During a later empty or partial rewrite, the proxy could return the previous account's credential.
Bind retained logins and observation tickets to the existing main-account identity generation, in addition to retention, file-identity, and credential-mutation fences.
Refuse stale asynchronous completions and same-fingerprint reuse across an account transition, including A → B → A.
Complete the existing owned lifecycle identity transition before capturing a new token/status retention ticket. This retires the previous account's runtime state first and preserves a newly read account through later same-account reconciliation.
Keep write-guard/device-reauth observations and explicit pre-exchange refresh tickets within their existing authority.
Update the retention contract and add attack-path and normal-rewrite regressions.
Verification
Recorded local validation:
bun test tests/codex-integration/native-main-credentials-retention.test.ts: 35 passed, 169 assertions.
Five new attack regressions failed against the unchanged implementation. The final suite covers independently observed replacement, empty/partial writes, A → B → A, stale regular/forced refresh completion, same-fingerprint reuse, write-guard authority, normal refresh, ownership loss, and expiration.
Fresh independent review found a double-transition compatibility gap when B was read before lifecycle reconciliation. Four token/status × empty/partial controls failed on that intermediate candidate and pass after sharing the existing lifecycle transition; they also verify that A's cached info is cleared first.
Typecheck passed across 2,536 files. Structure, privacy, file-size ratchet and staged whitespace checks passed.
Cold imports starting from either main-account or account-lifecycle passed with a private empty test home and a network-rejecting stub. The static import closure remained 288 modules, with no added Lab path.
Posted-head CI 43812231165 passed, including the Typecheck step and test changed job. Catalog checks also passed. This is exact-head hosted evidence; the local results above are retained prior validation and were not rerun for this status change.
A source comparison against dev c36793a9336b70cfe5bc3b7f6e6f751e730fb6fc found no duplicate implementation or incompatible contract change requiring a rebase. Maintainer security review and installed/live application validation remain separate; review readiness does not claim merge or release acceptance.
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed.
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
The security checkbox records implementation review; explicit maintainer security review and the repository's maintainer-sponsored requirement for authentication surfaces remain required before merge.
Summary by CodeRabbit
Bug Fixes
Improved native sign-in reliability when account identity changes. Previously retained login credentials are no longer reused after an account replacement or identity change, including changes that occur while a refresh is in progress. Incomplete or empty credential updates retain access only while the associated account identity remains valid. This helps prevent an earlier login from becoming usable again after the account has changed.
No actionable comments were generated in the recent review.
Walkthrough
Complete credential reads now observe the main-account identity before capturing eligible retention tickets. Retained native-main logins and observation tickets are bound to that identity generation, and stale generations are rejected.
Changes: Native-main login retention
Layer / File(s)
Summary
Reconcile identity on owned reads src/codex/account-lifecycle.ts, src/codex/main-account.ts, tests/codex-integration/native-main-credentials-retention.test.ts
Complete credential reads observe account identity before capturing a retention ticket when native-main traffic is allowed and retained credentials are enabled. Tests cover identity reconciliation during token and status reads and when native reauthentication starts.
Fence retained logins by identity generation src/codex/native-main-credentials.ts, tests/codex-integration/native-main-credentials-retention.test.ts, structure/providers/native-main-login-retention.md
Observation tickets and retained entries include the account identity generation. Retention rejects stale tickets, and reads invalidate entries whose generation is no longer live. Tests cover account changes, identity round trips, and refreshes; the documentation describes the generation checks.
lidge-jun/opencodex#8766: Adds process-memory retention for complete native-main logins. This change updates the retention contract in the same files and functions.
Merge Risk: Minimal · up to 5a76b
The change stops a retained native login from returning credentials for a previous account after the account changes. No concrete merge-blocking defect was found. Maintainer security review and installed-application validation are still pending, as the PR description states.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: retained native main-account login is now fenced by account identity generation, which the raw summary and PR objectives both describe. The title is specific and match…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: retained native main-account login is now fenced by account identity generation, which the raw summary and PR objectives both describe. The title is specific and matches the changeset, and it stays within the 8-word, single-sentence style.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Required PR checks at that head: gates SUCCESS; test jobs SUCCESS: test changed; no failing or pending checks.
Lane R4 verdict MERGE-READY with an independent security review (PASS-WITH-NITS); merged tree with dev passed 60/60 focused tests and typecheck; coordinator reviewed the src diff (identity-generation fence on native-main retention).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A complete Native main login could remain retained after another component observed a different physical account in the same auth file. During a later empty or partial rewrite, the proxy could return the previous account's credential.
Verification
Recorded local validation:
bun test tests/codex-integration/native-main-credentials-retention.test.ts: 35 passed, 169 assertions.Posted-head CI 43812231165 passed, including the Typecheck step and test changed job. Catalog checks also passed. This is exact-head hosted evidence; the local results above are retained prior validation and were not rerun for this status change.
A source comparison against dev
c36793a9336b70cfe5bc3b7f6e6f751e730fb6fcfound no duplicate implementation or incompatible contract change requiring a rebase. Maintainer security review and installed/live application validation remain separate; review readiness does not claim merge or release acceptance.Checklist
The security checkbox records implementation review; explicit maintainer security review and the repository's
maintainer-sponsoredrequirement for authentication surfaces remain required before merge.Summary by CodeRabbit