Repository navigation
fix(auth): write the token store owner-only from the start and lock updates - #530
Merged
Merged
Conversation
…pdates The store was written to a fixed-name temp file and narrowed to 0600 afterwards, so the tokens were briefly readable under the default umask, and two writers shared the temp name. The temp file is now created 0600 under a unique name. set and remove hold a lock file across their read-modify-write, so two processes (a login and a token refresh) no longer lose an update. Co-Authored-By: Claude Fable 5.2 <[email protected]>
mrnasil
enabled auto-merge (squash)
December 2, 2026 15:58
The test made the save fail with a directory at the old fixed temp name, which the store no longer uses. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
From the same source audit as #527, #528 and #529.
Problem
auth.jsonwas written to a fixed-name temp file (auth.json.tmp) and narrowed to0600only afterwards. Until then the tokens were readable under the directory's permissions and the default umask, and two writers shared one temp name.setandremoveare read-modify-write with no lock, so a login in one process and a token refresh in another could drop each other's update.Change
0600(Unix) under a name unique to the process and the write, then renamed over the store. A failed write removes it.setandremoveholdauth.json.lock(an advisory lock, released when the call returns) across the read-modify-write.Windows is unchanged for permissions: the store relies on the per-user data directory there, as before.
Verification
0600, a failed replace leaves no temp file, eight concurrent writers keep all eight entries, an unusable lock path reports an I/O error.whycodes-authmeasured locally: no missed lines.🤖 Generated with Claude Code