Repository navigation
Closed
Description
Feature Request: Secure Token Storage in OS Keyring
Problem
Currently, the Coder CLI stores authentication tokens in plaintext configuration files, which poses a security risk. Users' tokens are stored unencrypted and can be easily accessed by other processes or users with file system access.
Proposed Solution
Implement secure token storage using the OS keyring with graceful fallback to file storage when keyring is unavailable.
Acceptance Criteria
-
CLI should by default store the token in the OS keyring using a library like zalando/go-keyring
- Keychain on macOS
- GNOME Keyring on Linux (Secret Service dbus interface)
- Wincred on Windows
-
CLI should fallback to storing the token in text file if the keyring is not available
- Maintain backward compatibility
- Ensure minimal disruption if keyring operations fail
- Log appropriate warnings when falling back to file storage
-
Address security considerations from GitHub CLI's keyring implementation discussion:
- Consider the security implications of using
zalando/go-keyringwhich shells out to thesecuritycommand on macOS - On macOS, this grants access to the
securitybinary rather than the specific application, which can weaken the security model - Document this limitation and consider future improvements to use native APIs
- Despite this limitation, keyring storage is still significantly more secure than plaintext files
- Consider the security implications of using
Implementation Considerations
- Library Choice: Use
zalando/go-keyringfor pure Go implementation without CGO requirements - Migration: Handle existing plaintext tokens gracefully during the transition
- Error Handling: Robust fallback mechanism when keyring operations fail
- Cross-platform: Ensure consistent behavior across macOS, Linux, and Windows
- User Experience: Minimal prompts and clear messaging about keyring access
- Testing: Comprehensive tests for both keyring and fallback scenarios
Security Benefits
- Tokens encrypted at rest using OS-provided security mechanisms
- Reduced risk of accidental token exposure in config files
- Better integration with enterprise security policies
References
Reacted by Atif Ali and Ben Potter
Activity
cli: macOS store session token in Keychain with file fallback
zedkipp commentedon Oct 16, 2025
Some updates on the desire of this feature:
EDIT: after more discussion/investigation into session token compatibility with Coder Desktop (and other Coder apps/plugins), I think we need to make keyring usage opt-in. As a result, I think there's no real need for fallback behavior. I am putting more internal details here: https://www.notion.so/coderhq/CLI-Session-Token-in-OS-Keyring-293d579be592808b8b7fd235304e50d5
feat(cli): optionally store session token in OS keyring (#20256)
[-]Store CLI authentication tokens in OS keyring with fallback to file storage[/-][+]Optionally store CLI authentication tokens in OS keyring[/+]feat(cli): add macOS support for session token keyring storage (#20613)
zedkipp commentedon Nov 26, 2025
I have merged changes that make keyring usage on by default for Windows and macOS, with an optional opt-out CLI flag. That means this should be in the 2.29 release. Linux continues to use plain-text files for now (could be added in the future - has some complexity w.r.t. the OS keyring).