Skip to content

feat: encrypt config.json at rest with AES-256-GCM#41

Closed
lohnim wants to merge 2 commits intochris/authfrom
chris/config-encryption
Closed

feat: encrypt config.json at rest with AES-256-GCM#41
lohnim wants to merge 2 commits intochris/authfrom
chris/config-encryption

Conversation

@lohnim
Copy link
Copy Markdown
Collaborator

@lohnim lohnim commented Mar 27, 2026

Summary

  • Encrypt the config file at rest using AES-256-GCM with a PBKDF2-derived key bound to machine identity (hostname + uid + username)
  • Existing plaintext configs auto-migrate to encrypted on first load
  • Fix test isolation for XDG_CONFIG_HOME/ALCHEMY_CONFIG env vars

Details

The encrypted format uses an ALCH_ENC magic prefix + version byte + random salt/IV, making it distinguishable from plaintext JSON. File permissions remain 0600. Corrupted or unreadable files gracefully fall back to empty config with a warning.

Test plan

  • Round-trip encrypt/decrypt
  • Tamper detection (GCM auth tag)
  • Plaintext auto-migration
  • Corrupted file fallback
  • All 255 existing tests pass

🤖 Generated with Claude Code

Derive a machine-bound key via PBKDF2 from hostname + uid + username
and encrypt the config file with AES-256-GCM. Existing plaintext
configs auto-migrate on first load. Also fixes test isolation for
XDG_CONFIG_HOME/ALCHEMY_CONFIG env vars.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lohnim lohnim requested a review from a team as a code owner March 27, 2026 17:55
@lohnim lohnim changed the base branch from main to chris/auth March 27, 2026 17:56
Instead of silently returning empty config, print a message explaining
the likely cause (different machine / hostname change), back up the
unreadable file to config.json.bak, and suggest reconfiguring.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lohnim lohnim closed this Mar 31, 2026
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.

1 participant