Skip to content

Move auth file to $XDG_RUNTIME_DIR for improved security#183

Closed
firecat53 wants to merge 4 commits intomainfrom
claude/systemd-state-directory-vCbMd
Closed

Move auth file to $XDG_RUNTIME_DIR for improved security#183
firecat53 wants to merge 4 commits intomainfrom
claude/systemd-state-directory-vCbMd

Conversation

@firecat53
Copy link
Owner

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

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
@firecat53 firecat53 closed this Feb 5, 2026
@firecat53 firecat53 deleted the claude/systemd-state-directory-vCbMd branch February 5, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants