Repository navigation
fix(store): don't silently create a second store; restrict store perms to 0700 - #24
Merged
vicentereig merged 1 commit intoJul 27, 2026
Conversation
…s to 0700 Two related problems with how the store directory is created. 1. --store defaults to a CWD-relative "./store" and the constructors create it unconditionally, so running any command from the wrong directory silently creates an empty store instead of reporting the mistake. Every later command run from there reads that empty store and reports zero messages, which is indistinguishable from data loss; an 'auth' against it leaves real session keys in a directory nobody is tracking. Only 'auth' may now bring a store into existence — everything else errors with the resolved path. 2. The store directories were created 0755, and SQLite creates the DBs 0644 under the usual umask. whatsapp.db holds the linked-device session keys (read access = account impersonation) and messages.db holds the plaintext message archive. Both are now 0700, along with the media output directory — media files themselves were already 0600. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks done
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.
Two related problems with how the store directory is created.
1. Silent duplicate stores
--storedefaults to a CWD-relative./store, and the store/client constructors create it unconditionally. So running any command from the wrong directory creates an empty second store instead of reporting the mistake. Every later command run from there reads that empty store and reports zero messages — indistinguishable from data loss. Anauthagainst such a directory is worse: it leaves real session keys somewhere nobody is tracking.This is not hypothetical. It happened three times in a single working session after I had identified the behaviour and was actively watching for it — twice from running the binary directly instead of through a wrapper, once from a
go testrun inside the repo. That is why I do not think documentation fixes it.Only
authmay now bring a store into existence; every other command errors with the resolved path:2. Permissions
The store directories were created
0755, and SQLite creates the DBs0644under the usual umask.whatsapp.dbholds the linked-device session keys — read access is account impersonation — andmessages.dbholds the plaintext message archive with contact names and phone numbers. Both are now0700, along with the media output directory. Media files themselves were already0600viaCreateTemp+Rename; the directory was the only part left readable.Tests
checkStorePresenceis extracted as a pure function and table-tested, including that it does not create the directory as a side effect. Store permissions are asserted ininternal/store.go build ./...,go test ./...andgo test -race ./...all pass.