fix: tighten file permissions on downloads and backups#24
Open
merv-nexura wants to merge 1 commit intotawanorg:mainfrom
Open
fix: tighten file permissions on downloads and backups#24merv-nexura wants to merge 1 commit intotawanorg:mainfrom
merv-nexura wants to merge 1 commit intotawanorg:mainfrom
Conversation
Downloaded files now use 0600 (was 0644), and download/backup directories now use 0700 (was 0755). Claude config may contain API keys and personal context; world-readable permissions allowed any process running as the user — or any other user with read access to the home directory — to read it. Addresses L2 and L3 from SECURITY-AUDIT.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Tightens permissions on files and directories that contain Claude config:
internal/sync/sync.go— files written byPullare now0600(was0644); the parent directory created on demand is0700(was0755).cmd/claude-sync/main.go— the~/.claude.backup.<ts>directory created during a first-pull-with-existing-files flow, its nested subdirectories, and the files copied into it now use0700/0700/0600(was0755/0755/0644).This addresses L2 and L3 in
SECURITY-AUDIT.md. Claude config may contain API keys, prompts, and personal context; world-readable permissions allowed any other user with read access to the home directory — or any process running on the box — to read it. The encryption key file at~/.claude-sync/age-key.txtis already0600, and the config dir is already0700, so this brings the synced/backed-up data in line with that posture.Self-update at
cmd/claude-sync/main.go:1694(which writes the new binary as0755) is intentionally not changed — it's an executable.Tests
internal/sync.TestPullSetsRestrictivePermissions— pulls a remote file at a nested path (agents/helper.json.age) so the pull has to create the parent directory, then assertsMode().Perm()is exactly0600for the file and0700for the directory. (Nested path is required becauseos.MkdirAlldoes not modify the mode of pre-existing directories.)cmd/claude-sync.TestCreateBackupSetsRestrictivePermissions— callscreateBackup()directly withHOMEswapped to a tempdir, asserts backup root, nested subdir, and copied file are0700/0700/0600.Both tests pass; full `go test ./...` is green.
Test plan
Note
This is the first of a planned series of small focused PRs to address findings in `SECURITY-AUDIT.md`.