Skip to content

fix(security): enable Claude OAuth refresh and tighten sandbox access#16

Merged
Pierozi merged 1 commit intomainfrom
fix/claude-refresh-token
Feb 2, 2026
Merged

fix(security): enable Claude OAuth refresh and tighten sandbox access#16
Pierozi merged 1 commit intomainfrom
fix/claude-refresh-token

Conversation

@Pierozi
Copy link
Contributor

@Pierozi Pierozi commented Feb 2, 2026

Summary

  • Fixes OAuth token refresh failure when running Claude Code in sandbox (401 authentication_error)
  • Enforces shift-left security principle by replacing broad ~/Library read with allowlist of safe subdirectories
  • Reduces attack surface by restricting write access to session-specific temp directory instead of all /var/folders

Details

Root cause: Claude stores OAuth tokens in macOS Keychain (~/Library/Keychains/login.keychain-db). The sandbox allowed reading but not writing to the keychain, blocking token refresh after ~24 hours.

Changes:

  1. OAuth Fix: Added write access to ~/Library/Keychains/login.keychain-db (token refresh)

  2. Read Security: Replaced ~/Library (ALL data) with:

    • ~/Library/Caches/
    • ~/Library/Preferences/
    • ~/Library/Application Support/
    • ~/Library/Logs/
    • ~/Library/Frameworks/
    • ~/Library/Keychains/ ✓ (encrypted, requires Security framework ACL)
    • ~/Library/Developer/

    Now protected: Cookies, Mail, Messages, Safari, Calendar, Contacts, Accounts

  3. Write Security: Restricted to session-specific temp:

    • Before: /private/var/folders, /var/folders (ALL apps' temp)
    • After: $TMPDIR (session-only)

Test plan

  • Run sx claude -- claude /login and verify token refresh works
  • Run sx -- mktemp to verify temp file creation still works
  • All existing tests pass (cargo test)

- Add write access to ~/Library/Keychains/login.keychain-db for token refresh
- Replace broad ~/Library read with allowlist (Caches, Preferences, etc.)
- Restrict write to session-specific $TMPDIR instead of all /var/folders
- Deny access to sensitive Library paths (Cookies, Mail, Messages, Safari)
- Enforce deny rules for critical sensitive paths in base profile
@Pierozi Pierozi force-pushed the fix/claude-refresh-token branch from 7bb841c to 6a46bc1 Compare February 2, 2026 08:14
@Pierozi Pierozi added enhancement New feature or request security labels Feb 2, 2026
@Pierozi Pierozi self-assigned this Feb 2, 2026
@Pierozi Pierozi merged commit 6864fe8 into main Feb 2, 2026
6 checks passed
@Pierozi Pierozi deleted the fix/claude-refresh-token branch February 3, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant