Repository navigation
Conversation
The setup script wrote the private key file and the config file with the default mode (usually 0644). Both could be read by any local user. The config file holds the API tokens, and with the "plain text" option it also holds the private key. Both files are now written with mode 0600. If the file already exists from an earlier run, its permissions are tightened too, since the mode given to os.open only applies when a file is created.
swlodarski-sumoheavy
approved these changes
Oct 8, 2026
This branch has not been deployed
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.
Summary
bitpay_setup.pysaved two files with the default mode (usually0644), so any local user could read them:private_key.pem: the merchant's private key.bitpay.config.json: the API tokens, and the private key too when the "plain text" option is used.Both files are now saved with mode
0600(only the owner can read and write).Changes
write_secret_fileinsrc/bitpay/utils/secret_file.py. It creates the file with0600and runschmodbefore and after writing. The mode given toos.openonly applies to new files, sochmodalso fixes files left by an older setup run.bitpay_setup.pyuses the helper for both files.tests/unit/utils/test_secret_file.py.On Windows,
chmodonly controls the read-only flag, so this change does nothing there. The tests skip on Windows.Testing
black --check src/,mypy src/,mypy -p src: OKpytest -m unit: 96 passed (93 existing + 3 new)umask 022. Before: both files0644. After: both0600, also when the files already existed with0644.Client.create_client_by_config_file_path).Jira: IM-191