Skip to content

Protect MCP OAuth persistence from stale credential writes - #60849

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/3d7c603950afcff72f0bcd943edae5ecfbcb5bd2
Nov 11, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/3d7c603950afcff72f0bcd943edae5ecfbcb5bd2

Conversation

@copyberry

@copyberry copyberry Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Protect MCP OAuth persistence from stale credential writes

Why

A pending token refresh must not overwrite a newer login or recreate credentials after logout. Legacy file entries also need to retain their stored identity across refreshes.

What changed

  • Lock and revalidate stored credentials before persisting changed authorization-manager credentials, requiring authorization again if storage has changed.
  • Update file-backed refreshes only when the matched entry still contains the expected credentials, preserving its key, server name, and ownership. Compare only fields the file format can persist.
  • Remove matching legacy file entries when saving login credentials or deleting credentials, while preserving unrelated entries and profile-scoped enterprise credentials' separate local entries.

Testing

Add regression coverage for newer logins and logout during pending persistence, repeated refreshes of legacy and escaped-name entries, and cleanup that preserves unrelated credentials. Update guard-retention and telemetry assertions for the validation path.

## Why

A pending token refresh must not overwrite a newer login or recreate credentials after logout. Legacy file entries also need to retain their stored identity across refreshes.

## What changed

- Lock and revalidate stored credentials before persisting changed authorization-manager credentials, requiring authorization again if storage has changed.
- Update file-backed refreshes only when the matched entry still contains the expected credentials, preserving its key, server name, and ownership. Compare only fields the file format can persist.
- Remove matching legacy file entries when saving login credentials or deleting credentials, while preserving unrelated entries and profile-scoped enterprise credentials' separate local entries.

## Testing

Add regression coverage for newer logins and logout during pending persistence, repeated refreshes of legacy and escaped-name entries, and cleanup that preserves unrelated credentials. Update guard-retention and telemetry assertions for the validation path.

GitOrigin-RevId: 3d7c603950afcff72f0bcd943edae5ecfbcb5bd2
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/3d7c603950afcff72f0bcd943edae5ecfbcb5bd2 branch from 859b46d to 392ced7 Compare November 11, 2026 19:19
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor
Codex Review Summary: 🔄 Running

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-11-11T19:19:15.344439Z 859b46d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@copyberry
copyberry Bot merged commit 392ced7 into main Nov 11, 2026
6 of 23 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/3d7c603950afcff72f0bcd943edae5ecfbcb5bd2 branch November 11, 2026 19:19
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 11, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — 392ced7d Deployed Nov 11, 2026 by jkodev via Identify potential duplicates (open issues fallback) #62879
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.