Move auth file to $XDG_RUNTIME_DIR for improved security#183
Closed
Move auth file to $XDG_RUNTIME_DIR for improved security#183
Conversation
Use $XDG_RUNTIME_DIR/keepmenu/ for storing the auth file instead of ~/.cache/. This provides better security because: - tmpfs-backed: auth keys never written to persistent disk storage - Auto-cleanup: files removed automatically on user logout - Enforced permissions: systemd guarantees 0700 on the directory Falls back to ~/.cache/ if XDG_RUNTIME_DIR is not available. https://claude.ai/code/session_013sXF2YWWf8yW5hRuhGVbZU
Change fallback from ~/.cache/ to $TMPDIR/keepmenu-<uid>/ when $XDG_RUNTIME_DIR is not available. This is more secure because: - $TMPDIR is typically tmpfs (memory-backed, not persisted to disk) - Cleared on reboot (no stale auth files) - Forensic recovery not possible - User-specific subdirectory with 0700 permissions ensures privacy https://claude.ai/code/session_013sXF2YWWf8yW5hRuhGVbZU
Tests cover: - $XDG_RUNTIME_DIR used when set and exists - Fallback to $TMPDIR/keepmenu-<uid>/ when XDG_RUNTIME_DIR not set - Fallback when XDG_RUNTIME_DIR is set but path doesn't exist - Directory created with 0700 permissions https://claude.ai/code/session_013sXF2YWWf8yW5hRuhGVbZU
tempfile.gettempdir() caches its result. Setting TMPDIR environment variable after import doesn't affect the cached value. Reset tempfile.tempdir = None before tests that modify TMPDIR so the function re-evaluates the temp directory path. https://claude.ai/code/session_013sXF2YWWf8yW5hRuhGVbZU
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.
Use $XDG_RUNTIME_DIR/keepmenu/ for storing the auth file instead of
~/.cache/. This provides better security because:
Falls back to ~/.cache/ if XDG_RUNTIME_DIR is not available.
https://claude.ai/code/session_013sXF2YWWf8yW5hRuhGVbZU