Repository navigation
Save the setup key and config files with owner-only permissions (IM-190) - #396
Merged
Merged
Conversation
The setup script wrote the private key file with mode 0755 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 option of writeFile only applies when a file is created.
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.
Why
The setup script saved the private key file with mode
0755and the config file with the default mode (usually0644). Any local user could read both. The config file holds the API tokens, and with the "plain text" option it also holds the private key.Reported through the bug bounty program (IM-190). Low severity: it needs local access to the machine.
What changed
writeSecretFile()insrc/setup/SecretFile.ts. It writes the file with mode0600(owner only).modeoption ofwriteFileonly applies when a file is created.BitPay.config.json.Tests
test/setup/secretFileUnit.spec.ts: a new file gets0600, and an existing0755file becomes0600. Skipped on Windows, where these permissions do not apply.0600.Note for the release
Files created by earlier versions keep their old permissions until setup runs again. The release notes should tell users to run
chmod 600on their key file andBitPay.config.json.