Skip to content

Save the setup key and config files with owner-only permissions (IM-190) - #396

Merged
aharoitx merged 1 commit into
bitpay:8.1.xfrom
aharoitx:fix/im190-setup-file-permissions
Sep 30, 2026
Merged

aharoitx merged 1 commit into
bitpay:8.1.xfrom
aharoitx:fix/im190-setup-file-permissions

Conversation

@aharoitx

Copy link
Copy Markdown
Contributor

Why

The setup script saved the private key file with mode 0755 and the config file with the default mode (usually 0644). 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

  • New writeSecretFile() in src/setup/SecretFile.ts. It writes the file with mode 0600 (owner only).
  • If the file already exists from an earlier run, its permissions are tightened too. The mode option of writeFile only applies when a file is created.
  • Used for both the private key file and BitPay.config.json.

Tests

  • New test/setup/secretFileUnit.spec.ts: a new file gets 0600, and an existing 0755 file becomes 0600. Skipped on Windows, where these permissions do not apply.
  • Ran the setup end to end on Linux: both files were created with 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 600 on their key file and BitPay.config.json.

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.
@aharoitx
aharoitx merged commit 5543384 into bitpay:8.1.x Sep 30, 2026
6 checks passed
@aharoitx aharoitx added this to the v8.1.0 milestone Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant