fix(cli): secure config file permissions #164
Open
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.
Problem
Config files containing API tokens are created with default permissions (often 0644), making them readable by other users on shared systems.
Solution
Security: Set restrictive file permissions
0600(owner read/write only)0700(owner only)chmodcall for existing filesMaintainability: Extract
resolveConfigPath()helperChanges
packages/clawdhub/src/config.ts: Add chmod import, extract helper, secure writeGlobalConfigTesting
Greptile Overview
Greptile Summary
This PR updates the CLI global config handling in
packages/clawdhub/src/config.tsby (1) centralizing the legacyclawdhub→clawhubfallback logic intoresolveConfigPath(), and (2) attempting to harden config persistence by creating the config directory with0o700, writing the config file with0o600, andchmod-ing the file on non-Windows platforms after write.Overall, it aligns config path resolution across macOS/XDG/Windows/default locations and improves token file protection, but the directory-permission hardening is not fully enforced for pre-existing directories.
Confidence Score: 4/5
(4/5) You can add custom instructions or style guidelines for the agent here!