fix: restrict config.toml permissions to 0600 on save - #86
Merged
yifanfeng97 merged 1 commit intoSep 3, 2026
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Owner
|
Merged — good security hygiene, and the migration path is thoughtful: warn (without leaking the key) on load, tighten to 0600 on the next save, Windows best-effort. Thanks! |
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.
Problem
he configwrites API keys into~/.he/config.tomlwith whatever mode the process umask produces. On typical Unix setups that is0644, so group and other users can read the file.Fix
On POSIX, after a successful save, chmod the config file to
0600(owner read/write only). Loading a file that is still group- or world-readable only logs a warning and still succeeds, so existing configs are not bricked; the next save tightens the mode. Windows chmod failures are swallowed and do not raise. This is file-mode restriction only — not Keychain, and not encryption. Keys remain plaintext on disk.Tests
tests/cli/test_config.pyusestmp_path. Dummy keys aresk-test/sk-xonly. POSIX asserts mode0600after save and a warning (without the key plaintext) on load of a0644file. Windows skips mode assertions but must not throw.Compatibility
Config is still plaintext on disk. Environment variables still override stored keys. Rebased onto current
main, which includes #83.Made with Cursor