Repository navigation
create config file with owner-only permissions at both write sites - #333
Draft
vkrastanov wants to merge 1 commit into
Draft
vkrastanov wants to merge 1 commit into
vkrastanov wants to merge 1 commit into
Conversation
~/.cf_client_python.json holds the long-lived refresh token, but both write sites created it with a plain open(path, "w") and no permission control, so its mode was silently inherited from the caller's umask — world-readable (0644) under the default umask 022. This is inconsistent with how credential files are normally handled and leaves the token readable by any other local user or process on a shared host. Add a _write_config_file helper and route both write sites through it: import_from_clf_cli() and the interactive first-run path in build_client_from_configuration(). The helper creates the file with os.open(..., 0o600) and unconditionally chmods it to 0600 afterwards, so an existing file left loose by an earlier version gets tightened on the next write as well. Behavior verified before/after: 0644 (unfixed, umask 022) -> 0600 for new files under umask 022/077 and for pre-existing 0644 files, with identical file content in all cases.
antechrestos
approved these changes
Oct 23, 2026
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.
~/.cf_client_python.json holds the long-lived refresh token, but both write sites created it with a plain open(path, "w") and no permission control, so its mode was silently inherited from the caller's umask — world-readable (0644) under the default umask 022. This is inconsistent with how credential files are normally handled and leaves the token readable by any other local user or process on a shared host.
Add a _write_config_file helper and route both write sites through it: import_from_clf_cli() and the interactive first-run path in build_client_from_configuration(). The helper creates the file with os.open(..., 0o600) and unconditionally chmods it to 0600 afterwards, so an existing file left loose by an earlier version gets tightened on the next write as well.
Behavior verified before/after: 0644 (unfixed, umask 022) -> 0600 for new files under umask 022/077 and for pre-existing 0644 files, with identical file content in all cases.